diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 6b284288412..0df3794e6c8 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -8,8 +8,8 @@ name: CI # # To maximize bug-catching changes while keeping CI times reasonable, we run: # - All tests on Linux/Java17 -# - Fewer tests on Linux/Java8 and Windows/Java17 -# - Fewest tests on Windows/Java8 +# - Fewer tests on Linux/Java11 and Windows/Java17 +# - Fewest tests on Windows/Java11 on: push: @@ -35,7 +35,7 @@ jobs: matrix: include: # bootstrap tests - - java-version: 8 + - java-version: 11 buildcmd: ci/test-mill-release.sh - java-version: 17 buildcmd: ci/test-mill-release.sh @@ -48,7 +48,7 @@ jobs: - java-version: 20 buildcmd: ci/test-mill-bootstrap.sh # Just some reporting to enable reasoning about library upgrades - - java-version: 8 + - java-version: 11 buildcmd: | ./mill -i -k __.ivyDepsTree ./mill -i -k __.ivyDepsTree --withRuntime @@ -63,7 +63,7 @@ jobs: strategy: fail-fast: false matrix: - java-version: [8, 17] + java-version: [11, 17] millargs: # unit and module tests - '"{main,scalalib,testrunner,bsp}.__.test"' @@ -94,13 +94,13 @@ jobs: format-check: uses: ./.github/workflows/run-mill-action.yml with: - java-version: '8' + java-version: '11' millargs: mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll __.sources bincompat-check: uses: ./.github/workflows/run-mill-action.yml with: - java-version: '8' + java-version: '11' millargs: __.mimaReportBinaryIssues continue-on-error: true @@ -108,7 +108,7 @@ jobs: strategy: fail-fast: false matrix: - java-version: [8, 17] + java-version: [11, 17] millargs: # Run a stripped down build matrix on Windows, to avoid taking too long - '"{__.publishLocal,dev.assembly,__.compile}"' @@ -165,7 +165,7 @@ jobs: - uses: actions/setup-java@v3 with: - java-version: 8 + java-version: 11 distribution: temurin - run: ci/release-maven.sh @@ -188,7 +188,7 @@ jobs: - uses: actions/setup-java@v3 with: - java-version: 8 + java-version: 11 distribution: temurin - run: ./mill -i uploadToGithub $REPO_ACCESS_TOKEN diff --git a/.github/workflows/publish-bridges.yml b/.github/workflows/publish-bridges.yml index 6267a21aee1..64c1b68a7ae 100644 --- a/.github/workflows/publish-bridges.yml +++ b/.github/workflows/publish-bridges.yml @@ -28,7 +28,7 @@ jobs: - uses: actions/setup-java@v3 with: - java-version: 8 + java-version: 11 distribution: temurin - run: ci/release-bridge-maven.sh diff --git a/.github/workflows/publishDocs.yml b/.github/workflows/publishDocs.yml index c59a77be0bf..fc3aaa1d2e0 100644 --- a/.github/workflows/publishDocs.yml +++ b/.github/workflows/publishDocs.yml @@ -19,7 +19,7 @@ jobs: - uses: actions/setup-java@v3 with: - java-version: 8 + java-version: 11 distribution: temurin - run: ci/publish-docs.sh diff --git a/scalalib/src/mill/scalalib/Assembly.scala b/scalalib/src/mill/scalalib/Assembly.scala index 78baebdfa99..d3379623f61 100644 --- a/scalalib/src/mill/scalalib/Assembly.scala +++ b/scalalib/src/mill/scalalib/Assembly.scala @@ -124,7 +124,8 @@ object Assembly { def loadShadedClasspath( inputPaths: Agg[os.Path], - assemblyRules: Seq[Assembly.Rule] + assemblyRules: Seq[Assembly.Rule], + runtimeVersion: Option[Runtime.Version] ): (Generator[(String, UnopenedInputStream)], ResourceCloser) = { val shadeRules = assemblyRules.collect { case Rule.Relocate(from, to) => ShadePattern.Rename(List(from -> to)).inAll @@ -148,13 +149,20 @@ object Assembly { } val pathsWithResources = inputPaths.filter(os.exists).map { path => - if (os.isFile(path)) path -> Some(new JarFile(path.toIO)) + if (os.isFile(path)) path -> { + val file = path.toIO + val jarFile = runtimeVersion match { + case Some(version) => new JarFile(file, true, java.util.zip.ZipFile.OPEN_READ, version) + case None => new JarFile(file) + } + Some(jarFile) + } else path -> None } val generators = Generator.from(pathsWithResources).flatMap { case (path, Some(jarFile)) => - Generator.from(jarFile.entries().asScala.filterNot(_.isDirectory)) + Generator.from(jarFile.versionedStream().iterator().asScala.filterNot(_.isDirectory)) .flatMap(entry => shader(entry.getName, () => jarFile.getInputStream(entry))) case (path, None) => os.walk @@ -193,7 +201,8 @@ object Assembly { manifest: mill.api.JarManifest = mill.api.JarManifest.MillDefault, prependShellScript: String = "", base: Option[os.Path] = None, - assemblyRules: Seq[Assembly.Rule] = Assembly.defaultRules + assemblyRules: Seq[Assembly.Rule] = Assembly.defaultRules, + runtimeVersion: Option[Runtime.Version] )(implicit ctx: Ctx.Dest with Ctx.Log): PathRef = { val tmp = ctx.dest / "out-tmp.jar" @@ -213,7 +222,8 @@ object Assembly { manifest.build.write(manifestOut) manifestOut.close() - val (mappings, resourceCleaner) = Assembly.loadShadedClasspath(inputPaths, assemblyRules) + val (mappings, resourceCleaner) = + Assembly.loadShadedClasspath(inputPaths, assemblyRules, runtimeVersion) try { Assembly.groupAssemblyEntries(mappings, assemblyRules).foreach { case (mapping, entry) => diff --git a/scalalib/src/mill/scalalib/JavaModule.scala b/scalalib/src/mill/scalalib/JavaModule.scala index 7f4ac04a40f..4f6debc258e 100644 --- a/scalalib/src/mill/scalalib/JavaModule.scala +++ b/scalalib/src/mill/scalalib/JavaModule.scala @@ -122,6 +122,17 @@ trait JavaModule */ def javacOptions: T[Seq[String]] = T { Seq.empty[String] } + private def extractRuntimeVersion(javacOptions: Seq[String]): Option[Runtime.Version] = { + val releaseOptIndex = javacOptions.indexOf("--release") + val releaseOptValueIndex = releaseOptIndex + 1 + if (releaseOptIndex >= 0 && javacOptions.length >= releaseOptValueIndex) { + val runtimeVersionString = javacOptions(releaseOptValueIndex) + val runtimeVersion = Runtime.Version.parse(runtimeVersionString) + println(s"Extracted javac --release version $runtimeVersion") + Some(runtimeVersion) + } else None + } + /** The direct dependencies of this module */ def moduleDeps: Seq[JavaModule] = Seq.empty @@ -447,7 +458,8 @@ trait JavaModule Assembly.createAssembly( upstreamAssemblyClasspath().map(_.path), manifest(), - assemblyRules = assemblyRules + assemblyRules = assemblyRules, + runtimeVersion = extractRuntimeVersion(javacOptions()) ) } @@ -461,7 +473,8 @@ trait JavaModule manifest(), prependShellScript(), Some(upstreamAssembly().path), - assemblyRules + assemblyRules, + runtimeVersion = extractRuntimeVersion(javacOptions()) ) }