Hello everyone,
I have problem and I hope some more experience gradle plugin developer can help me find what exactly I’m doing wrong. Problem I’m trying to solve by plugin is following. I would like to compile my Java source code with multiple JDK. To be able to produce all LTS jdks artifact in single build. I took inspiration originally from plugin generating multi jdk jars. However I’m facing issue with dependencies in multi-project build.
To start from beginning, I defined plugin and plugin extension classes. In plugin I register extension collect some objects for extension and that is about it. Extension class definite method to consume requested JDK configuration and in this method I’m doing most of configuration. Fist step is creating SourceSet specific to extension and extending it by main source set to allow specific compiler discover classes defined in main source set. Setting up some filtering for modules classes in case when JDK8 and define used compiler in compile task including target platform.
As far as I can say this is working if project has no dependencies. However when one project module deepens on other project module I’m facing problem how to configure build. After week or so experimenting and debugging my best success was adding compile/classes task configuration when I was able to locate configured dependencies and propagate them to new feature configuration.
Unfortunately this approach even to me feels like hack and not properly working. Dependencies are propagated unfortunately when gradle try to resolve variant for specific JDK I’m getting following variant error:
- Variant ‘jdk8RuntimeElements’ declares a library for use during runtime, compatible with Java 8, packaged as a jar, and its dependencies declared externally:
- Other compatible attribute:
- Doesn’t say anything about its target Java environment (preferred optimized for standard JVMs)
- Other compatible attribute:
This part of message is for variant I expect to be used as dependency in sub-module compiled by JDK8 registered as feature. Can someone help me to identify problem?
BR,
Thank you,