Skip to content

Commit

Permalink
Exclude transitive dependencies from maven parent (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
Squiry authored Jul 24, 2023
1 parent 336a4e2 commit e74c84b
Showing 1 changed file with 5 additions and 26 deletions.
31 changes: 5 additions & 26 deletions maven-parent/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,18 @@ plugins {
id 'signing'
}

def visitLibrary(DependencyConstraintHandler dep, lib) {
if (lib instanceof Provider) {
dep.api(lib.get())
} else if (lib instanceof VersionCatalog) {
for (def sublib : lib.libraryAliases) {
visitLibrary(dep, lib.findLibrary(sublib).get())
}
} else if (lib instanceof org.gradle.api.internal.catalog.ExternalModuleDependencyFactory) {
for (def entry : lib.properties.entrySet()) {
visitLibrary(dep, entry.value)
}

}
}

dependencies {
constraints {
def addModule = { Project p ->
api(p)
}

var added = new HashSet<String>()
project.rootProject.subprojects {
if (added.add(it.name)){
addModule(it)
}
}


for (def lib : libs.properties) {
if (lib.value != null) {
visitLibrary(it, lib.value)
project.rootProject.subprojects { Project p ->
if (p.parent.name == 'internal') return
if (!p.subprojects.isEmpty()) return
if (added.add(p.name)) {
addModule(p)
}
}
}
Expand Down Expand Up @@ -126,7 +106,6 @@ publishing {
email = '[email protected]'
}
}

}
}
}
Expand Down

0 comments on commit e74c84b

Please sign in to comment.