From 916832f01ad58e8a9c0b9c199d91ff0cad60cfb7 Mon Sep 17 00:00:00 2001 From: Gareth Clay Date: Mon, 28 Nov 2022 15:47:24 +0000 Subject: [PATCH] Use Gradle-native BOM support for dependency management --- README.adoc | 4 +- build.gradle | 40 +++--------------- credhub-server/docker-compose.yml | 6 +-- publish-maven.gradle | 10 ++--- settings.gradle | 33 +++++++++------ spring-credhub-core/build.gradle | 33 ++++++--------- spring-credhub-demo/build.gradle | 42 ++++--------------- spring-credhub-docs/build.gradle | 15 +++---- spring-credhub-integration-tests/build.gradle | 26 +++--------- .../build.gradle | 24 +++-------- spring-credhub-starter/build.gradle | 14 +++---- 11 files changed, 79 insertions(+), 168 deletions(-) diff --git a/README.adoc b/README.adoc index f9d77bd..029fa2b 100644 --- a/README.adoc +++ b/README.adoc @@ -19,7 +19,7 @@ To build the source you will need to install JDK 17. Spring CredHub uses Gradle for most build-related activities, and you should be able to get off the ground quite quickly by cloning the project you are interested in and typing ---- -$ ./gradlew install +$ ./gradlew build ---- === Working with the code @@ -27,5 +27,3 @@ $ ./gradlew install If you don't have an IDE preference we would recommend that you use https://www.springsource.com/developer/sts[Spring Tools Suite] or https://eclipse.org[Eclipse] when working with the code. - - diff --git a/build.gradle b/build.gradle index b9cc32e..49dec17 100644 --- a/build.gradle +++ b/build.gradle @@ -16,9 +16,8 @@ plugins { id 'checkstyle' - id 'io.spring.nohttp' version '0.0.10' - id 'io.spring.dependency-management' version '1.0.15.RELEASE' - id 'io.spring.javaformat' version '0.0.35' + id 'io.spring.nohttp' + id 'io.spring.javaformat' } description = "Spring CredHub" @@ -27,18 +26,8 @@ ext { springVersion = "6.0.0" springBootVersion = "3.0.0-RC2" springSecurityVersion = "6.0.0-RC2" - reactorVersion = "2020.0.24" - - okHttp3Version = "4.9.3" - httpClient5Version = "5.1.3" - nettyVersion = "4.1.84.Final" - - junitVersion = "5.7.2" - mockitoVersion = "3.9.0" - assertJVersion = "3.19.0" - javadocLinks = [ - "https://docs.oracle.com/javase/8/docs/api/", + "https://docs.oracle.com/javase/17/docs/api/", 'https://docs.spring.io/spring/docs/current/javadoc-api/', ] as String[] } @@ -47,24 +36,7 @@ configure(allprojects) { apply plugin: 'java' apply plugin: 'eclipse' - apply plugin: "io.spring.dependency-management" - group = 'org.springframework.credhub' - - repositories { - mavenCentral() - maven { url 'https://repo.spring.io/release' } - } - if (version =~ /((-M|-RC)[0-9]+|-SNAPSHOT)$/) { - repositories { - maven { url 'https://repo.spring.io/milestone' } - } - } - if (version.endsWith('-SNAPSHOT')) { - repositories { - maven { url 'https://repo.spring.io/snapshot' } - } - } } configure(allprojects) { @@ -119,14 +91,14 @@ configure(publishedProjects) { } subprojects { - sourceCompatibility = 17 - targetCompatibility = 17 - tasks.withType(JavaCompile) { options.encoding = 'UTF-8' } java { + toolchain { + languageVersion = JavaLanguageVersion.of(17) + } registerFeature('reactive') { usingSourceSet(sourceSets.main) } diff --git a/credhub-server/docker-compose.yml b/credhub-server/docker-compose.yml index 51ba89b..70d37b8 100644 --- a/credhub-server/docker-compose.yml +++ b/credhub-server/docker-compose.yml @@ -1,12 +1,10 @@ -version: '2' - services: uaa: image: pcfseceng/uaa volumes: - ./uaa.yml:/uaa/uaa.yml ports: - - 8080:8080 + - "8080:8080" restart: always credhub: @@ -19,4 +17,4 @@ services: - uaa environment: UAA_URL: http://localhost:8080/uaa - UAA_INTERNAL_URL: http://uaa:8080/uaa \ No newline at end of file + UAA_INTERNAL_URL: http://uaa:8080/uaa diff --git a/publish-maven.gradle b/publish-maven.gradle index 3c449da..b732835 100644 --- a/publish-maven.gradle +++ b/publish-maven.gradle @@ -59,6 +59,11 @@ publishing { email = "sfrederick@pivotal.io" } } + withXml { + def pomNode = asNode() + def dependencyManagementNode = pomNode.get('dependencyManagement') + if (dependencyManagementNode) pomNode.remove(dependencyManagementNode) + } } // Published pom will use fully-qualified dependency versions and no BOMs @@ -70,11 +75,6 @@ publishing { fromResolutionResult() } } - pom.withXml { - def dependencyManagementNode = asNode().get("dependencyManagement") - asNode().remove(dependencyManagementNode) - } } } } - diff --git a/settings.gradle b/settings.gradle index 16918a2..94517da 100644 --- a/settings.gradle +++ b/settings.gradle @@ -15,19 +15,34 @@ */ pluginManagement { + plugins { + id 'io.spring.nohttp' version '0.0.10' + id 'io.spring.javaformat' version '0.0.35' + id 'org.asciidoctor.jvm.convert' version '3.3.2' + id 'org.springframework.boot' version '3.0.0' + } repositories { gradlePluginPortal() - mavenCentral() maven { url "https://repo.spring.io/plugins-release" } if (version.endsWith('-SNAPSHOT')) { maven { url "https://repo.spring.io/plugins-snapshot" } } } - resolutionStrategy { - eachPlugin { - if (requested.id.id == "io.spring.javaformat") { - useModule "io.spring.javaformat:spring-javaformat-gradle-plugin:${requested.version}" - } +} + +dependencyResolutionManagement { + repositories { + mavenCentral() + maven { url 'https://repo.spring.io/release' } + } + if (version =~ /((-M|-RC)[0-9]+|-SNAPSHOT)$/) { + repositories { + maven { url 'https://repo.spring.io/milestone' } + } + } + if (version.endsWith('-SNAPSHOT')) { + repositories { + maven { url 'https://repo.spring.io/snapshot' } } } } @@ -39,9 +54,3 @@ include ':spring-credhub-starter' include ':spring-credhub-integration-tests' include ':spring-credhub-reactive-integration-tests' include ':spring-credhub-docs' - -project(':spring-credhub-core').projectDir = "$rootDir/spring-credhub-core" as File -project(':spring-credhub-starter').projectDir = "$rootDir/spring-credhub-starter" as File -project(':spring-credhub-integration-tests').projectDir = "$rootDir/spring-credhub-integration-tests" as File -project(':spring-credhub-reactive-integration-tests').projectDir = "$rootDir/spring-credhub-reactive-integration-tests" as File -project(':spring-credhub-docs').projectDir = "$rootDir/spring-credhub-docs" as File diff --git a/spring-credhub-core/build.gradle b/spring-credhub-core/build.gradle index 38be78b..b273867 100644 --- a/spring-credhub-core/build.gradle +++ b/spring-credhub-core/build.gradle @@ -14,43 +14,36 @@ * limitations under the License. */ -dependencyManagement { - imports { - mavenBom "org.springframework:spring-framework-bom:${springVersion}" - mavenBom "org.springframework.security:spring-security-bom:${springSecurityVersion}" - mavenBom "io.projectreactor:reactor-bom:${reactorVersion}" - } -} - description = 'Spring CredHub Core' dependencies { + api(platform("org.springframework.boot:spring-boot-dependencies:${springBootVersion}")) api("org.springframework:spring-core") api("org.springframework:spring-beans") api("org.springframework:spring-context") api("org.springframework:spring-web") - api("com.fasterxml.jackson.core:jackson-databind:2.13.3") + api("com.fasterxml.jackson.core:jackson-databind") + api("org.springframework.security:spring-security-oauth2-client") { + exclude module: "spring-security-web" + } reactiveImplementation("org.springframework:spring-webflux") reactiveImplementation("io.projectreactor.netty:reactor-netty") - api("org.springframework.security:spring-security-oauth2-client") { - exclude module: "spring-security-web" - } securityImplementation("org.springframework.security:spring-security-config") - httpclientImplementation("org.apache.httpcomponents.client5:httpclient5:${httpClient5Version}") { + httpclientImplementation("org.apache.httpcomponents.client5:httpclient5") { exclude(group: 'commons-logging', module: 'commons-logging') } - okhttpImplementation("com.squareup.okhttp3:okhttp:${okHttp3Version}") + okhttpImplementation("com.squareup.okhttp3:okhttp") testImplementation("org.springframework:spring-test") testImplementation("io.projectreactor:reactor-test") - testImplementation("org.junit.jupiter:junit-jupiter-api:${junitVersion}") - testImplementation("org.junit.jupiter:junit-jupiter-params:${junitVersion}") - testImplementation("org.mockito:mockito-core:${mockitoVersion}") - testImplementation("org.mockito:mockito-junit-jupiter:${mockitoVersion}") - testImplementation("org.assertj:assertj-core:${assertJVersion}") - testImplementation("com.jayway.jsonpath:json-path:2.4.0") + testImplementation("org.junit.jupiter:junit-jupiter-api") + testImplementation("org.junit.jupiter:junit-jupiter-params") + testImplementation("org.mockito:mockito-core") + testImplementation("org.mockito:mockito-junit-jupiter") + testImplementation("org.assertj:assertj-core") + testImplementation("com.jayway.jsonpath:json-path") } diff --git a/spring-credhub-demo/build.gradle b/spring-credhub-demo/build.gradle index 6e4a123..a3a02c6 100644 --- a/spring-credhub-demo/build.gradle +++ b/spring-credhub-demo/build.gradle @@ -14,40 +14,16 @@ * limitations under the License. */ +plugins { + id 'org.springframework.boot' version '3.0.0' + id 'eclipse' +} + description = 'Spring CredHub Demo' -buildscript { - ext { - springBootVersion = "3.0.0-RC2" - } - - dependencies { - classpath('io.spring.gradle:dependency-management-plugin:1.0.11.RELEASE') - classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") - } - - repositories { - mavenCentral() - maven { url "https://repo.spring.io/plugins-release" } - } -} - -apply plugin: 'java' -apply plugin: 'eclipse' - -apply plugin: 'io.spring.dependency-management' -apply plugin: 'org.springframework.boot' - dependencies { - compile("org.springframework.boot:spring-boot-starter-web") - compile("org.springframework.boot:spring-boot-starter-actuator") - compile("org.springframework.boot:spring-boot-starter-security") - - compile("org.springframework.credhub:spring-credhub-starter:2.2.0-SNAPSHOT") -} - -repositories { - mavenCentral() - maven { url "https://repo.spring.io/snapshot" } - maven { url "https://repo.spring.io/milestone" } + implementation("org.springframework.credhub:spring-credhub-starter:3.0.0-SNAPSHOT") + implementation("org.springframework.boot:spring-boot-starter-web") + implementation("org.springframework.boot:spring-boot-starter-actuator") + implementation("org.springframework.boot:spring-boot-starter-security") } diff --git a/spring-credhub-docs/build.gradle b/spring-credhub-docs/build.gradle index fb7b898..a8f8598 100644 --- a/spring-credhub-docs/build.gradle +++ b/spring-credhub-docs/build.gradle @@ -14,15 +14,11 @@ * limitations under the License. */ -plugins { - id 'org.asciidoctor.jvm.convert' version '3.3.2' -} +import org.springframework.boot.gradle.plugin.SpringBootPlugin -dependencyManagement { - imports { - mavenBom "org.springframework.boot:spring-boot-dependencies:${springBootVersion}" - mavenBom "io.projectreactor:reactor-bom:${reactorVersion}" - } +plugins { + id 'org.asciidoctor.jvm.convert' + id 'org.springframework.boot' apply false } description = "Spring CredHub Documentation" @@ -32,7 +28,8 @@ configurations { } dependencies { - implementation project(":spring-credhub-core") + implementation(platform(SpringBootPlugin.BOM_COORDINATES)) + implementation(project(":spring-credhub-core")) implementation("io.projectreactor:reactor-core") implementation("org.springframework.boot:spring-boot-autoconfigure") diff --git a/spring-credhub-integration-tests/build.gradle b/spring-credhub-integration-tests/build.gradle index 1e6902b..e3e057c 100644 --- a/spring-credhub-integration-tests/build.gradle +++ b/spring-credhub-integration-tests/build.gradle @@ -14,22 +14,12 @@ * limitations under the License. */ -description = 'Spring CredHub Integration Tests' - -buildscript { - dependencies { - classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}" - } - - repositories { - mavenCentral() - maven { url "https://repo.spring.io/plugins-release" } - } +plugins { + id 'org.springframework.boot' + id 'eclipse' } -apply plugin: 'java' -apply plugin: 'eclipse' -apply plugin: 'org.springframework.boot' +description = 'Spring CredHub Integration Tests' dependencies { testImplementation(project(":spring-credhub-starter")) @@ -43,11 +33,11 @@ dependencies { if (project.hasProperty("useOkHttp3")) { testImplementation("com.squareup.okhttp3:okhttp") } else { - testImplementation("org.apache.httpcomponents.client5:httpclient5:${httpClient5Version}") + testImplementation("org.apache.httpcomponents.client5:httpclient5") } testImplementation("org.springframework.boot:spring-boot-starter-test") - testImplementation("org.assertj:assertj-core:${assertJVersion}") + testImplementation("org.assertj:assertj-core") } test { @@ -61,7 +51,3 @@ bootJar { } configurations.archives.artifacts.clear() - -repositories { - mavenCentral() -} diff --git a/spring-credhub-reactive-integration-tests/build.gradle b/spring-credhub-reactive-integration-tests/build.gradle index f89c23b..2e77205 100644 --- a/spring-credhub-reactive-integration-tests/build.gradle +++ b/spring-credhub-reactive-integration-tests/build.gradle @@ -14,22 +14,12 @@ * limitations under the License. */ -description = 'Spring CredHub Reactive Integration Tests' - -buildscript { - dependencies { - classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}" - } - - repositories { - mavenCentral() - maven { url "https://repo.spring.io/plugins-release" } - } +plugins { + id 'org.springframework.boot' + id 'eclipse' } -apply plugin: 'java' -apply plugin: 'eclipse' -apply plugin: 'org.springframework.boot' +description = 'Spring CredHub Reactive Integration Tests' dependencies { testImplementation(project(":spring-credhub-starter")) @@ -43,7 +33,7 @@ dependencies { testImplementation("org.springframework.boot:spring-boot-starter-test") testImplementation("io.projectreactor:reactor-test") - testImplementation("org.assertj:assertj-core:${assertJVersion}") + testImplementation("org.assertj:assertj-core") } test { @@ -57,7 +47,3 @@ bootJar { } configurations.archives.artifacts.clear() - -repositories { - mavenCentral() -} \ No newline at end of file diff --git a/spring-credhub-starter/build.gradle b/spring-credhub-starter/build.gradle index 45c73f9..a41021a 100644 --- a/spring-credhub-starter/build.gradle +++ b/spring-credhub-starter/build.gradle @@ -14,15 +14,10 @@ * limitations under the License. */ -dependencyManagement { - imports { - mavenBom "org.springframework.boot:spring-boot-dependencies:${springBootVersion}" - } -} - description = 'Spring CredHub Starter' dependencies { + api(platform("org.springframework.boot:spring-boot-dependencies:${springBootVersion}")) api(project(':spring-credhub-core')) api("org.springframework.boot:spring-boot-autoconfigure") @@ -31,15 +26,16 @@ dependencies { securityImplementation("org.springframework.security:spring-security-config") securityImplementation("org.springframework.security:spring-security-oauth2-client") - httpclientImplementation("org.apache.httpcomponents.client5:httpclient5:${httpClient5Version}") { + httpclientImplementation("org.apache.httpcomponents.client5:httpclient5") { exclude(group: 'commons-logging', module: 'commons-logging') } - okhttpImplementation("com.squareup.okhttp3:okhttp:${okHttp3Version}") + okhttpImplementation("com.squareup.okhttp3:okhttp") + annotationProcessor(platform("org.springframework.boot:spring-boot-dependencies:${springBootVersion}")) annotationProcessor("org.springframework.boot:spring-boot-configuration-processor") testImplementation("org.springframework.boot:spring-boot-starter-test") testImplementation("org.springframework.boot:spring-boot-starter-web") - testImplementation("org.assertj:assertj-core:${assertJVersion}") + testImplementation("org.assertj:assertj-core") }