@@ -94,6 +94,8 @@ public interface Parameter extends TransformParameters {
9494 MapProperty <String , Set <String >> getCompileClasspathDependencies ();
9595 @ Input
9696 MapProperty <String , Set <String >> getRuntimeClasspathDependencies ();
97+ @ Input
98+ MapProperty <String , Set <String >> getAnnotationProcessorClasspathDependencies ();
9799 }
98100
99101 @ InputArtifact
@@ -320,8 +322,9 @@ private byte[] addModuleInfo(ModuleInfo moduleInfo, Map<String, List<String>> pr
320322 if (moduleInfo .requireAllDefinedDependencies ) {
321323 Set <String > compileDependencies = getParameters ().getCompileClasspathDependencies ().get ().get (moduleInfo .getIdentifier ());
322324 Set <String > runtimeDependencies = getParameters ().getRuntimeClasspathDependencies ().get ().get (moduleInfo .getIdentifier ());
325+ Set <String > annotationProcessorDependencies = getParameters ().getAnnotationProcessorClasspathDependencies ().get ().get (moduleInfo .getIdentifier ());
323326
324- if (compileDependencies == null && runtimeDependencies == null ) {
327+ if (compileDependencies == null && runtimeDependencies == null && annotationProcessorDependencies == null ) {
325328 throw new RuntimeException ("[requires directives from metadata] " +
326329 "Cannot find dependencies for '" + moduleInfo .getModuleName () + "'. " +
327330 "Are '" + moduleInfo .getIdentifier () + "' the correct component coordinates?" );
@@ -333,17 +336,22 @@ private byte[] addModuleInfo(ModuleInfo moduleInfo, Map<String, List<String>> pr
333336 if (runtimeDependencies == null ) {
334337 runtimeDependencies = Collections .emptySet ();
335338 }
339+ if (annotationProcessorDependencies == null ) {
340+ annotationProcessorDependencies = Collections .emptySet ();
341+ }
336342 Set <String > allDependencies = new TreeSet <>();
337343 allDependencies .addAll (compileDependencies );
338344 allDependencies .addAll (runtimeDependencies );
345+ allDependencies .addAll (annotationProcessorDependencies );
339346 for (String ga : allDependencies ) {
340347 String moduleName = gaToModuleName (ga );
341- if (compileDependencies .contains (ga ) && runtimeDependencies .contains (ga )) {
342- moduleVisitor .visitRequire (moduleName , Opcodes .ACC_TRANSITIVE , null );
343- } else if (runtimeDependencies .contains (ga )) {
344- moduleVisitor .visitRequire (moduleName , 0 , null );
345- } else if (compileDependencies .contains (ga )) {
348+ if (compileDependencies .contains (ga ) && !runtimeDependencies .contains (ga )) {
346349 moduleVisitor .visitRequire (moduleName , Opcodes .ACC_STATIC_PHASE , null );
350+ } else {
351+ // We can currently not identify for sure if a 'requires' is NOT transitive.
352+ // For that, we would need the 'compile classpath' of the module we are looking at right now.
353+ // The 'compileDependencies' set is based only on the 'compile classpath' of the final consumer.
354+ moduleVisitor .visitRequire (moduleName , Opcodes .ACC_TRANSITIVE , null );
347355 }
348356 }
349357 }
0 commit comments