From 72c2e1548799604ae54884080b0f2c8a7ecb1578 Mon Sep 17 00:00:00 2001 From: Steve Riesenberg Date: Wed, 30 Mar 2022 14:39:01 -0500 Subject: [PATCH] Upgrade build to Gradle 7 Closes gh-572 --- build.gradle | 50 +++-------------- ...g-authorization-server-dependencies.gradle | 25 +++++++++ .../docs-modules-guides-examples.gradle | 40 +++++++------- docs/spring-authorization-server-docs.gradle | 3 ++ gradle.properties | 7 ++- gradle/dependency-management.gradle | 38 ------------- gradle/wrapper/gradle-wrapper.properties | 2 +- ...ecurity-oauth2-authorization-server.gradle | 52 +++++++++--------- ...-custom-consent-authorizationserver.gradle | 35 +++++++++--- ...samples-default-authorizationserver.gradle | 37 +++++++++---- ...erated-identity-authorizationserver.gradle | 43 +++++++++------ .../samples-messages-client.gradle | 38 +++++++++---- .../samples-messages-resource.gradle | 24 +++++++-- settings.gradle | 54 ++++++++++++++----- 14 files changed, 260 insertions(+), 188 deletions(-) create mode 100644 dependencies/spring-authorization-server-dependencies.gradle create mode 100644 docs/spring-authorization-server-docs.gradle delete mode 100644 gradle/dependency-management.gradle diff --git a/build.gradle b/build.gradle index eb71eaf2..35ff5b0e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,47 +1,13 @@ -buildscript { - dependencies { - classpath 'io.spring.gradle:spring-build-conventions:0.0.38' - classpath "org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion" - classpath 'io.spring.nohttp:nohttp-gradle:0.0.8' - } - repositories { - maven { - url = 'https://repo.spring.io/plugins-snapshot' - if (project.hasProperty('artifactoryUsername')) { - credentials { - username "$artifactoryUsername" - password "$artifactoryPassword" - } - } - } - maven { url 'https://plugins.gradle.org/m2/' } - } +plugins { + id "io.spring.convention.root" } -apply plugin: 'io.spring.nohttp' -apply plugin: 'locks' -apply plugin: 'io.spring.convention.root' +group = "org.springframework.security" +description = "Spring Authorization Server" -group = 'org.springframework.security' -description = 'Spring Authorization Server' - -ext.snapshotBuild = version.contains("SNAPSHOT") - -repositories { - mavenCentral() -} - -dependencyManagementExport.projects = subprojects.findAll { !it.name.contains('-boot') } - -subprojects { - plugins.withType(JavaPlugin) { - project.sourceCompatibility = "1.8" - } - tasks.withType(JavaCompile) { - options.encoding = "UTF-8" +if (hasProperty("buildScan")) { + buildScan { + termsOfServiceUrl = "https://gradle.com/terms-of-service" + termsOfServiceAgree = "yes" } } - -nohttp { - allowlistFile = project.file("etc/nohttp/allowlist.lines") -} diff --git a/dependencies/spring-authorization-server-dependencies.gradle b/dependencies/spring-authorization-server-dependencies.gradle new file mode 100644 index 00000000..fdea6041 --- /dev/null +++ b/dependencies/spring-authorization-server-dependencies.gradle @@ -0,0 +1,25 @@ +plugins { + id "java-platform" +} + +javaPlatform { + allowDependencies() +} + +dependencies { + api platform("org.springframework:spring-framework-bom:$springFrameworkVersion") + api platform("org.springframework.security:spring-security-bom:$springSecurityVersion") + api platform("org.junit:junit-bom:5.8.2") + api platform("com.fasterxml.jackson:jackson-bom:2.13.2") + constraints { + api "com.nimbusds:nimbus-jose-jwt:9.10.1" + api "javax.servlet:javax.servlet-api:4.0.1" + api "junit:junit:4.13.2" + api "org.assertj:assertj-core:3.22.0" + api "org.mockito:mockito-core:3.12.4" + api "com.squareup.okhttp3:mockwebserver:3.14.9" + api "com.squareup.okhttp3:okhttp:3.14.9" + api "com.jayway.jsonpath:json-path:2.7.0" + api "org.hsqldb:hsqldb:2.6.1" + } +} diff --git a/docs/modules/guides/examples/docs-modules-guides-examples.gradle b/docs/modules/guides/examples/docs-modules-guides-examples.gradle index 21989f6e..eb463e31 100644 --- a/docs/modules/guides/examples/docs-modules-guides-examples.gradle +++ b/docs/modules/guides/examples/docs-modules-guides-examples.gradle @@ -1,30 +1,30 @@ plugins { - id 'java' + id "java" } -group = 'org.springframework.security' -version = '0.0.1-SNAPSHOT' -sourceCompatibility = '1.8' +group = project.rootProject.group +version = project.rootProject.version +sourceCompatibility = "11" repositories { - mavenCentral() + mavenCentral() } dependencies { - implementation platform('org.springframework.boot:spring-boot-dependencies:2.6.2') - implementation 'org.springframework.boot:spring-boot-starter-data-jpa' - implementation 'org.springframework.boot:spring-boot-starter-oauth2-client' - implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server' - implementation 'org.springframework.boot:spring-boot-starter-security' - implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' - implementation 'org.springframework.boot:spring-boot-starter-web' - implementation 'org.springframework.security:spring-security-oauth2-authorization-server:0.2.1' - implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5' - runtimeOnly 'com.h2database:h2' - testImplementation 'org.springframework.boot:spring-boot-starter-test' - testImplementation 'org.springframework.security:spring-security-test' + implementation platform("org.springframework.boot:spring-boot-dependencies:2.5.12") + implementation "org.springframework.boot:spring-boot-starter-web" + implementation "org.springframework.boot:spring-boot-starter-thymeleaf" + implementation "org.springframework.boot:spring-boot-starter-security" + implementation "org.springframework.boot:spring-boot-starter-oauth2-client" + implementation "org.springframework.boot:spring-boot-starter-oauth2-resource-server" + implementation "org.springframework.boot:spring-boot-starter-data-jpa" + implementation "org.thymeleaf.extras:thymeleaf-extras-springsecurity5" + implementation project(":spring-security-oauth2-authorization-server") + runtimeOnly "com.h2database:h2" + testImplementation "org.springframework.boot:spring-boot-starter-test" + testImplementation "org.springframework.security:spring-security-test" } -test { - useJUnitPlatform() -} \ No newline at end of file +tasks.named("test") { + useJUnitPlatform() +} diff --git a/docs/spring-authorization-server-docs.gradle b/docs/spring-authorization-server-docs.gradle new file mode 100644 index 00000000..53c680f0 --- /dev/null +++ b/docs/spring-authorization-server-docs.gradle @@ -0,0 +1,3 @@ +plugins { + id "io.spring.convention.docs" +} diff --git a/gradle.properties b/gradle.properties index b478578a..5f61c21f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,10 @@ version=0.3.0-SNAPSHOT -springBootVersion=2.5.10 org.gradle.jvmargs=-Xmx3g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError org.gradle.parallel=true org.gradle.caching=true +springFrameworkVersion=5.3.19 +springSecurityVersion=5.5.6 +springJavaformatVersion=0.0.31 +checkstyleToolVersion=8.34 +nohttpCheckstyleVersion=0.0.10 +jacocoToolVersion=0.8.7 diff --git a/gradle/dependency-management.gradle b/gradle/dependency-management.gradle deleted file mode 100644 index edebfa04..00000000 --- a/gradle/dependency-management.gradle +++ /dev/null @@ -1,38 +0,0 @@ -if (!project.hasProperty("springVersion")) { - ext.springVersion = "5.3.16" -} - -if (!project.hasProperty("springSecurityVersion")) { - ext.springSecurityVersion = "5.5.5" -} - -if (!project.hasProperty("reactorVersion")) { - ext.reactorVersion = "2020.0.16" -} - -if (!project.hasProperty("locksDisabled")) { - dependencyLocking { - lockAllConfigurations() - } -} - -dependencyManagement { - imports { - mavenBom "org.springframework:spring-framework-bom:$springVersion" - mavenBom "org.springframework.security:spring-security-bom:$springSecurityVersion" - mavenBom "io.projectreactor:reactor-bom:$reactorVersion" - mavenBom "com.fasterxml.jackson:jackson-bom:2.12.6" - } - - dependencies { - dependency "com.nimbusds:nimbus-jose-jwt:9.10.1" - dependency "javax.servlet:javax.servlet-api:4.0.1" - dependency 'junit:junit:4.13.2' - dependency 'org.assertj:assertj-core:3.19.0' - dependency 'org.mockito:mockito-core:3.9.0' - dependency "com.squareup.okhttp3:mockwebserver:3.14.9" - dependency "com.squareup.okhttp3:okhttp:3.14.9" - dependency "com.jayway.jsonpath:json-path:2.5.0" - dependency "org.hsqldb:hsqldb:2.5.2" - } -} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 549d8442..e750102e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/oauth2-authorization-server/spring-security-oauth2-authorization-server.gradle b/oauth2-authorization-server/spring-security-oauth2-authorization-server.gradle index 1644ebcf..4db6d872 100644 --- a/oauth2-authorization-server/spring-security-oauth2-authorization-server.gradle +++ b/oauth2-authorization-server/spring-security-oauth2-authorization-server.gradle @@ -1,31 +1,35 @@ -apply plugin: 'io.spring.convention.spring-module' +plugins { + id "io.spring.convention.spring-module" +} dependencies { - compile 'org.springframework.security:spring-security-config' - compile 'org.springframework.security:spring-security-web' - compile 'org.springframework.security:spring-security-oauth2-core' - compile 'org.springframework.security:spring-security-oauth2-jose' - compile 'org.springframework.security:spring-security-oauth2-resource-server' - compile springCoreDependency - compile 'com.nimbusds:nimbus-jose-jwt' - compile 'com.fasterxml.jackson.core:jackson-databind' + management platform(project(":spring-authorization-server-dependencies")) - optional 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310' - optional 'org.springframework:spring-jdbc' + api "org.springframework.security:spring-security-config" + api "org.springframework.security:spring-security-web" + api "org.springframework.security:spring-security-oauth2-core" + api "org.springframework.security:spring-security-oauth2-jose" + api "org.springframework.security:spring-security-oauth2-resource-server" + api("org.springframework:spring-core") { + exclude group: "commons-logging", module: "commons-logging" + } + api "com.nimbusds:nimbus-jose-jwt" + api "com.fasterxml.jackson.core:jackson-databind" - testCompile 'org.springframework.security:spring-security-test' - testCompile 'org.springframework:spring-webmvc' - testCompile 'junit:junit' - testCompile 'org.assertj:assertj-core' - testCompile 'org.mockito:mockito-core' - testCompile 'com.jayway.jsonpath:json-path' - testCompile 'com.squareup.okhttp3:mockwebserver' + optional "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" + optional "org.springframework:spring-jdbc" - testRuntime 'org.hsqldb:hsqldb' + testImplementation "org.springframework.security:spring-security-test" + testImplementation "org.springframework:spring-webmvc" + testImplementation "org.junit.jupiter:junit-jupiter" + testImplementation "junit:junit" + testImplementation "org.junit.vintage:junit-vintage-engine" + testImplementation "org.assertj:assertj-core" + testImplementation "org.mockito:mockito-core" + testImplementation "com.jayway.jsonpath:json-path" + testImplementation "com.squareup.okhttp3:mockwebserver" - provided 'javax.servlet:javax.servlet-api' -} - -jacoco { - toolVersion = '0.8.6' + testRuntimeOnly "org.hsqldb:hsqldb" + + provided "javax.servlet:javax.servlet-api" } diff --git a/samples/custom-consent-authorizationserver/samples-custom-consent-authorizationserver.gradle b/samples/custom-consent-authorizationserver/samples-custom-consent-authorizationserver.gradle index b58a36aa..21340bc3 100644 --- a/samples/custom-consent-authorizationserver/samples-custom-consent-authorizationserver.gradle +++ b/samples/custom-consent-authorizationserver/samples-custom-consent-authorizationserver.gradle @@ -1,12 +1,31 @@ -apply plugin: 'io.spring.convention.spring-sample-boot' +plugins { + id "org.springframework.boot" version "2.5.12" + id "io.spring.dependency-management" version "1.0.11.RELEASE" + id "java" +} + +group = project.rootProject.group +version = project.rootProject.version +sourceCompatibility = "11" + +repositories { + mavenCentral() +} dependencies { - compile 'org.springframework.boot:spring-boot-starter-web' - compile 'org.springframework.boot:spring-boot-starter-thymeleaf' - compile 'org.springframework.boot:spring-boot-starter-security' - compile project(':spring-security-oauth2-authorization-server') + implementation "org.springframework.boot:spring-boot-starter-web" + implementation "org.springframework.boot:spring-boot-starter-thymeleaf" + implementation "org.springframework.boot:spring-boot-starter-security" + implementation project(":spring-security-oauth2-authorization-server") - testCompile 'org.springframework.boot:spring-boot-starter-test' - testCompile 'org.springframework.security:spring-security-test' - testCompile 'net.sourceforge.htmlunit:htmlunit' + testImplementation "org.springframework.boot:spring-boot-starter-test" + testImplementation "org.junit.jupiter:junit-jupiter" + testImplementation "junit:junit" + testImplementation "org.junit.vintage:junit-vintage-engine" + testImplementation "org.springframework.security:spring-security-test" + testImplementation "net.sourceforge.htmlunit:htmlunit" +} + +tasks.named("test") { + useJUnitPlatform() } diff --git a/samples/default-authorizationserver/samples-default-authorizationserver.gradle b/samples/default-authorizationserver/samples-default-authorizationserver.gradle index 2a24a81a..cdc87738 100644 --- a/samples/default-authorizationserver/samples-default-authorizationserver.gradle +++ b/samples/default-authorizationserver/samples-default-authorizationserver.gradle @@ -1,13 +1,32 @@ -apply plugin: 'io.spring.convention.spring-sample-boot' +plugins { + id "org.springframework.boot" version "2.5.12" + id "io.spring.dependency-management" version "1.0.11.RELEASE" + id "java" +} + +group = project.rootProject.group +version = project.rootProject.version +sourceCompatibility = "11" + +repositories { + mavenCentral() +} dependencies { - compile 'org.springframework.boot:spring-boot-starter-web' - compile 'org.springframework.boot:spring-boot-starter-security' - compile 'org.springframework.boot:spring-boot-starter-jdbc' - compile project(':spring-security-oauth2-authorization-server') - runtimeOnly 'com.h2database:h2' + implementation "org.springframework.boot:spring-boot-starter-web" + implementation "org.springframework.boot:spring-boot-starter-security" + implementation "org.springframework.boot:spring-boot-starter-jdbc" + implementation project(":spring-security-oauth2-authorization-server") + runtimeOnly "com.h2database:h2" - testCompile 'org.springframework.boot:spring-boot-starter-test' - testCompile 'org.springframework.security:spring-security-test' - testCompile 'net.sourceforge.htmlunit:htmlunit' + testImplementation "org.springframework.boot:spring-boot-starter-test" + testImplementation "org.junit.jupiter:junit-jupiter" + testImplementation "junit:junit" + testImplementation "org.junit.vintage:junit-vintage-engine" + testImplementation "org.springframework.security:spring-security-test" + testImplementation "net.sourceforge.htmlunit:htmlunit" +} + +tasks.named("test") { + useJUnitPlatform() } diff --git a/samples/federated-identity-authorizationserver/samples-federated-identity-authorizationserver.gradle b/samples/federated-identity-authorizationserver/samples-federated-identity-authorizationserver.gradle index e9d43819..2df8ee82 100644 --- a/samples/federated-identity-authorizationserver/samples-federated-identity-authorizationserver.gradle +++ b/samples/federated-identity-authorizationserver/samples-federated-identity-authorizationserver.gradle @@ -1,19 +1,30 @@ -apply plugin: 'io.spring.convention.spring-sample-boot' +plugins { + id "org.springframework.boot" version "2.5.12" + id "io.spring.dependency-management" version "1.0.11.RELEASE" + id "java" +} + +group = project.rootProject.group +version = project.rootProject.version +sourceCompatibility = "11" + +repositories { + mavenCentral() +} dependencies { - compile 'org.springframework.boot:spring-boot-starter-web' - compile 'org.springframework.boot:spring-boot-starter-security' - compile 'org.springframework.boot:spring-boot-starter-oauth2-client' - compile 'org.springframework.boot:spring-boot-starter-thymeleaf' - compile 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5' - compile 'org.webjars:webjars-locator-core' - compile 'org.webjars:bootstrap:3.4.1' - compile 'org.webjars:jquery:3.4.1' - compile 'org.springframework.boot:spring-boot-starter-jdbc' - compile project(':spring-security-oauth2-authorization-server') - runtimeOnly 'com.h2database:h2' - - testCompile 'org.springframework.boot:spring-boot-starter-test' - testCompile 'org.springframework.security:spring-security-test' - testCompile 'net.sourceforge.htmlunit:htmlunit' + implementation "org.springframework.boot:spring-boot-starter-web" + implementation "org.springframework.boot:spring-boot-starter-security" + implementation "org.springframework.boot:spring-boot-starter-oauth2-client" + implementation "org.springframework.boot:spring-boot-starter-thymeleaf" + implementation "org.springframework.boot:spring-boot-starter-jdbc" + implementation "org.webjars:webjars-locator-core" + implementation "org.webjars:bootstrap:3.4.1" + implementation "org.webjars:jquery:3.4.1" + implementation project(":spring-security-oauth2-authorization-server") + runtimeOnly "com.h2database:h2" +} + +tasks.named("test") { + useJUnitPlatform() } diff --git a/samples/messages-client/samples-messages-client.gradle b/samples/messages-client/samples-messages-client.gradle index 4758bd08..ac3351a4 100644 --- a/samples/messages-client/samples-messages-client.gradle +++ b/samples/messages-client/samples-messages-client.gradle @@ -1,14 +1,30 @@ -apply plugin: 'io.spring.convention.spring-sample-boot' +plugins { + id "org.springframework.boot" version "2.5.12" + id "io.spring.dependency-management" version "1.0.11.RELEASE" + id "java" +} + +group = project.rootProject.group +version = project.rootProject.version +sourceCompatibility = "11" + +repositories { + mavenCentral() +} dependencies { - compile 'org.springframework.boot:spring-boot-starter-web' - compile 'org.springframework.boot:spring-boot-starter-thymeleaf' - compile 'org.springframework.boot:spring-boot-starter-security' - compile 'org.springframework.boot:spring-boot-starter-oauth2-client' - compile 'org.springframework:spring-webflux' - compile 'io.projectreactor.netty:reactor-netty' - compile 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5' - compile 'org.webjars:webjars-locator-core' - compile 'org.webjars:bootstrap:3.4.1' - compile 'org.webjars:jquery:3.4.1' + implementation "org.springframework.boot:spring-boot-starter-web" + implementation "org.springframework.boot:spring-boot-starter-thymeleaf" + implementation "org.springframework.boot:spring-boot-starter-security" + implementation "org.springframework.boot:spring-boot-starter-oauth2-client" + implementation "org.springframework:spring-webflux" + implementation "io.projectreactor.netty:reactor-netty" + implementation "org.thymeleaf.extras:thymeleaf-extras-springsecurity5" + implementation "org.webjars:webjars-locator-core" + implementation "org.webjars:bootstrap:3.4.1" + implementation "org.webjars:jquery:3.4.1" +} + +tasks.named("test") { + useJUnitPlatform() } diff --git a/samples/messages-resource/samples-messages-resource.gradle b/samples/messages-resource/samples-messages-resource.gradle index d45f7b53..31572a0b 100644 --- a/samples/messages-resource/samples-messages-resource.gradle +++ b/samples/messages-resource/samples-messages-resource.gradle @@ -1,7 +1,23 @@ -apply plugin: 'io.spring.convention.spring-sample-boot' +plugins { + id "org.springframework.boot" version "2.5.12" + id "io.spring.dependency-management" version "1.0.11.RELEASE" + id "java" +} + +group = project.rootProject.group +version = project.rootProject.version +sourceCompatibility = "11" + +repositories { + mavenCentral() +} dependencies { - compile 'org.springframework.boot:spring-boot-starter-web' - compile 'org.springframework.boot:spring-boot-starter-security' - compile 'org.springframework.boot:spring-boot-starter-oauth2-resource-server' + implementation "org.springframework.boot:spring-boot-starter-web" + implementation "org.springframework.boot:spring-boot-starter-security" + implementation "org.springframework.boot:spring-boot-starter-oauth2-resource-server" +} + +tasks.named("test") { + useJUnitPlatform() } diff --git a/settings.gradle b/settings.gradle index 7a11a343..e86ebda7 100644 --- a/settings.gradle +++ b/settings.gradle @@ -6,23 +6,49 @@ pluginManagement { } plugins { - id "com.gradle.enterprise" version "3.8" + id "com.gradle.enterprise" version "3.9" id "io.spring.ge.conventions" version "0.0.9" } -rootProject.name = 'spring-authorization-server' - -FileTree buildFiles = fileTree(rootDir) { - include '**/*.gradle' - exclude 'build', '**/gradle', 'settings.gradle', 'buildSrc', '/build.gradle', '.*', 'out' +dependencyResolutionManagement { + repositories { + mavenCentral() + } } -buildFiles.each { File buildFile -> - String projectName = buildFile.name.replace('.gradle', ''); - String projectPath = ':' + projectName; - include projectPath - def project = findProject("${projectPath}") - project.name = projectName - project.projectDir = buildFile.parentFile - project.buildFileName = buildFile.name +rootProject.name = "spring-authorization-server" + +def buildFiles = fileTree(rootDir) { + def excludes = gradle.startParameter.projectProperties.get("excludeProjects")?.split(",") + include "**/*.gradle", "**/*.gradle.kts" + exclude "build", "**/gradle", "settings.gradle", "buildSrc", "/build.gradle", ".*", "out" + if (excludes) { + exclude excludes + } +} + +buildFiles.forEach { buildFile -> + def isDefaultName = buildFile.name == "build.gradle" || buildFile.name == "build.gradle.kts" + def isKotlin = buildFile.name.endsWith ".kts" + if (isDefaultName) { + def buildFilePath = buildFile.parentFile.absolutePath + def projectPath = buildFilePath.replace((String) rootDir.absolutePath, "").replace(File.separator, ":") + include projectPath + } else { + def projectName + if (isKotlin) { + projectName = buildFile.name.replace(".gradle.kts", "") + } else { + projectName = buildFile.name.replace(".gradle", "") + } + + + def projectPath = ":$projectName" + include projectPath + + def project = findProject(projectPath) + project.name = projectName + project.projectDir = buildFile.parentFile + project.buildFileName = buildFile.name + } }