Eclipse import does not trigger builtBy when resolving dependencies

(Daryl Teo) #1
project.with {
        // find all zip files
        .filter { file -> return'.zip') }
        .each { file ->
          def modName = - '.zip'
          def modDir = rootProject.file("mods/$modName")
          def modLibs = rootProject.fileTree("mods/$modName/lib") {
            include '*.jar'
            builtBy dep.installModules
            println "Module Dependency for $project from $dep: $modName"
            // Add the extracted contents to provided
          dependencies.provided modLibs
            sourceSets.all {
            compileClasspath += modLibs + rootProject.files(modDir)

So I have this code above that I’m calling to extract zips and add them to my classpath. This works when running on command line, but eclipse fails to trigger the ‘installModules’ task I have set up that does the actual extracting. Is there something I am missing?

It is also worth noting that I do believe my dependencies are set up correctly: if I run the installModules task manually and refresh dependencies, Eclipse correctly picks up the files without much fuss.

Other notes:

  • this is in a afterEvaluate closure, so there shouldn’t be any issues with incomplete configurations.

  • all I just want to do is get all the zip files, unzip them, remove dependency on zip, add dependency on zip jars… THAT’S ALL WHY IS THIS SO HARD? sigh. I cannot remove the files from the provided/compile configurations that’s why I created a new configuration ‘modules’.

  • this might not have been so hard if I could have subclassed ExternalModuleDependency (which is an interface), and then modify its file contents.

Regards, Daryl