I need to have a list of dependencies for each subproject with effective dependency versions. There are some version conflicts for some transitive dependencies and higher version is used. So if I execute gradle dependencies
I see smth like this:
com.github.jnr:jnr-posix:3.0.61 -> 3.1.5
So subproject has transitive dependency of version 3.0.61
, but since there is higher version 3.1.5
in the project, it will be used.
I have next task now:
task listDependencies() {
doFirst {
subprojects {
it.project.configurations.resolvableImpl.resolvedConfiguration.resolvedArtifacts.each {
println(it.file.name)
}
}
}
}
It lists 3.0.61
version, but it does not exist in the final package. I need to get final effective version in that list somehow.
Any ideas?
CodePudding user response:
try below if it helps, you can put it in the main build.gradle (no task needed.
allprojects {
afterEvaluate {
println project.name
project.configurations.findAll {
print "\t"
println it.name
if (["incrementalScalaAnalysisElements", "incrementalScalaAnalysisFormain", "incrementalScalaAnalysisFortest"].contains(it.name)) println "\t\t -- Skipped"
else if (it.canBeResolved) it.resolvedConfiguration.resolvedArtifacts.findAll {ra -> println "\t\t" ra.file.name}
else println "\t\t -- not resolvable"
//else it.files { nra -> println nra}
}
}
}
CodePudding user response:
Configuration which is working for me:
configurations {
deployable
}
dependencies {
deployable project(':sub-group:sub-project1')
deployable project(':sub-group:sub-project2')
deployable project(':sub-group:sub-project3')
}
task generateLibsDescriptors() {
dependsOn(configurations.deployable.dependencies.dependencyProject.path.collect { it ":jar" })
doFirst {
configurations.deployable.dependencies.forEach { deployableDependency ->
println deployableDependency.name
configurations.deployable.files(deployableDependency).forEach { file ->
println "\t${file.name}"
}
}
}
}