Skip to content
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
22 changes: 10 additions & 12 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -357,18 +357,16 @@ lazy val minimizedSettings = List[Def.Setting[_]](
(run / fork) := true,
(Compile / unmanagedSourceDirectories) += minimizedSourceDirectory,
libraryDependencies ++= List("org.projectlombok" % "lombok" % "1.18.22"),
javacOptions ++=
List[String](
s"-Arandomtimestamp=${System.nanoTime()}",
List(
s"-Xplugin:semanticdb",
s"-build-tool:sbt",
s"-text:on",
s"-verbose",
s"-sourceroot:${(ThisBuild / baseDirectory).value}",
s"-targetroot:${(Compile / semanticdbTargetRoot).value}"
).mkString(" ")
)
javacOptions +=
List(
s"-Xplugin:semanticdb",
s"-build-tool:sbt",
s"-text:on",
s"-verbose",
s"-sourceroot:${(ThisBuild / baseDirectory).value}",
s"-targetroot:${(Compile / semanticdbTargetRoot).value}",
s"-randomtimestamp=${System.nanoTime()}"
).mkString(" ")
)

lazy val minimized = project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ class SemanticdbGradlePlugin extends Plugin[Project] {
// TODO: before this plugin is published to Maven Central,
// we will need to revert this change - as it can have detrimental
// effect on people's builds
s"-Arandomtimestamp=${System.currentTimeMillis()}",
s"-Xplugin:semanticdb -targetroot:$targetRoot -sourceroot:$sourceRoot"
s"-Xplugin:semanticdb -targetroot:$targetRoot -sourceroot:$sourceRoot -randomtimestamp=${System.nanoTime()}"
).asJava
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public static SemanticdbJavacOptions parse(String[] args, JavacTask task) {
result.verboseEnabled = true;
} else if (arg.equals("-verbose:off")) {
result.verboseEnabled = false;
} else if (arg.startsWith("-randomtimestamp")) {
} else {
result.errors.add(String.format("unknown flag '%s'\n", arg));
}
Expand Down Expand Up @@ -126,8 +127,10 @@ private static boolean isSourcerootDefined(SemanticdbJavacOptions options) {
// warning - use of internal API
// requires --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
private static TargetPaths getJavacClassesDir(SemanticdbJavacOptions result, JavacTask task) {
// both Context and BasicJavacTask are internal JDK classes so not exported under >= JDK 17
// com.sun.tools.javac.util.Context ctx = ((com.sun.tools.javac.api.BasicJavacTask)
// both Context and BasicJavacTask are internal JDK classes so not exported
// under >= JDK 17
// com.sun.tools.javac.util.Context ctx =
// ((com.sun.tools.javac.api.BasicJavacTask)
// task).getContext();
// I'm not aware of a better way to get the class output directory from javac
Path classOutputDir = null;
Expand Down
32 changes: 32 additions & 0 deletions tests/buildTools/src/test/scala/tests/GradleBuildToolSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,38 @@ abstract class GradleBuildToolSuite(allGradle: List[String])
gradleVersions = List(Gradle8, Gradle7, Gradle67)
)

checkGradleBuild(
"build-with-Werror",
"""|/build.gradle
|plugins {
| id 'java-library'
|}
|repositories {
| // Use Maven Central for resolving dependencies.
| mavenCentral()
|}
|dependencies {
| compileOnly 'org.immutables:value:2.9.2'
| annotationProcessor 'org.immutables:value:2.9.2'
|}
|compileJava {
| options.compilerArgs << "-Werror"
|}
|/src/main/java/main/bla/ExampleClass.java
|package test;
|import org.immutables.value.Value;
|import java.util.Optional;
|@Value.Immutable
|public abstract class ExampleClass {
| public abstract Optional<String> getWorkflowIdReusePolicy();
|}
""".stripMargin,
// See comment about immutable annotation processor above,
// it explains why we expecte 2 semanticdb files
expectedSemanticdbFiles = 2,
gradleVersions = List(Gradle8, Gradle7, Gradle67)
)

checkGradleBuild(
"publishing",
"""|/build.gradle
Expand Down