Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Mill API to 0.11 and some tweaks #118

Merged
merged 9 commits into from
Jun 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ jobs:
targets:
- "__.publishLocal testRepo"
- "core.__.test"
- "itest[0.11.0-M7].test"
- "itest[0.10.11].test"
- "itest[0.11.1].test"
- "itest[0.11.0].test"
- "itest[0.10.12].test"
- "itest[0.10.0].test"
- "itest[0.9.12].test"
- "itest[0.9.3].test"
Expand Down Expand Up @@ -60,7 +61,7 @@ jobs:
- name: Upload scoverage reports to codecov.io
uses: codecov/codecov-action@v3
with:
files: ./out/core/0.11.0-M6/scoverage/xmlReport.dest/scoverage.xml,./out/core/0.10/scoverage/xmlReport.dest/scoverage.xml,./out/core/0.9/scoverage/xmlReport.dest/scoverage.xml,./out/core/0.7/scoverage/xmlReport.dest/scoverage.xml,./out/core/0.6/scoverage/xmlReport.dest/scoverage.xml
files: ./out/core/0.11/scoverage/xmlReport.dest/scoverage.xml,./out/core/0.10/scoverage/xmlReport.dest/scoverage.xml,./out/core/0.9/scoverage/xmlReport.dest/scoverage.xml,./out/core/0.7/scoverage/xmlReport.dest/scoverage.xml,./out/core/0.6/scoverage/xmlReport.dest/scoverage.xml
continue-on-error: true

publish:
Expand Down
2 changes: 1 addition & 1 deletion .mill-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.11.0-27-d74d22
0.11.1
34 changes: 18 additions & 16 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ trait Deps {
// The mill API version used in the project/sources/dependencies, also default for integration tests
def millVersion: String
def millPlatform: String
def scalaVersion: String
def scalaVersion: String = "2.13.11"
def millTestVersions: Seq[String]
val scoverageVersion = "2.0.10"

Expand All @@ -44,30 +44,26 @@ trait Deps {
}

object Deps_0_11 extends Deps {
override val millVersion = "0.11.0-M7" // needs to be an exact milestone version
override def millPlatform = millVersion
override val scalaVersion = "2.13.11"
override val millVersion = "0.11.0" // scala-steward:off
override def millPlatform = "0.11"
// keep in sync with .github/workflows/build.yml
override val millTestVersions = Seq(millVersion)
override val millTestVersions = Seq("0.11.1", millVersion)
}
object Deps_0_10 extends Deps {
override val millVersion = "0.10.0" // scala-steward:off
override def millPlatform = "0.10"
override val scalaVersion = "2.13.11"
// keep in sync with .github/workflows/build.yml
override val millTestVersions = Seq("0.10.11", millVersion)
override val millTestVersions = Seq("0.10.12", millVersion)
}
object Deps_0_9 extends Deps {
override val millVersion = "0.9.3" // scala-steward:off
override def millPlatform = "0.9"
override val scalaVersion = "2.13.11"
// keep in sync with .github/workflows/build.yml
override val millTestVersions = Seq("0.9.12", millVersion)
}
object Deps_0_7 extends Deps {
override val millVersion = "0.7.0" // scala-steward:off
override def millPlatform = "0.7"
override val scalaVersion = "2.13.11"
// keep in sync with .github/workflows/build.yml
override val millTestVersions = Seq("0.8.0", "0.7.4", millVersion)
}
Expand Down Expand Up @@ -101,6 +97,14 @@ trait MillOsgiModule extends ScalaModule with PublishModule with Cross.Module[St
developers = Seq(Developer("lefou", "Tobias Roeser", "https.//github.com/lefou"))
)
}
override def sources = T.sources {
super.sources() ++
(
ZincWorkerUtil.matchingVersions(deps.millPlatform) ++
ZincWorkerUtil.versionRanges(deps.millPlatform, millPlatforms.map(_._1))
)
.map(p => PathRef(millSourcePath / s"src-${p}"))
}
}

object core extends Cross[Core](millPlatforms.map(_._1))
Expand Down Expand Up @@ -154,12 +158,7 @@ trait TestSupport extends MillOsgiModule {

val testVersions: Seq[(String, Deps)] = millPlatforms.flatMap { case (_, d) => d.millTestVersions.map(_ -> d) }

object itest extends Cross[ItestCross](testVersions.map(_._1)) with TaskModule {
override def defaultCommandName(): String = "test"
def testCached: T[Seq[TestCase]] = itest(testVersions.map(_._1).head).testCached
def test(args: String*): Command[Seq[TestCase]] = itest(testVersions.map(_._1).head).test(args: _*)
}

object itest extends Cross[ItestCross](testVersions.map(_._1))
trait ItestCross extends MillIntegrationTestModule with Cross.Module[String] {
def millVersion = crossValue
def deps = testVersions.toMap.apply(millVersion)
Expand Down Expand Up @@ -187,7 +186,10 @@ trait ItestCross extends MillIntegrationTestModule with Cross.Module[String] {
val scov = deps.scoverageRuntime.dep
os.write(
T.dest / "shared.sc",
s"""import $$ivy.`${scov.module.organization.value}::${scov.module.name.value}:${scov.version}`
s"""// Load the plugin under test
|import $$file.plugins
|// Load scoverage runtime to get coverage results
|import $$ivy.`${scov.module.organization.value}::${scov.module.name.value}:${scov.version}`
|""".stripMargin
)
PathRef(T.dest)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package de.tobiasroeser.mill.osgi

import mill.{Agg,T}
import mill.api.PathRef
import mill.scalalib.JavaModule

trait OsgiBundleModulePlatform extends JavaModule {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package de.tobiasroeser.mill.osgi

import mill.{Agg,T}
import mill.api.PathRef
import mill.scalalib.JavaModule

trait OsgiBundleModulePlatform extends JavaModule {

override def compileClasspath: T[Agg[PathRef]] = T {
// restore pre-Mill-0.11.0-M8 behavior
// Mill 0.11.0-M8 uses transitiveCompileClasspath instead of transitiveLocalClass
// which does not include the resources
transitiveLocalClasspath() ++
compileResources() ++
unmanagedClasspath() ++
resolvedIvyDeps()
}

}
2 changes: 1 addition & 1 deletion core/src/de/tobiasroeser/mill/osgi/OsgiBundleModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import mill.modules.Jvm
import mill.scalalib.{JavaModule, PublishModule}
import os.Path

trait OsgiBundleModule extends JavaModule {
trait OsgiBundleModule extends OsgiBundleModulePlatform {

import OsgiBundleModule._

Expand Down
3 changes: 1 addition & 2 deletions itest/src-0.10-/WrapContents/build.sc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import $exec.plugins
import $exec.shared
import $file.shared

import mill._
import mill.scalalib._
Expand Down
3 changes: 1 addition & 2 deletions itest/src-0.11+/WrapContents/build.sc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import $exec.plugins
import $exec.shared
import $file.shared

import mill._
import mill.scalalib._
Expand Down
3 changes: 1 addition & 2 deletions itest/src/Embedded-Jars/build.sc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import $exec.plugins
import $exec.shared
import $file.shared
import mill._
import mill.scalalib._
import de.tobiasroeser.mill.osgi._
Expand Down
3 changes: 1 addition & 2 deletions itest/src/Exploded-Jars/build.sc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import $exec.plugins
import $exec.shared
import $file.shared
import mill._
import mill.scalalib._
import de.tobiasroeser.mill.osgi._
Expand Down
3 changes: 1 addition & 2 deletions itest/src/HelloWorld/build.sc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import $exec.plugins
import $exec.shared
import $file.shared
import mill._
import mill.scalalib._
import mill.scalalib.publish._
Expand Down
3 changes: 1 addition & 2 deletions itest/src/Include-Sources/build.sc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import $exec.plugins
import $exec.shared
import $file.shared
import mill._
import mill.scalalib._
import de.tobiasroeser.mill.osgi._
Expand Down
46 changes: 23 additions & 23 deletions itest/src/Interproject-dependson-includePackage-versions/build.sc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import $exec.plugins
import $exec.shared
import $file.shared
import java.io.IOException
import java.util.jar.Manifest
import java.util.zip.ZipFile
Expand All @@ -12,32 +11,33 @@ import de.tobiasroeser.mill.osgi.testsupport.TestSupport._

val projVersion = "1.0.0"

def verify() = T.command {

for {
(jar1, jar2) <- Seq(
(proj1.jar(), proj2.jar()),
(manifest.proj1.jar(), manifest.proj2.jar())
)
} {
withManifest(jar1.path) { manifest =>
checkExact(manifest, "Bundle-SymbolicName", "proj1_2.12")
checkExact(manifest, "Bundle-Version", projVersion)
checkSlices(manifest, "Export-Package", Seq("proj1;", s"""version="${projVersion}""""))
}
withManifest(jar2.path) { manifest =>
checkExact(manifest, "Bundle-SymbolicName", "proj2_2.12")
checkExact(manifest, "Bundle-Version", projVersion)
checkSlices(manifest, "Export-Package", Seq("proj2;", s"""version="${projVersion}""""))
def verifyTask(jar1: PathRef, jar2: PathRef) = {
println(s"jar1: ${jar1}")
withManifest(jar1.path) { manifest =>
checkExact(manifest, "Bundle-SymbolicName", "proj1_2.12")
checkExact(manifest, "Bundle-Version", projVersion)
checkSlices(manifest, "Export-Package", Seq("proj1;", s"""version="${projVersion}""""))
}
println(s"jar2: ${jar2}")
withManifest(jar2.path) { manifest =>
checkExact(manifest, "Bundle-SymbolicName", "proj2_2.12")
checkExact(manifest, "Bundle-Version", projVersion)
checkSlices(manifest, "Export-Package", Seq("proj2;", s"""version="${projVersion}""""))

val rangeFrom = projVersion.split("[.]").take(2).mkString(".")
val rangeTo = projVersion.split("[.]").head.toInt + 1
checkSlices(manifest, "Import-Package", Seq(s"""proj1;version="[${rangeFrom},${rangeTo})""""))
}
val rangeFrom = projVersion.split("[.]").take(2).mkString(".")
val rangeTo = projVersion.split("[.]").head.toInt + 1
checkSlices(manifest, "Import-Package", Seq(s"""proj1;version="[${rangeFrom},${rangeTo})""""))
}
}

def verify() = T.command {
verifyTask(proj1.jar(), proj2.jar())
verifyTask(manifest.proj1.jar(), manifest.proj2.jar())
()
}

trait TemplateBnd extends ScalaModule with OsgiBundleModule {
override def osgiBuildMode: OsgiBundleModule.BuildMode = OsgiBundleModule.BuildMode.ReplaceJarTarget
override def scalaVersion: T[String] = "2.12.7"
override def bundleVersion = projVersion
}
Expand Down