diff options
-rwxr-xr-x | build.sc | 10 | ||||
-rwxr-xr-x | ci/test4.sh | 2 | ||||
-rw-r--r-- | scalalib/src/mill/scalalib/PublishModule.scala | 23 |
3 files changed, 27 insertions, 8 deletions
@@ -206,17 +206,21 @@ val isMasterCommit = { (sys.env.get("TRAVIS_BRANCH") == Some("master") || sys.env("TRAVIS_TAG") != "") } +def gitHead = T.input{ + sys.env.get("TRAVIS_COMMIT").getOrElse( + %%('git, "rev-parse", "head")(pwd).out.string.trim() + ) +} def publishVersion = T.input{ val tag = - try Option(%%('git, 'describe, "--exact-match", "--tags", 'HEAD)(pwd).out.string) + try Option(%%('git, 'describe, "--exact-match", "--tags", gitHead())(pwd).out.string) catch{case e => None} tag match{ case Some(t) => (t, t) case None => val timestamp = java.time.Instant.now().toString.replaceAll(":|\\.", "-") - val gitHash = %%('git, "rev-parse", "head")(pwd).out.string.trim() - ("unstable", timestamp + "-" + gitHash) + ("unstable", timestamp + "-" + gitHead()) } } diff --git a/ci/test4.sh b/ci/test4.sh index fafe603b..2a8b1497 100755 --- a/ci/test4.sh +++ b/ci/test4.sh @@ -12,7 +12,7 @@ git clean -xdf sbt bin/test:assembly # Build Mill using SBT -~/mill-release --all \ +target/bin/mill --all \ moduledefs.publishLocal \ core.publishLocal \ scalalib.publishLocal \ diff --git a/scalalib/src/mill/scalalib/PublishModule.scala b/scalalib/src/mill/scalalib/PublishModule.scala index 785f77ac..19fafaa3 100644 --- a/scalalib/src/mill/scalalib/PublishModule.scala +++ b/scalalib/src/mill/scalalib/PublishModule.scala @@ -2,6 +2,7 @@ package mill package scalalib import ammonite.ops._ +import mill.define.Task import mill.eval.{PathRef, Result} import mill.util.Loose.Agg /** @@ -10,14 +11,28 @@ import mill.util.Loose.Agg trait PublishModule extends ScalaModule { outer => import mill.scalalib.publish._ + override def moduleDeps = Seq.empty[PublishModule] + def pomSettings: T[PomSettings] def publishVersion: T[String] def artifactId: T[String] = T { s"${artifactName()}${artifactSuffix()}" } - + def publishSelfDependency = T{ + Artifact(pomSettings().organization, artifactId(), publishVersion()), + } + def publishUpstreamDependencies = T{ Task.sequence(moduleDeps.map(_.publishSelfDependency)) } def pom = T { - val dependencies = - ivyDeps().map(Artifact.fromDep(_, scalaVersion(), Lib.scalaBinaryVersion(scalaVersion()))) - val pom = Pom(artifact(), dependencies, artifactId(), pomSettings()) + val ivyPomDeps = ivyDeps().map( + Artifact.fromDep(_, scalaVersion(), Lib.scalaBinaryVersion(scalaVersion())) + ) + + val upstreamPomDeps = publishUpstreamDependencies().map(Dependency(_, Scope.Compile)) + + val pom = Pom( + artifact(), + ivyPomDeps ++ upstreamPomDeps, + artifactId(), + pomSettings() + ) val pomPath = T.ctx().dest / s"${artifactId()}-${publishVersion()}.pom" write.over(pomPath, pom) |