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
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,7 @@ class GradleBuildTool(index: IndexCommand) extends BuildTool("Gradle", index) {
buildCommand +=
s"-Porg.gradle.java.installations.paths=${toolchains.paths()}"
}
buildCommand ++=
index.finalBuildCommand(
List(
// Disable the checkerframework plugin because it updates the processorpath
// in a way that causes the error "plug-in not found: semanticdb".
// Details: https://github.com/kelloggm/checkerframework-gradle-plugin/blob/76d1926ae22144b082dfcfde1abe625750469398/src/main/groovy/org/checkerframework/gradle/plugin/CheckerFrameworkPlugin.groovy#L374-L376
"-PskipCheckerFramework",
"clean",
"compileTestJava"
)
)
buildCommand ++= index.finalBuildCommand(List("clean", "compileTestJava"))
buildCommand += lsifJavaDependencies

val result = index.process(buildCommand, env = Map("TERM" -> "dumb"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ public static void premain(String agentArgs, Instrumentation inst) {
named("getCompileClasspath"),
DefaultJvmLanguageCompileSpecAdvice.class.getName()))
.installOn(inst);
new AgentBuilder.Default()
.disableClassFormatChanges()
.type(
named("org.gradle.api.internal.tasks.compile.DefaultJavaCompileSpec")
.or(named("tests.GradleDefaultJavaCompileSpec")))
.transform(
new AgentBuilder.Transformer.ForAdvice()
.advice(
named("getAnnotationProcessorPath"),
DefaultJavaCompileSpecAdvice.class.getName()))
.installOn(inst);
new AgentBuilder.Default()
.type(
named("org.gradle.api.internal.tasks.compile.JavaCompilerArgumentsBuilder")
Expand Down Expand Up @@ -92,6 +103,23 @@ public static void getClasspath(
}
}

@SuppressWarnings("all")
public static class DefaultJavaCompileSpecAdvice {
@Advice.OnMethodExit
public static void getAnnotationProcessorPath(
@Advice.Return(readOnly = false, typing = DYNAMIC) List<File> classpath) {
if (classpath == null) return;
String PLUGINPATH = System.getProperty("semanticdb.pluginpath");
if (PLUGINPATH == null) throw new NoSuchElementException("-Dsemanticdb.pluginpath");
File semanticdbJar = new File(PLUGINPATH);
if (!classpath.contains(semanticdbJar)) {
List<File> newClasspath = new ArrayList<>(classpath);
newClasspath.add(semanticdbJar);
classpath = newClasspath;
}
}
}

@SuppressWarnings("all")
public static class JavaCompilerArgumentsBuilderAdvice {

Expand Down