How to use LWJGL? Or: how to use native libraries?

Still no luck… Here is my build.gradle:

apply plugin: 'java'
  repositories {
    mavenCentral()
}
  dependencies {
    compile 'org.lwjgl.lwjgl:lwjgl:2.8.2'
}
  task copyNativesWindows(type: Copy) {
    from configurations.compile.files {
         it instanceof ExternalModuleDependency && it.artifacts.every { it.classifier == 'natives-windows' }
    }
     into "$buildDir/natives/windows"
}

If I run “gradle clean” followed by “gradle copyNativesWindows”, $buildDir/natives/windows looks like this:

jinput-2.0.5.jar jinput-platform-2.0.5-natives-linux.jar jinput-platform-2.0.5-natives-osx.jar jinput-platform-2.0.5-natives-windows.jar jutils-1.0.0.jar lwjgl-2.8.2.jar lwjgl-platform-2.8.2-natives-linux.jar lwjgl-platform-2.8.2-natives-osx.jar lwjgl-platform-2.8.2-natives-windows.jar

I would have expected it to look more like: jinput-platform-2.0.5-natives-windows.jar lwjgl-platform-2.8.2-natives-windows.jar

Really not sure what I am doing wrong.

I have tried getting more information about what exactly is happening in copyNativesWindows. For example, I have tried something like this:

task copyNativesWindows(type: Copy) {
    from configurations.compile.files {
         println("it: " + it)
        println("it.artifacts: " + it.artifacts)
        it instanceof ExternalModuleDependency && it.artifacts.every { it.classifier == 'natives-windows' }
    }
     into "$buildDir/natives/windows"
}

My output ends up looking like this:

it: DefaultExternalModuleDependency{group=‘org.lwjgl.lwjgl’, name=‘lwjgl’, version=‘2.8.2’, configuration=‘default’} it.artifacts: [] it: DefaultExternalModuleDependency{group=‘org.lwjgl.lwjgl’, name=‘lwjgl’, version=‘2.8.2’, configuration=‘default’} it.artifacts: [] :copyNativesWindows

BUILD SUCCESSFUL

My guess as to why all these files are being copied is that every one of the artifacts pass the classifier comparison, since there seem to be no artifacts to run the comparison against. I’m not sure why it seems as though the closure is being called twice. Clearly I’m doing something wrong, but I’m not sure what. Could do me the favor of posting your build.gradle for me to examine? Any additional advice would be welcome.