Say you wanted to create a zip of all external (i.e. not project
dependencies) runtime dependencies, how would you do it?
This is pretty awkward. This is the best I can come up with:
task zipDeps(type: Zip) { task ->
gradle.taskGraph.whenReady { taskGraph ->
if (taskGraph.hasTask(':zipDeps')) {
def projectNames = rootProject.subprojects*.name
def artifacts = new HashSet()
subprojects.each { subproject ->
subproject.configurations.runtime.resolvedConfiguration.resolvedArtifacts.each
{ artifact ->
def dependency = artifact.moduleVersion.id
if (!projectNames.contains(dependency.name)) {
artifacts << artifact.file
}
}
}
task.from artifacts
}
}
}
Am I missing something?
--
Luke Daley
Principal Engineer, Gradleware
http://gradleware.com