-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10749 from SethTisue/skip-jdeps-on-jdk-22
skip `testJDeps` on JDK 22+
- Loading branch information
Showing
1 changed file
with
17 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,29 @@ | ||
package scala.build | ||
|
||
import sbt._, Keys._ | ||
import scala.util.Properties.isJavaAtLeast | ||
|
||
object TestJDeps { | ||
val testJDepsImpl: Def.Initialize[Task[Unit]] = Def.task { | ||
val libraryJar = (LocalProject("library") / Compile / packageBin).value | ||
val reflectJar = (LocalProject("reflect") / Compile / packageBin).value | ||
val log = streams.value.log | ||
// in JDK 22, the already-deprecated `-P` option to jdeps was removed, | ||
// so we can't do the test. it's fine -- it will be a long, long time | ||
// (probably never) before Scala 2's minimum JVM version is 22+ | ||
if (isJavaAtLeast("22")) | ||
log.info("can't test jdeps on JDK 22+") | ||
else { | ||
// jdeps -s -P build/pack/lib/scala-{library,reflect}.jar | grep -v build/pack | perl -pe 's/.*\((.*)\)$/$1/' | sort -u | ||
val jdepsOut = scala.sys.process.Process("jdeps", Seq("-s", "-P", libraryJar.getPath, reflectJar.getPath)).lineStream | ||
|
||
// jdeps -s -P build/pack/lib/scala-{library,reflect}.jar | grep -v build/pack | perl -pe 's/.*\((.*)\)$/$1/' | sort -u | ||
val jdepsOut = scala.sys.process.Process("jdeps", Seq("-s", "-P", libraryJar.getPath, reflectJar.getPath)).lineStream | ||
val profilePart = ".*\\((.*)\\)$".r | ||
val profiles = jdepsOut.collect { | ||
case profilePart(profile) => profile | ||
}.toSet | ||
|
||
val profilePart = ".*\\((.*)\\)$".r | ||
val profiles = jdepsOut.collect { | ||
case profilePart(profile) => profile | ||
}.toSet | ||
|
||
if (profiles != Set("compact1")) | ||
throw new RuntimeException(jdepsOut.mkString("Detected dependency outside of compact1:\n", "\n", "")) | ||
if (profiles != Set("compact1")) | ||
throw new RuntimeException(jdepsOut.mkString("Detected dependency outside of compact1:\n", "\n", "")) | ||
} | ||
} | ||
} |