The manual for the Java-Library Plugin says:
A feature of the
java-libraryplugin is that projects which consume the library only require the classes folder for compilation, instead of the full JAR. This enables lighter inter-project dependencies as resources processing (
processResourcestask) and archive construction (
jartask) are no longer executed when only Java code compilation is performed during development.
Yes! Sounds great! I want that! Not only to skip the jar creation step, which sounds nice, but because I believe that if the consumer runs using the classes folder, that will make it faster and easier to do live reloading of classes and resources in our application during the development process.
When I look at
outgoingVariants of the producing project (
:engine), I see that there are secondary variants with artifactTypes of java-classes-directory and java-resources-directory. Looks good to me.
But when I
run the application that depends on it, I get this:
Selected primary task ‘run’ from project :facades
Tasks to be executed: [task ‘:engine:compileJava’, task ‘:engine:processResources’, task ‘:engine:classes’, task ‘:engine:compileDevJava’, task ‘:engine:processDevResources’, task ‘:engine:devClasses’, task ‘:engine:cacheReflections’, task ‘:engine:copyResourcesToClasses’, task ‘:engine:createVersionInfoFile’, task ‘:engine:jar’, task ‘:facades:PC:compileJava’, task ‘:facades:PC:processResources’, task ‘:facades:PC:classes’, task ‘:facades:PC:run’]
which is certainly not skipping the
:engine:jar task, and the application’s classpath has the jar on it instead of a directory.
Build scan for that run task: https://scans.gradle.com/s/6mrxp74uzzf4y
Build scan for just the outgoingVariants task: https://scans.gradle.com/s/2xradzdaiu3ag/console-log
The manual goes on at great length about customizing variants and attributes and all that, but if I understand correctly, what I’m looking for is expected to be the default behavior between sibling Java projects.
There’s lots of stuff going on in the build configuration, so it seems likely we’ve done something to cause that variant selection to break down, but how do I find out what or why?