@@ -49,6 +49,17 @@ public static void premain(String agentArgs, Instrumentation inst) {
4949 named ("getCompileClasspath" ),
5050 DefaultJvmLanguageCompileSpecAdvice .class .getName ()))
5151 .installOn (inst );
52+ new AgentBuilder .Default ()
53+ .disableClassFormatChanges ()
54+ .type (
55+ named ("org.gradle.api.internal.tasks.compile.DefaultJavaCompileSpec" )
56+ .or (named ("tests.GradleDefaultJavaCompileSpec" )))
57+ .transform (
58+ new AgentBuilder .Transformer .ForAdvice ()
59+ .advice (
60+ named ("getAnnotationProcessorPath" ),
61+ DefaultJavaCompileSpecAdvice .class .getName ()))
62+ .installOn (inst );
5263 new AgentBuilder .Default ()
5364 .type (
5465 named ("org.gradle.api.internal.tasks.compile.JavaCompilerArgumentsBuilder" )
@@ -92,6 +103,23 @@ public static void getClasspath(
92103 }
93104 }
94105
106+ @ SuppressWarnings ("all" )
107+ public static class DefaultJavaCompileSpecAdvice {
108+ @ Advice .OnMethodExit
109+ public static void getAnnotationProcessorPath (
110+ @ Advice .Return (readOnly = false , typing = DYNAMIC ) List <File > classpath ) {
111+ if (classpath == null ) return ;
112+ String PLUGINPATH = System .getProperty ("semanticdb.pluginpath" );
113+ if (PLUGINPATH == null ) throw new NoSuchElementException ("-Dsemanticdb.pluginpath" );
114+ File semanticdbJar = new File (PLUGINPATH );
115+ if (!classpath .contains (semanticdbJar )) {
116+ List <File > newClasspath = new ArrayList <>(classpath );
117+ newClasspath .add (semanticdbJar );
118+ classpath = newClasspath ;
119+ }
120+ }
121+ }
122+
95123 @ SuppressWarnings ("all" )
96124 public static class JavaCompilerArgumentsBuilderAdvice {
97125
0 commit comments