mirror of https://github.com/sbt/sbt.git
Merge pull request #509 from coursier/topic/javadoc-sources-config
Publish sources / javadoc under the right conf
This commit is contained in:
commit
6e79dcab9c
|
|
@ -158,21 +158,68 @@ object Tasks {
|
|||
sbt.Keys.ivyConfigurations
|
||||
).map { (state, projectRef, projId, sv, sbv, ivyConfs) =>
|
||||
|
||||
val packageTasks = Seq(packageBin, packageSrc, packageDoc)
|
||||
val sbtBinArtifacts =
|
||||
for ((config, targetConfig) <- configsMap) yield {
|
||||
|
||||
val publish = publishArtifact
|
||||
.in(projectRef)
|
||||
.in(packageBin)
|
||||
.in(config)
|
||||
.getOrElse(state, false)
|
||||
|
||||
val sbtArtifacts =
|
||||
for {
|
||||
pkgTask <- packageTasks
|
||||
(config, targetConfig) <- configsMap
|
||||
} yield {
|
||||
val publish = publishArtifact.in(projectRef).in(pkgTask).in(config).getOrElse(state, false)
|
||||
if (publish)
|
||||
artifact.in(projectRef).in(pkgTask).in(config).find(state)
|
||||
artifact
|
||||
.in(projectRef)
|
||||
.in(packageBin)
|
||||
.in(config)
|
||||
.find(state)
|
||||
.map(targetConfig -> _)
|
||||
else
|
||||
None
|
||||
}
|
||||
|
||||
val sbtSourceArtifacts =
|
||||
for ((config, _) <- configsMap) yield {
|
||||
|
||||
val publish = publishArtifact
|
||||
.in(projectRef)
|
||||
.in(packageSrc)
|
||||
.in(config)
|
||||
.getOrElse(state, false)
|
||||
|
||||
if (publish)
|
||||
artifact
|
||||
.in(projectRef)
|
||||
.in(packageSrc)
|
||||
.in(config)
|
||||
.find(state)
|
||||
.map("sources" -> _)
|
||||
else
|
||||
None
|
||||
}
|
||||
|
||||
val sbtDocArtifacts =
|
||||
for ((config, _) <- configsMap) yield {
|
||||
|
||||
val publish = publishArtifact
|
||||
.in(projectRef)
|
||||
.in(packageDoc)
|
||||
.in(config)
|
||||
.getOrElse(state, false)
|
||||
|
||||
if (publish)
|
||||
artifact
|
||||
.in(projectRef)
|
||||
.in(packageDoc)
|
||||
.in(config)
|
||||
.find(state)
|
||||
.map("docs" -> _)
|
||||
else
|
||||
None
|
||||
}
|
||||
|
||||
val sbtArtifacts = sbtBinArtifacts ++ sbtSourceArtifacts ++ sbtDocArtifacts
|
||||
|
||||
def artifactPublication(artifact: sbt.Artifact) = {
|
||||
|
||||
val name = FromSbt.sbtCrossVersionName(
|
||||
|
|
|
|||
|
|
@ -0,0 +1,68 @@
|
|||
|
||||
val org = "io.get-coursier.scriptedtest"
|
||||
val ver = "0.1.0-SNAPSHOT"
|
||||
|
||||
lazy val foo = project
|
||||
.settings(
|
||||
shared
|
||||
)
|
||||
|
||||
lazy val bar = project
|
||||
.settings(
|
||||
shared,
|
||||
libraryDependencies += org %% "foo" % ver
|
||||
)
|
||||
|
||||
|
||||
lazy val shared = Seq(
|
||||
organization := org,
|
||||
version := ver,
|
||||
scalaVersion := "2.11.8",
|
||||
confCheck := {
|
||||
|
||||
val updateReport = update.value
|
||||
val updateClassifiersReport = updateClassifiers.value
|
||||
|
||||
def artifacts(config: String, classifier: Option[String], useClassifiersReport: Boolean = false) = {
|
||||
|
||||
val configReport = (if (useClassifiersReport) updateClassifiersReport else updateReport)
|
||||
.configuration(config)
|
||||
.getOrElse {
|
||||
throw new Exception(
|
||||
s"$config configuration not found in update report"
|
||||
)
|
||||
}
|
||||
|
||||
val artifacts = configReport
|
||||
.modules
|
||||
.flatMap(_.artifacts)
|
||||
.collect {
|
||||
case (a, _) if a.classifier == classifier =>
|
||||
a
|
||||
}
|
||||
|
||||
streams.value.log.info(
|
||||
s"Found ${artifacts.length} artifacts for config $config / classifier $classifier" +
|
||||
(if (useClassifiersReport) " in classifiers report" else "")
|
||||
)
|
||||
for (a <- artifacts)
|
||||
streams.value.log.info(" " + a)
|
||||
|
||||
artifacts
|
||||
}
|
||||
|
||||
val compileSourceArtifacts = artifacts("compile", Some("sources"))
|
||||
val sourceArtifacts = artifacts("compile", Some("sources"), useClassifiersReport = true)
|
||||
|
||||
val compileDocArtifacts = artifacts("compile", Some("javadoc"))
|
||||
val docArtifacts = artifacts("compile", Some("javadoc"), useClassifiersReport = true)
|
||||
|
||||
assert(compileSourceArtifacts.isEmpty)
|
||||
assert(sourceArtifacts.length == 2)
|
||||
assert(compileDocArtifacts.isEmpty)
|
||||
assert(docArtifacts.length == 2)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
lazy val confCheck = TaskKey[Unit]("confCheck")
|
||||
|
|
@ -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)
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
> foo/publishLocal
|
||||
> bar/confCheck
|
||||
Loading…
Reference in New Issue