Set default artifact type to empty value

Add non regression test for
https://github.com/alexarchambault/coursier/issues/322

A dirty hack is lying in this commit.
This commit is contained in:
Alexandre Archambault 2016-08-15 16:14:30 +02:00
parent 908a596b6d
commit 1b0dd4e899
No known key found for this signature in database
GPG Key ID: 14640A6839C263A9
7 changed files with 47 additions and 5 deletions

View File

@ -61,10 +61,10 @@ case class CommonOptions(
@Value("configuration")
@Short("c")
defaultConfiguration: String = "default(compile)",
@Help("Default artifact type (make it empty to follow POM packaging - default: jar)")
@Help("Default artifact type (default: follow packaging infos, else default to jar)")
@Value("type")
@Short("a")
defaultArtifactType: String = "jar",
defaultArtifactType: String = "",
@Help("Maximum number of parallel downloads (default: 6)")
@Short("n")
parallel: Int = 6,

View File

@ -69,6 +69,10 @@ object MavenRepository {
} else
module.name
val ignorePackaging = Set(
Module("org.apache.zookeeper", "zookeeper", Map.empty)
)
}
case class MavenRepository(
@ -76,7 +80,8 @@ case class MavenRepository(
changing: Option[Boolean] = None,
/** Hackish hack for sbt plugins mainly - what this does really sucks */
sbtAttrStub: Boolean = false,
authentication: Option[Authentication] = None
authentication: Option[Authentication] = None,
packagingBlacklist: Set[Module] = MavenRepository.ignorePackaging
) extends Repository {
import Repository._
@ -260,7 +265,11 @@ case class MavenRepository(
_ <- if (xml.label == "project") \/-(()) else -\/("Project definition not found")
proj <- Pom.project(xml)
} yield {
val packagingOpt = Pom.packagingOpt(xml)
val packagingOpt =
if (packagingBlacklist(module))
None
else
Pom.packagingOpt(xml)
proj.copy(
configurations = defaultConfigurations,

View File

@ -59,7 +59,7 @@ object CoursierPlugin extends AutoPlugin {
override lazy val projectSettings = Seq(
coursierParallelDownloads := 6,
coursierMaxIterations := 50,
coursierDefaultArtifactType := "jar",
coursierDefaultArtifactType := "",
coursierChecksums := Seq(Some("SHA-1"), None),
coursierArtifactsChecksums := Seq(None),
coursierCachePolicies := CachePolicy.default,

View File

@ -0,0 +1,13 @@
scalaVersion := "2.11.8"
libraryDependencies += ("com.rengwuxian.materialedittext" % "library" % "2.1.4")
.exclude("com.android.support", "support-v4")
.exclude("com.android.support", "support-annotations")
.exclude("com.android.support", "appcompat-v7")
coursierCachePolicies := {
if (sys.props("os.name").startsWith("Windows"))
coursierCachePolicies.value
else
Seq(coursier.CachePolicy.ForceDownload)
}

View File

@ -0,0 +1,11 @@
{
val pluginVersion = sys.props.getOrElse(
"plugin.version",
throw new RuntimeException(
"""|The system property 'plugin.version' is not defined.
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin
)
)
addSbtPlugin("io.get-coursier" % "sbt-coursier" % pluginVersion)
}

View File

@ -0,0 +1,6 @@
import java.io.File
import java.nio.file.Files
object Main extends App {
Files.write(new File("output").toPath, "OK".getBytes("UTF-8"))
}

View File

@ -0,0 +1,3 @@
$ delete output
> run
$ exists output