How to download transitive dependency?

In one project which, is using maven, I have this in pom.xml:


With that, maven will also download (according to platform):

In another project, which is using gradle I have in build.gradle:

compileOnly ('com.nixxcode.jvmbrotli:jvmbrotli:0.2.0') {
    transient = true //As far as I know this is the default

Although it is not downloading the linux-86-amd64 package. I have to include it manually to make it work:

compileOnly 'com.nixxcode.jvmbrotli:jvmbrotli-linux-x86-amd64:0.2.0'

What do I have to do to make it work automatically as I have no control on which platform will be later compiled?


Take a look at the pom file for your dependency. The transitive dependency uses maven profiles to pull in the OS specific jar.

Gradle does not have full support of maven profile activation. See this old blog on how Gradle deals with consuming Maven dependencies that rely on profiles. Gradle can support:

  1. Profiles that are active by default.
  2. Profiles that are active on the absence of a system property.

Unfortunately, the library you are pulling uses OS activation. I suspect that is the reason. I’m not aware of a workaround other than manually adding the transitive dependency.

You can use if conditions to add the correct dependency based on the and os.arch system properties. See example.


Thank you so much for your explanation! Now it is clear to me… :slight_smile:
I think the example you included will be useful. Thanks again.