-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4740de
commit e765767
Showing
93 changed files
with
423 additions
and
865 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,134 +1,98 @@ | ||
import groovy.xml.XmlSlurper | ||
|
||
plugins { | ||
id 'java' | ||
id 'java-library' | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
|
||
//TODO remove | ||
jcenter() | ||
maven { url "https://repo.grails.org/grails/libs-releases" } | ||
// TODO: remove when GORM is in central | ||
maven { url "https://repo.grails.org/grails/libs-releases/" } | ||
} | ||
|
||
boolean micronautSnapshot = rootProject.version.toString().endsWith("-SNAPSHOT") | ||
|
||
def excludedProjects = [ | ||
"benchmarks", | ||
"inject-test-utils", | ||
"test-suite", | ||
"test-suite-groovy", | ||
"test-suite-helper", | ||
"test-suite-kotlin", | ||
"test-utils" | ||
] | ||
configurations.all { | ||
resolutionStrategy.dependencySubstitution { | ||
for (Project p : rootProject.subprojects) { | ||
if (!p.subprojects.empty) continue | ||
if (excludedProjects.contains(p.name)) continue | ||
substitute module("io.micronaut:micronaut-$p.name") with project(":$p.name") | ||
// checks all the BOMs are resolvable from central | ||
task("checkBom") { | ||
doLast { | ||
// verify BOMs | ||
def centralURL = repositories.findByName("MavenRepo").url | ||
List<String> errors = [] | ||
for (dep in bomVersions) { | ||
def info = dep.value | ||
def versionExpr = info.version | ||
|
||
def pom = new groovy.xml.XmlSlurper() | ||
.parse("$centralURL${info.group.replace('.', '/')}/${info.name}/$versionExpr/${info.name}-${versionExpr}.pom") | ||
if (!info.group.startsWith("io.micronaut")) { | ||
pom.dependencyManagement.dependencies.dependency.each { | ||
|
||
String groupId = it.groupId.text() | ||
groupId = groupId.replace('${project.groupId}', info.group) | ||
|
||
if (!groupId.startsWith(info.group)) { | ||
errors << "Error validating BOM [${info.name}]: includes the dependency [${it.groupId}:${it.artifactId}:${it.version}] that doesn't belong to the group id of the BOM: [${info.group}]".toString() | ||
} | ||
|
||
} | ||
} | ||
|
||
} | ||
} | ||
} | ||
dependencies { | ||
//Include Micronaut BOM | ||
implementation enforcedPlatform(project(":bom")) | ||
|
||
//Include other BOMs | ||
for (dep in bomVersions) { | ||
def info = dep.value | ||
def versionExpr = info.version | ||
implementation platform("$info.group:$info.name:$versionExpr") | ||
} | ||
|
||
//Include core projects | ||
for (Project p : rootProject.subprojects) { | ||
if (!p.subprojects.empty) continue | ||
if (p.name.contains("bom") || p.name.contains("parent")) continue | ||
if (excludedProjects.contains(p.name)) continue | ||
// verify dependencies | ||
for (dep in dependencyVersions) { | ||
def info = dep.value | ||
// don't include snapshots | ||
if (info.version.toString().endsWith("-SNAPSHOT") && !micronautSnapshot) { | ||
continue | ||
} | ||
|
||
implementation p | ||
} | ||
def versionExpr = dep.value.version | ||
def moduleName = info.name | ||
if (moduleName) { | ||
validatePom(centralURL, info, moduleName, versionExpr, errors) | ||
} | ||
info.modules?.each { | ||
validatePom(centralURL, info, it, versionExpr, errors) | ||
} | ||
|
||
//Include the rest of dependencies | ||
for (dep in dependencyVersions) { | ||
def info = dep.value | ||
// don't include snapshots | ||
if (info.version.toString().endsWith("-SNAPSHOT") && !micronautSnapshot) { | ||
continue | ||
} | ||
|
||
def versionExpr = dep.value.version | ||
|
||
if (info.name) { | ||
implementation "$info.group:$info.name:$versionExpr" | ||
} | ||
if (info.modules) { | ||
for (m in info.modules) { | ||
implementation "$info.group:$m:$versionExpr" | ||
} | ||
if (errors) { | ||
throw new GradleException("Bom Check Failed: " + errors.join("\n")) | ||
} | ||
} | ||
} | ||
|
||
//publishing { | ||
// publications { | ||
// maven(MavenPublication) { | ||
// groupId = 'io.micronaut.internal' | ||
// artifactId = 'micronaut-bom-check' | ||
// version = project.version | ||
// from components.java | ||
// } | ||
// } | ||
//} | ||
check.dependsOn(checkBom) | ||
|
||
//publish.enabled = false | ||
private validatePom(centralURL, info, moduleName, versionExpr, List errors) { | ||
def pom = null | ||
|
||
task validateMicronautBom { | ||
doLast { | ||
configurations.each { cfg -> | ||
if (cfg.isCanBeResolved()) { | ||
cfg.resolve() | ||
} | ||
} | ||
try { | ||
pom = new XmlSlurper() | ||
.parse("$centralURL${info.group.replace('.', '/')}/${moduleName}/$versionExpr/${moduleName}-${versionExpr}.pom") | ||
} catch (e) { | ||
println "WARNING: Dependency ${moduleName} is not in Maven Central or has an invalid POM: $e.message" | ||
} | ||
} | ||
|
||
task validateThirdPartyBoms(dependsOn:['validateMicronautBom']) { | ||
doLast { | ||
for (dep in bomVersions) { | ||
def info = dep.value | ||
if (info.group.startsWith("io.micronaut")) continue | ||
|
||
def componentId = "$info.group:$info.name:$info.version" | ||
|
||
Configuration cfg = configurations.detachedConfiguration(dependencies.create(componentId)) | ||
cfg.incoming.resolutionResult.allDependencies { DependencyResult dr -> | ||
def result = dependencies.createArtifactResolutionQuery() | ||
.forModule(info.group, info.name, info.version) | ||
.withArtifacts(MavenModule, MavenPomArtifact) | ||
.execute() | ||
|
||
for (component in result.resolvedComponents) { | ||
component.getArtifacts(MavenPomArtifact).each { | ||
def pom = new XmlSlurper().parse(it.file) | ||
|
||
pom.dependencyManagement.dependencies.dependency.each { | ||
String groupId = it.groupId.text() | ||
groupId = groupId.replace('${project.groupId}', info.group) | ||
if (!groupId.startsWith(info.group)) { | ||
throw new GradleException("Error validating BOM [${componentId}]: includes the dependency [${it.groupId}:${it.artifactId}:${it.version}] that doesn't belong to the group id of the BOM: [${info.group}]") | ||
} | ||
} | ||
|
||
} | ||
} | ||
} | ||
} | ||
// try other repos | ||
if (pom == null) { | ||
for (repo in repositories) { | ||
try { | ||
def url = "${repo.url}${info.group.replace('.', '/')}/${moduleName}/$versionExpr/${moduleName}-${versionExpr}.pom" | ||
pom = new XmlSlurper() | ||
.parse(url) | ||
if (pom != null) { | ||
break | ||
} | ||
} catch (e) { | ||
|
||
} | ||
} | ||
} | ||
if (pom == null) { | ||
errors << "Error validating POM for dependency [${moduleName}]: POM Not Found or not Parseable".toString() | ||
} | ||
} | ||
|
||
task bomCheck(dependsOn: [validateThirdPartyBoms]) | ||
|
||
check.dependsOn(bomCheck) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.