Hi,
I work on a Gradle multi-module POC, containing libraries / applications in Java and C++. Assembling and publishing in my local Maven repository works well for all components.
But, I would like to create a dependency between a Jar and a native component (called from jar project in a specific folder at runtime). As a good noob, i’ve tried to add this rule in my Java subproject:
dependencies {
api project(':backends:CGI:document') // document is a cpp project
testImplementation group: 'junit', name: 'junit', version:'4.12'
}
I get this error:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':frontends:extensions:compileJava'.
> Could not resolve all task dependencies for configuration ':frontends:extensions:compileClasspath'.
> Could not resolve project :backends:CGI:document.
Required by:
project :frontends:extensions
> Unable to find a matching variant of project :backends:CGI:document:
- Variant 'debugWindowsX86-64RuntimeElements' capability foo.bar:document:1.2.000.0.2020.04.08.16.05:
- Incompatible attribute:
- Required org.gradle.usage 'java-api' and found incompatible value 'native-runtime'.
- Other attributes:
- Required org.gradle.category 'library' but no value provided.
- Required org.gradle.dependency.bundling 'external' but no value provided.
- Required org.gradle.jvm.version '8' but no value provided.
- Required org.gradle.libraryelements 'classes' but no value provided.
- Found org.gradle.native.architecture 'x86-64' but wasn't required.
- Found org.gradle.native.debuggable 'true' but wasn't required.
- Found org.gradle.native.operatingSystem 'windows' but wasn't required.
- Found org.gradle.native.optimized 'false' but wasn't required.
- Variant 'debugWindowsX86RuntimeElements' capability foo.bar:document:1.2.000.0.2020.04.08.16.05:
- Incompatible attribute:
- Required org.gradle.usage 'java-api' and found incompatible value 'native-runtime'.
- Other attributes:
- Required org.gradle.category 'library' but no value provided.
- Required org.gradle.dependency.bundling 'external' but no value provided.
- Required org.gradle.jvm.version '8' but no value provided.
- Required org.gradle.libraryelements 'classes' but no value provided.
- Found org.gradle.native.architecture 'x86' but wasn't required.
- Found org.gradle.native.debuggable 'true' but wasn't required.
- Found org.gradle.native.operatingSystem 'windows' but wasn't required.
- Found org.gradle.native.optimized 'false' but wasn't required.
- Variant 'releaseWindowsX86-64RuntimeElements' capability foo.bar:document:1.2.000.0.2020.04.08.16.05:
- Incompatible attribute:
- Required org.gradle.usage 'java-api' and found incompatible value 'native-runtime'.
- Other attributes:
- Required org.gradle.category 'library' but no value provided.
- Required org.gradle.dependency.bundling 'external' but no value provided.
- Required org.gradle.jvm.version '8' but no value provided.
- Required org.gradle.libraryelements 'classes' but no value provided.
- Found org.gradle.native.architecture 'x86-64' but wasn't required.
- Found org.gradle.native.debuggable 'true' but wasn't required.
- Found org.gradle.native.operatingSystem 'windows' but wasn't required.
- Found org.gradle.native.optimized 'true' but wasn't required.
- Variant 'releaseWindowsX86RuntimeElements' capability foo.bar:document:1.2.000.0.2020.04.08.16.05:
- Incompatible attribute:
- Required org.gradle.usage 'java-api' and found incompatible value 'native-runtime'.
- Other attributes:
- Required org.gradle.category 'library' but no value provided.
- Required org.gradle.dependency.bundling 'external' but no value provided.
- Required org.gradle.jvm.version '8' but no value provided.
- Required org.gradle.libraryelements 'classes' but no value provided.
- Found org.gradle.native.architecture 'x86' but wasn't required.
- Found org.gradle.native.debuggable 'true' but wasn't required.
- Found org.gradle.native.operatingSystem 'windows' but wasn't required.
- Found org.gradle.native.optimized 'true' but wasn't required.
Hmm… how to select the good variant depending of the current environment ?
Reading this page about variant model doesn’t help me, but give me some clues.