mirror of https://github.com/sbt/sbt.git
Merge pull request #5403 from eed3si9n/wip/artifacts
Fix the default artifact of packageSrc for custom configuration
This commit is contained in:
commit
7360e6342e
|
|
@ -1375,10 +1375,14 @@ object Defaults extends BuildCommon {
|
|||
val configurations = cOpt.map(c => ConfigRef(c.name)).toVector
|
||||
if (combined.isEmpty) a.withClassifier(None).withConfigurations(configurations)
|
||||
else {
|
||||
val classifierString = combined mkString "-"
|
||||
a.withClassifier(Some(classifierString))
|
||||
.withType(Artifact.classifierType(classifierString))
|
||||
val a1 = a
|
||||
.withClassifier(Some(combined.mkString("-")))
|
||||
.withConfigurations(configurations)
|
||||
// use "source" as opposed to "foo-source" to retrieve the type
|
||||
classifier match {
|
||||
case Some(c) => a1.withType(Artifact.classifierType(c))
|
||||
case None => a1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,19 @@ import sbt.internal.inc.classpath.ClasspathUtilities
|
|||
|
||||
lazy val checkFull = taskKey[Unit]("")
|
||||
lazy val check = taskKey[Unit]("")
|
||||
lazy val checkArtifact = taskKey[Unit]("")
|
||||
|
||||
ThisBuild / useCoursier := false
|
||||
ThisBuild / scalaVersion := "2.12.10"
|
||||
ThisBuild / version := "0.1.0-SNAPSHOT"
|
||||
ThisBuild / organization := "com.example"
|
||||
ThisBuild / organizationName := "example"
|
||||
|
||||
lazy val Dev = config("dev").extend(Compile)
|
||||
.describedAs("Dependencies required for development environments")
|
||||
|
||||
lazy val root = (project in file("."))
|
||||
.configs(Dev)
|
||||
.settings(
|
||||
ivyPaths := IvyPaths(baseDirectory.value, Some(target.value / "ivy-cache")),
|
||||
publishTo := Some(Resolver.file("Test Publish Repo", file("test-repo"))),
|
||||
|
|
@ -17,8 +26,22 @@ lazy val root = (project in file("."))
|
|||
// needed to add a jar with a different type to the managed classpath
|
||||
unmanagedClasspath in Compile ++= scalaInstance.value.libraryJars.toSeq,
|
||||
classpathTypes := Set(tpe),
|
||||
|
||||
// custom configuration artifacts
|
||||
inConfig(Dev)(Defaults.compileSettings),
|
||||
addArtifact(Dev / packageBin / artifact, Dev / packageBin),
|
||||
addArtifact(Dev / packageDoc / artifact, Dev / packageDoc),
|
||||
addArtifact(Dev / packageSrc / artifact, Dev / packageSrc),
|
||||
Dev / publishArtifact := true,
|
||||
check := checkTask(dependencyClasspath).value,
|
||||
checkFull := checkTask(fullClasspath).value
|
||||
checkFull := checkTask(fullClasspath).value,
|
||||
checkArtifact := {
|
||||
val d = (Dev / packageSrc / artifact).value
|
||||
assert(d.`type` == "src", s"${d.`type`} is not src")
|
||||
|
||||
val t = (Test / packageSrc / artifact).value
|
||||
assert(t.`type` == "src", s"${t.`type`} is not src")
|
||||
}
|
||||
)
|
||||
|
||||
// define strings for defining the artifact
|
||||
|
|
|
|||
|
|
@ -17,3 +17,5 @@ $ touch retrieve
|
|||
|
||||
# verify that artifact with extension, type, and classifier can be retrieved
|
||||
> check
|
||||
|
||||
> checkArtifact
|
||||
|
|
|
|||
Loading…
Reference in New Issue