Trying to unpack the jars of two specific dependencies gives me an UP-TO-DATE

Hi

There are two dependencies with 3-3 jar files each, containing native .dll and .so libraries that I would like to extract to $buildDir/natives/. I made a simple Copy task to handle it.

However, for some reason, Gradle thinks the task is up to date, and refuses to do anything, even if I do an upToDateWhen false.

But, if I instead include a dependency that has the other two as transitive dependencies, suddenly it can extract them. It is commented out below:

apply plugin: 'java'
  repositories {
    mavenCentral()
}
  configurations {
    natives
}
  dependencies {
    natives group: 'net.java.jinput', name: 'jinput-platform', version: 'latest.release'
    natives group: 'org.lwjgl.lwjgl', name: 'lwjgl-platform', version: 'latest.release'
//
  natives group: 'org.lwjgl.lwjgl', name: 'lwjgl', version: 'latest.release'
}
  task extractNatives (type: Copy, dependsOn: configurations.natives) {
    from configurations.natives.collect {
        zipTree(it)
    }
    into("$buildDir/natives/")
}

Am I overlooking something obvious or otherwise what is going on?

Thank you for your help!

One obvious problem is that you resolve the configuration in the configuration phase. To fix this, enclose the expression following ‘from’ in curly braces.

Have tried that too but found no change in behavior.

As can be seen on http://search.maven.org, all artifacts associated with these dependencies have classifiers. Hence you’ll have to use one of ‘classifier: ‘natives-osx’’, ‘classifier: ‘natives-windows’’, or ‘classifier: ‘natives-linux’’. Otherwise you’ll get back an empty set of artifacts.

A good way to find such problems is to print the resolved contents of a configuration:

task debug << {
  configurations.natives.each { println it }
}

Thank you, you just saved me from several days worth of headache!