ResolvedDependency.getModuleArtifacts() returns 0 items for transitive dependencies in m7


(Magnus Rundberget) #1

In milestone 3 the below snippet worked, however after upgrading to m7 ResolvedDependency.getModuleArtifacts() doesn’t return any ResolvedModuleArtifacts for transitive (child) dependencies. I’ve found a workaround, but its not nearly as elegant.

def generateThirdPartyIkvmDll(dependency) {
    def artifact = null
    if(dependency.moduleArtifacts.size() == 1) { // returns 0 for transitive children
  artifact = dependency.moduleArtifacts.iterator().next()
    } else {
  throw new RuntimeException("Error: dependency doesn't have a moduleartifact, or has several")
 }
    def ikvmDll = new File("build/ikvm", "${artifact.name}.dll")
     def refs = [ikvmDll]
 def commandLineArgs = ["-out:$ikvmDll", "-version:0.0.0.0", artifact.file]
 def childRefs =
dependency.children.each {child ->
        generateThirdPartyIkvmDll(child)
    }
    childRefs = childRefs.flatten().unique()
    childRefs.each {
  commandLineArgs += "-reference:$it"
    }
      executeIkvm(ikvmDll, commandLineArgs) // generetates dll from jar file
      refs += childRefs
    return refs
}
  task myFancyTask << {
 configurations.thirdPartyIkvmDlls.resolvedConfiguration.firstLevelModuleDependencies.each {dependency ->
        println "First level dependency: ${dependency.name}"
        generateThirdPartyIkvmDll(dependency)
    }
}