Skip to content

Commit

Permalink
Upgrade to Gradle 7.0 (#5364)
Browse files Browse the repository at this point in the history
  • Loading branch information
graemerocher authored May 3, 2021
1 parent f4740de commit e765767
Show file tree
Hide file tree
Showing 93 changed files with 423 additions and 865 deletions.
16 changes: 9 additions & 7 deletions benchmarks/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "me.champeau.gradle.jmh" version "0.5.2"
id "me.champeau.jmh" version "0.6.4"
}

dependencies {
Expand All @@ -17,18 +17,20 @@ dependencies {
api project(":router")
api project(":runtime")

jmh 'org.openjdk.jmh:jmh-core:1.27'
jmh 'org.openjdk.jmh:jmh-generator-annprocess:1.27'
jmh 'org.openjdk.jmh:jmh-core:1.29'
jmh 'org.openjdk.jmh:jmh-generator-annprocess:1.29'
}
jmh {
include =['io.micronaut.http.server.StartupBenchmark']
duplicateClassesStrategy = 'warn'
includes = ['io.micronaut.http.server.StartupBenchmark']
duplicateClassesStrategy = DuplicatesStrategy.WARN
warmupIterations = 2
iterations = 3
fork = 1
jvmArgs = ["-agentpath:/Applications/YourKit-Java-Profiler-2018.04.app/Contents/Resources/bin/mac/libyjpagent.jnilib"]
// jvmArgs = ["-agentpath:/Applications/YourKit-Java-Profiler-2018.04.app/Contents/Resources/bin/mac/libyjpagent.jnilib"]
}
processJmhResources {
duplicatesStrategy = DuplicatesStrategy.WARN
}

spotlessJavaCheck.enabled = false
checkstyleMain.enabled = false
checkstyleJmh.enabled = false
178 changes: 71 additions & 107 deletions bom-check/build.gradle
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)
11 changes: 5 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
buildscript {
repositories {
gradlePluginPortal()
mavenCentral()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:6.1.0'
classpath "io.micronaut.build.internal:micronaut-gradle-plugins:3.0.4"
classpath "gradle.plugin.org.aim42:htmlSanityCheck:$htmlSanityCheckVersion"
classpath "gradle.plugin.com.github.jengelman.gradle.plugins:shadow:7.0.0"
classpath "io.micronaut.build.internal:micronaut-gradle-plugins:4.0.0.RC5"
classpath "org.aim42:htmlSanityCheck:$htmlSanityCheckVersion"
classpath 'javax.xml.bind:jaxb-api:2.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
Expand All @@ -15,8 +15,7 @@ buildscript {
apply plugin: 'org.aim42.htmlSanityCheck'

repositories {
maven { url "https://repo.grails.org/grails/core" }
//maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
mavenCentral()
}

ext {
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ micronautLiquibaseVersion=3.3.1
micronautOldDiscoveryClientVersion=2.0.1
micronautDiscoveryClientVersion=2.4.0
micronautElasticSearchVersion=2.3.0
micronautDocsVersion=1.0.25
micronautDocsVersion=2.0.0.RC1
micronautRssVersion=2.3.0
micronautOldMultitenancyVersion=2.2.3
micronautMultitenancyVersion=3.0.0
Expand Down Expand Up @@ -131,7 +131,7 @@ braveOpentracingVersion=1.0.0
opentracingVersion=0.33.0
micrometerVersion=1.6.3
chromedriverVersion=79.0.3945.36
htmlSanityCheckVersion=1.1.3
htmlSanityCheckVersion=1.1.6
geckodriverVersion=0.26.0
kafkaVersion=2.8.0
systemLambdaVersion=1.0.0
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
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
4 changes: 4 additions & 0 deletions http-client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ dependencies {
exclude module:'micronaut-runtime'
exclude module:'micronaut-inject'
}

if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_15)) {
testImplementation('org.bouncycastle:bcpkix-jdk15on:1.65')
}
}

//tasks.withType(Test) {
Expand Down
4 changes: 3 additions & 1 deletion http-server-netty/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ dependencies {
testImplementation dependencyVersion("spotbugs")
testImplementation group: 'org.powermock', name: 'powermock-module-junit4', version: '2.0.9'
testImplementation group: 'org.powermock', name: 'powermock-api-mockito2', version: '2.0.9'

if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_15)) {
testImplementation('org.bouncycastle:bcpkix-jdk15on:1.65')
}
testImplementation dependencyModuleVersion("micronaut.test", "micronaut-test-junit5"), {
exclude module:'micronaut-runtime'
exclude module:'micronaut-inject'
Expand Down
Loading

0 comments on commit e765767

Please sign in to comment.