瀏覽代碼

Upgrade build to Gradle 7

Closes gh-572
Steve Riesenberg 3 年之前
父節點
當前提交
72c2e15487

+ 8 - 42
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/' }
-	}
-}
-
-apply plugin: 'io.spring.nohttp'
-apply plugin: 'locks'
-apply plugin: 'io.spring.convention.root'
-
-group = 'org.springframework.security'
-description = 'Spring Authorization Server'
-
-ext.snapshotBuild = version.contains("SNAPSHOT")
-
-repositories {
-	mavenCentral()
+plugins {
+	id "io.spring.convention.root"
 }
 
-dependencyManagementExport.projects = subprojects.findAll { !it.name.contains('-boot') }
+group = "org.springframework.security"
+description = "Spring Authorization Server"
 
-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")
-}

+ 25 - 0
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"
+	}
+}

+ 20 - 20
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()
-}
+tasks.named("test") {
+	useJUnitPlatform()
+}

+ 3 - 0
docs/spring-authorization-server-docs.gradle

@@ -0,0 +1,3 @@
+plugins {
+	id "io.spring.convention.docs"
+}

+ 6 - 1
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

+ 0 - 38
gradle/dependency-management.gradle

@@ -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"
-	}
-}

+ 1 - 1
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

+ 27 - 23
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'
-}
+	testRuntimeOnly "org.hsqldb:hsqldb"
 
-jacoco {
-	toolVersion = '0.8.6'
+	provided "javax.servlet:javax.servlet-api"
 }

+ 28 - 9
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')
-
-	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-thymeleaf"
+	implementation "org.springframework.boot:spring-boot-starter-security"
+	implementation project(":spring-security-oauth2-authorization-server")
+
+	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()
 }

+ 29 - 10
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'
-
-	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-jdbc"
+	implementation project(":spring-security-oauth2-authorization-server")
+	runtimeOnly "com.h2database:h2"
+
+	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()
 }

+ 26 - 15
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'
+	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"
+}
 
-	testCompile 'org.springframework.boot:spring-boot-starter-test'
-	testCompile 'org.springframework.security:spring-security-test'
-	testCompile 'net.sourceforge.htmlunit:htmlunit'
+tasks.named("test") {
+	useJUnitPlatform()
 }

+ 27 - 11
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()
 }

+ 20 - 4
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()
 }

+ 39 - 13
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'
+dependencyResolutionManagement {
+	repositories {
+		mavenCentral()
+	}
+}
 
-FileTree buildFiles = fileTree(rootDir) {
-	include '**/*.gradle'
-	exclude 'build', '**/gradle', 'settings.gradle', 'buildSrc', '/build.gradle', '.*', 'out'
+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.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
+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
+	}
 }