diff options
5 files changed, 40 insertions, 41 deletions
diff --git a/scalajslib/src/mill/scalajslib/ScalaJSModule.scala b/scalajslib/src/mill/scalajslib/ScalaJSModule.scala index 7b6b79f9..70ae1394 100644 --- a/scalajslib/src/mill/scalajslib/ScalaJSModule.scala +++ b/scalajslib/src/mill/scalajslib/ScalaJSModule.scala @@ -128,8 +128,9 @@ trait ScalaJSModule extends scalalib.ScalaModule { outer => else scalaJSBinaryVersion() } - override def artifactId: T[String] = T { s"${artifactName()}_sjs${artifactScalaJSVersion()}_${artifactScalaVersion()}" } - + override def artifactSuffix: T[String] = T { + s"_sjs${artifactScalaJSVersion()}_${artifactScalaVersion()}" + } } trait TestScalaJSModule extends ScalaJSModule with TestModule { diff --git a/scalajslib/test/src/mill/scalajslib/HelloJSWorldTests.scala b/scalajslib/test/src/mill/scalajslib/HelloJSWorldTests.scala index c9ab64e1..cc44b7c8 100644 --- a/scalajslib/test/src/mill/scalajslib/HelloJSWorldTests.scala +++ b/scalajslib/test/src/mill/scalajslib/HelloJSWorldTests.scala @@ -7,7 +7,7 @@ import javax.script.{ScriptContext, ScriptEngineManager} import ammonite.ops._ import mill._ import mill.define.Discover -import mill.scalalib.{DepSyntax, Lib, PublishModule, TestRunner} +import mill.scalalib.{CrossScalaModule, DepSyntax, Lib, PublishModule, TestRunner} import mill.scalalib.publish.{Developer, License, PomSettings, SCM} import mill.util.{TestEvaluator, TestUtil} import utest._ @@ -19,7 +19,7 @@ import scala.collection.JavaConverters._ object HelloJSWorldTests extends TestSuite { val workspacePath = TestUtil.getOutPathStatic() / "hello-js-world" - trait HelloJSWorldModule extends ScalaJSModule with PublishModule { + trait HelloJSWorldModule extends ScalaJSModule with PublishModule with CrossScalaModule{ override def millSourcePath = workspacePath def publishVersion = "0.0.1-SNAPSHOT" override def mainClass = Some("Main") @@ -31,11 +31,29 @@ object HelloJSWorldTests extends TestSuite { scalaJS <- Seq("0.6.22", "1.0.0-M2") } yield (scala, scalaJS) - object build extends Cross[BuildModule](matrix:_*) + object helloJsWorld extends Cross[BuildModule](matrix:_*) + class BuildModule(val crossScalaVersion: String, sjsVersion0: String) extends HelloJSWorldModule { + override def artifactName = "hello-js-world" + def scalaJSVersion = sjsVersion0 + def pomSettings = PomSettings( + organization = "com.lihaoyi", + description = "hello js world ready for real world publishing", + url = "https://github.com/lihaoyi/hello-world-publish", + licenses = Seq( + License("Apache License, Version 2.0", + "http://www.apache.org/licenses/LICENSE-2.0")), + scm = SCM( + "https://github.com/lihaoyi/hello-world-publish", + "scm:git:https://github.com/lihaoyi/hello-world-publish" + ), + developers = + Seq(Developer("lihaoyi", "Li Haoyi", "https://github.com/lihaoyi")) + ) + } object buildUTest extends Cross[BuildModuleUtest](matrix:_*) - class BuildModuleUtest(scalaVersion0: String, sjsVersion0: String) - extends BuildModule(scalaVersion0: String, sjsVersion0: String) { + class BuildModuleUtest(crossScalaVersion: String, sjsVersion0: String) + extends BuildModule(crossScalaVersion, sjsVersion0) { object test extends super.Tests { override def sources = T.sources{ millSourcePath / 'src / 'utest } def testFramework: T[String] = "utest.runner.Framework" @@ -46,8 +64,8 @@ object HelloJSWorldTests extends TestSuite { } object buildScalaTest extends Cross[BuildModuleScalaTest](matrix:_*) - class BuildModuleScalaTest(scalaVersion0: String, sjsVersion0: String) - extends BuildModule(scalaVersion0: String, sjsVersion0: String) { + class BuildModuleScalaTest(crossScalaVersion: String, sjsVersion0: String) + extends BuildModule(crossScalaVersion, sjsVersion0) { object test extends super.Tests { override def sources = T.sources{ millSourcePath / 'src / 'scalatest } def testFramework: T[String] = "org.scalatest.tools.Framework" @@ -56,25 +74,6 @@ object HelloJSWorldTests extends TestSuite { ) } } - - class BuildModule(scalaVersion0: String, sjsVersion0: String) extends HelloJSWorldModule { - def scalaVersion = scalaVersion0 - def scalaJSVersion = sjsVersion0 - def pomSettings = PomSettings( - organization = "com.lihaoyi", - description = "hello js world ready for real world publishing", - url = "https://github.com/lihaoyi/hello-world-publish", - licenses = Seq( - License("Apache License, Version 2.0", - "http://www.apache.org/licenses/LICENSE-2.0")), - scm = SCM( - "https://github.com/lihaoyi/hello-world-publish", - "scm:git:https://github.com/lihaoyi/hello-world-publish" - ), - developers = - Seq(Developer("lihaoyi", "Li Haoyi", "https://github.com/lihaoyi")) - ) - } } val millSourcePath = pwd / 'scalajslib / 'test / 'resources / "hello-js-world" @@ -105,7 +104,7 @@ object HelloJSWorldTests extends TestSuite { def testCompileFromScratch(scalaVersion: String, scalaJSVersion: String): Unit = { val Right((result, evalCount)) = - helloWorldEvaluator(HelloJSWorld.build(scalaVersion, scalaJSVersion).compile) + helloWorldEvaluator(HelloJSWorld.helloJsWorld(scalaVersion, scalaJSVersion).compile) val outPath = result.classes.path val outputFiles = ls.rec(outPath) @@ -117,7 +116,7 @@ object HelloJSWorldTests extends TestSuite { // don't recompile if nothing changed val Right((_, unchangedEvalCount)) = - helloWorldEvaluator(HelloJSWorld.build(scalaVersion, scalaJSVersion).compile) + helloWorldEvaluator(HelloJSWorld.helloJsWorld(scalaVersion, scalaJSVersion).compile) assert(unchangedEvalCount == 0) } @@ -131,8 +130,8 @@ object HelloJSWorldTests extends TestSuite { scalaJSVersion: String, mode: OptimizeMode): Unit = { val task = mode match { - case FullOpt => HelloJSWorld.build(scalaVersion, scalaJSVersion).fullOpt - case FastOpt => HelloJSWorld.build(scalaVersion, scalaJSVersion).fastOpt + case FullOpt => HelloJSWorld.helloJsWorld(scalaVersion, scalaJSVersion).fullOpt + case FastOpt => HelloJSWorld.helloJsWorld(scalaVersion, scalaJSVersion).fastOpt } val Right((result, evalCount)) = helloWorldEvaluator(task) val output = runJS(result.path) @@ -153,7 +152,7 @@ object HelloJSWorldTests extends TestSuite { } 'jar - { 'containsSJSIRs - { - val Right((result, evalCount)) = helloWorldEvaluator(HelloJSWorld.build("2.12.4", "0.6.22").jar) + val Right((result, evalCount)) = helloWorldEvaluator(HelloJSWorld.helloJsWorld("2.12.4", "0.6.22").jar) val jar = result.path val entries = new JarFile(jar.toIO).entries().asScala.map(_.getName) assert(entries.contains("Main$.sjsir")) @@ -163,7 +162,7 @@ object HelloJSWorldTests extends TestSuite { def testArtifactId(scalaVersion: String, scalaJSVersion: String, artifactId: String): Unit = { - val Right((result, evalCount)) = helloWorldEvaluator(HelloJSWorld.build(scalaVersion, scalaJSVersion).artifact) + val Right((result, evalCount)) = helloWorldEvaluator(HelloJSWorld.helloJsWorld(scalaVersion, scalaJSVersion).artifact) assert(result.id == artifactId) } 'artifactId_0621 - testArtifactId("2.12.4", "0.6.22", "hello-js-world_sjs0.6_2.12") diff --git a/scalalib/src/mill/scalalib/MiscModule.scala b/scalalib/src/mill/scalalib/MiscModule.scala index 8576e788..7ff5d97f 100644 --- a/scalalib/src/mill/scalalib/MiscModule.scala +++ b/scalalib/src/mill/scalalib/MiscModule.scala @@ -12,7 +12,7 @@ object CrossModuleBase{ yield PathRef(f(segments.mkString("."))) } } -trait CrossModuleBase extends mill.Module{ +trait CrossModuleBase extends ScalaModule { def crossScalaVersion: String def scalaVersion = T{ crossScalaVersion } @@ -37,7 +37,7 @@ trait CrossModuleBase extends mill.Module{ } trait CrossScalaModule extends ScalaModule with CrossModuleBase{ outer => - override def sources = T.sources{ + override def sources = T.sources{ super.sources() ++ CrossModuleBase.scalaVersionPaths(crossScalaVersion, s => millSourcePath / s"src-$s" ) } diff --git a/scalalib/src/mill/scalalib/PublishModule.scala b/scalalib/src/mill/scalalib/PublishModule.scala index 460defcb..785f77ac 100644 --- a/scalalib/src/mill/scalalib/PublishModule.scala +++ b/scalalib/src/mill/scalalib/PublishModule.scala @@ -12,11 +12,12 @@ trait PublishModule extends ScalaModule { outer => def pomSettings: T[PomSettings] def publishVersion: T[String] + def artifactId: T[String] = T { s"${artifactName()}${artifactSuffix()}" } def pom = T { val dependencies = ivyDeps().map(Artifact.fromDep(_, scalaVersion(), Lib.scalaBinaryVersion(scalaVersion()))) - val pom = Pom(artifact(), dependencies, artifactName(), pomSettings()) + val pom = Pom(artifact(), dependencies, artifactId(), pomSettings()) val pomPath = T.ctx().dest / s"${artifactId()}-${publishVersion()}.pom" write.over(pomPath, pom) diff --git a/scalalib/src/mill/scalalib/ScalaModule.scala b/scalalib/src/mill/scalalib/ScalaModule.scala index fa8e8ca6..a5637220 100644 --- a/scalalib/src/mill/scalalib/ScalaModule.scala +++ b/scalalib/src/mill/scalalib/ScalaModule.scala @@ -249,15 +249,13 @@ trait ScalaModule extends mill.Module with TaskModule { outer => // publish artifact with name "mill_2.12.4" instead of "mill_2.12" def crossFullScalaVersion: T[Boolean] = false - def artifactName: T[String] = millModuleSegments.parts.mkString("-") - def artifactScalaVersion: T[String] = T { if (crossFullScalaVersion()) scalaVersion() else Lib.scalaBinaryVersion(scalaVersion()) } + def artifactName: T[String] = millModuleSegments.parts.mkString("-") - def artifactId: T[String] = T { s"${artifactName()}_${artifactScalaVersion()}" } - + def artifactSuffix: T[String] = T { s"_${artifactScalaVersion()}" } } |