Compiletime dependency on FlatDir repository dosnt propagate to dependant modules


(Peter Rasmussen) #1

I have created a testproject with two modules in it. ModuleA and ModuleB.
ModuleA have a flatdir repo with a jar file in it and a compiletime dependency on it.
ModuleB depends on ModuleA and i would expect it to also compile when it accesses the jarfile as it should inherit the compiledependencies. But it dont.
When building ModuleA i get:
Executing external task ‘build’…
:ModuleA:compileJava
:ModuleA:processResources UP-TO-DATE
:ModuleA:classes
:ModuleA:jar
:ModuleA:assemble
:ModuleA:compileTestJava UP-TO-DATE
:ModuleA:processTestResources UP-TO-DATE
:ModuleA:testClasses UP-TO-DATE
:ModuleA:test UP-TO-DATE
:ModuleA:check UP-TO-DATE
:ModuleA:build

BUILD SUCCESSFUL

When building ModuleB i get:
Executing external task ‘build’…
:ModuleA:compileJava UP-TO-DATE
:ModuleA:processResources UP-TO-DATE
:ModuleA:classes UP-TO-DATE
:ModuleA:jar UP-TO-DATE

FAILURE: Build failed with an exception.

  • What went wrong:
    Could not resolve all dependencies for configuration ‘:ModuleB:compileClasspath’.

Could not find :Mylib:1.0-SNAPSHOT.
Searched in the following locations:
https://repo1.maven.org/maven2//Mylib/1.0-SNAPSHOT/maven-metadata.xml
https://repo1.maven.org/maven2//Mylib/1.0-SNAPSHOT/Mylib-1.0-SNAPSHOT.pom
https://repo1.maven.org/maven2//Mylib/1.0-SNAPSHOT/Mylib-1.0-SNAPSHOT.jar
Required by:
ModuleDependency:ModuleB:1.0-SNAPSHOT > ModuleDependency:ModuleA:1.0-SNAPSHOT

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    :ModuleB:compileJava

BUILD FAILED

Total time: 1.103 secs
Could not find :Mylib:1.0-SNAPSHOT.
Searched in the following locations:
https://repo1.maven.org/maven2//Mylib/1.0-SNAPSHOT/maven-metadata.xml
https://repo1.maven.org/maven2//Mylib/1.0-SNAPSHOT/Mylib-1.0-SNAPSHOT.pom
https://repo1.maven.org/maven2//Mylib/1.0-SNAPSHOT/Mylib-1.0-SNAPSHOT.jar
Required by:
ModuleDependency:ModuleB:1.0-SNAPSHOT > ModuleDependency:ModuleA:1.0-SNAPSHOT
21:50:46: External task execution finished ‘build’.

I would expect it to compile and find Mylib in the flatDir repo of moduleA.

I have attached an exampleproject

ModuleDependency.zip (61.1 KB)


(Sterling Greene) #2

The difference is that ModuleB doesn’t have the flatDir as a repository to search. ModuleB does get the dependency information for ModuleA, but it only gets the coordinates, so it has to resolve the dependency itself. ModuleB can only look in mavenCentral() (since that’s the only repository configured).