Reputation: 10604
I have dependencies:
A
B
(that also depends on A
).Now, I want to use specifier on A
, lets say: A-foo
. However, B
still depends on A
and as a result, I get both A-foo
and A
included in the target artifact.
Is there a way to force classifier on certain dependency?
The reason why I need this is the following.
My A
is a Java library built on Java8 but packaged as Multi-Release Jar which means it contains additional classes for when jar is run on Java9.
Unfortunately, some old tools and servers are not aware of MR Jars and this makes them not working.
For that reason I have A-foo
version of my library, that is without any extra classes, so old server can run it.
However, if user is using library B
that depends on my A
, he will simply get the MRJar version of A
and it will fail again. I want to be able to prevent this somehow.
Upvotes: 3
Views: 1277
Reputation: 10604
In Gradle this is possible with the following code:
compile ('org.jodd:jodd-core:4.1.4:jre9') {
force = true
}
compile ('org.jodd:jodd-joy:4.1.4') {
exclude group: 'org.jodd', module:'jodd-core'
}
This means:
Upvotes: 0
Reputation: 35785
An artifact with a classifier is a different artifact, not just a different version of the same artifact. It cannot replace - neither technically nor logically - the original artifact, meaning: Even if you would find a way around it technically, it goes against Maven logic.
If you describe in more detail which problem you want to solve, one can probably find a "Maven way" to do it.
Upvotes: 1