Configurations collect including multiple verions

(Conall Prendergast) #1

I am building an RPM from a gradle project using gradle ospackage plugin.
So The RPM is to include a lib folder with all the compile dependencies of the project, simple enough.
I have:

from (configurations.compile.collect()) {
    into 'lib'

This puts a bunch of dependencies into the ‘lib’ folder in the RPM root but it includes multiple versions of some of the packages. For example, a

rpm -qlp build/distributions/my.rpm

can produce


How can I make it only include the one version of log4j and all other duplicated dependencies?

(Conall Prendergast) #2

So I am a complete fool.
I forgot that I had overridden some of the dependencies with file dependencies, hence the different versions.
Sorry :frowning:

(Chris Doré) #3

Something else to watch out for is that calling collect() on the configuration will cause the configuration to be resolved during Gradle’s configuration/evaluation phase. This is something that should be avoided as a general best practice.

You can use the configuration directly when calling from() and the configuration will only be resolved if the task is actually executed.

(Conall Prendergast) #4

I actually had an issue whereby a dependency resolve (really a dependency substitution) wasn’t being included in a detached configuration. I therefor had to switch it to a:

       exclude group: ....
 compile "....."

Would using “from” solve this issue?

I was trying to execute the ‘jmh’ task of the gradle-jmh plugin.
Thanks anyways for the tip