From 2f2c2e03133e6ed1c063fe632dce4d2e0e2b8cb7 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Thu, 30 Apr 2020 15:04:26 +0200 Subject: [PATCH] Use Spring dependency management plugin This commit introduces the Spring dependency management Gradle plugin. All dependency versions and BOMs are now managed in the root project and declared in the modules directly. --- build.gradle | 121 +++++++++++++++++---------- spring-binding/spring-binding.gradle | 15 +++- spring-faces/spring-faces.gradle | 31 ++++--- spring-webflow/spring-webflow.gradle | 55 ++++++------ 4 files changed, 142 insertions(+), 80 deletions(-) diff --git a/build.gradle b/build.gradle index 2aa63fc9..d44b82d4 100644 --- a/build.gradle +++ b/build.gradle @@ -9,14 +9,84 @@ buildscript { } } -allprojects { +plugins { + id 'io.spring.dependency-management' version '1.0.9.RELEASE' apply false +} +ext { + moduleProjects = subprojects.findAll { it.name.startsWith("spring-") } + javaProjects = subprojects - project("spring-js-resources") + withoutJclOverSlf4j = { + exclude group: "org.slf4j", name: "jcl-over-slf4j" + } +} + +allprojects { group = "org.springframework.webflow" + apply plugin: "io.spring.dependency-management" apply plugin: "propdeps" apply plugin: "java" apply from: "${rootProject.projectDir}/ide.gradle" + dependencyManagement { + imports { + mavenBom "org.springframework:spring-framework-bom:5.2.6.RELEASE" + mavenBom "org.springframework.security:spring-security-bom:5.3.1.RELEASE" + mavenBom "org.junit:junit-bom:5.6.2" + } + dependencies { + dependency "javax.servlet:javax.servlet-api:3.1.0" + dependency "javax.servlet:jstl:1.2" + dependency "javax.servlet.jsp:javax.servlet.jsp-api:2.3.2-b02" + dependency "javax.el:javax.el-api:3.0.1-b06" + dependency "javax.validation:validation-api:2.0.1.Final" + dependencySet(group: 'org.hibernate', version: '5.4.14.Final') { + entry 'hibernate-core' + entry 'hibernate-entitymanager' + } + dependency "org.hibernate:hibernate-validator:6.1.4.Final" + dependencySet(group: 'com.sun.faces', version: '2.2.16') { + entry 'jsf-api' + entry 'jsf-impl' + } + dependencySet(group: 'org.apache.tiles', version: '3.0.8') { + entry 'tiles-api' + entry('tiles-core', withoutJclOverSlf4j) + entry('tiles-servlet', withoutJclOverSlf4j) + entry('tiles-jsp', withoutJclOverSlf4j) + entry('tiles-el', withoutJclOverSlf4j) + entry('tiles-extras') { + exclude group: "org.springframework", name: "spring-web" + } + } + dependency "org.apache.myfaces.core:myfaces-impl:2.2.12" + dependency "com.sun.facelets:jsf-facelets:1.1.14" + dependency "org.hsqldb:hsqldb:2.5.0" + + dependencySet(group: 'org.apache.logging.log4j', version: '2.13.2') { + entry 'log4j-api' + entry 'log4j-core' + entry 'log4j-slf4j-impl' + entry 'log4j-jul' + } + dependency "org.slf4j:slf4j-api:1.7.30" + + dependency("junit:junit:4.13") { + exclude group: "org.hamcrest", name: "hamcrest-core" + } + dependency "org.easymock:easymock:4.2" + dependency "org.hamcrest:hamcrest:2.1" + dependency "org.apache.tomcat:tomcat-jasper-el:9.0.34" + dependency "org.apache.myfaces.test:myfaces-test22:1.0.8" + } + generatedPomCustomization { + enabled = false + } + resolutionStrategy { + cacheChangingModulesFor 0, "seconds" + } + } repositories { mavenCentral() if (!version.endsWith('RELEASE')) { @@ -26,6 +96,13 @@ allprojects { maven { url "https://repo.spring.io/snapshot" } } } + configurations.all { + resolutionStrategy { + cacheChangingModulesFor 0, "seconds" + cacheDynamicVersionsFor 0, "seconds" + } + } + } subprojects { subproject -> @@ -52,47 +129,7 @@ subprojects { subproject -> } } -configure(subprojects.findAll { - it.name != "spring-build-src" && it.name != "spring-js-resources"}) { subproject -> - - subproject.ext { - springVersion = "5.2.6.RELEASE" - springSecurityVersion = "5.3.1.RELEASE" - servletVersion = "3.1.0" - hibernate5Version = "5.4.14.Final" - tiles3Version = "3.0.8" - log4jVersion = "2.13.2" - junit5Version = "5.6.2" - } - - configurations.all { - // Check for updates every build - resolutionStrategy.cacheChangingModulesFor 0, 'seconds' - - // Consistent slf4j version (e.g. clashes between slf4j versions) - resolutionStrategy.eachDependency { DependencyResolveDetails details -> - if (details.requested.group == 'org.slf4j') { - details.useVersion "1.7.25" - } - } - - exclude group: "org.slf4j", module: "jcl-over-slf4j" - } - - dependencies { - compile("org.springframework:spring-beans:$springVersion") - compile("org.springframework:spring-context:$springVersion") - compile("org.springframework:spring-core:$springVersion") - compile("org.springframework:spring-expression:$springVersion") - compileOnly("javax.el:javax.el-api:3.0.1-b06") - testCompile("org.junit.jupiter:junit-jupiter:${junit5Version}") - testCompile("org.hamcrest:hamcrest-all:1.3") - testCompile("org.easymock:easymock:4.2") - testCompile("org.apache.tomcat:tomcat-jasper-el:9.0.34") - testRuntime("org.apache.logging.log4j:log4j-core:${log4jVersion}") - testRuntime("org.apache.logging.log4j:log4j-slf4j-impl:${log4jVersion}") - testRuntime("org.apache.logging.log4j:log4j-jul:${log4jVersion}") - } +configure(javaProjects) { javaProject -> test { useJUnitPlatform() diff --git a/spring-binding/spring-binding.gradle b/spring-binding/spring-binding.gradle index e4a088c1..9d837b1d 100644 --- a/spring-binding/spring-binding.gradle +++ b/spring-binding/spring-binding.gradle @@ -1 +1,14 @@ -description = "Spring Binding" \ No newline at end of file +description = "Spring Binding" + +dependencies { + compile("org.springframework:spring-context") + + compileOnly("javax.el:javax.el-api") + testCompile("org.junit.jupiter:junit-jupiter") + testCompile("org.hamcrest:hamcrest") + testCompile("org.easymock:easymock") + testCompile("org.apache.tomcat:tomcat-jasper-el") + testRuntime("org.apache.logging.log4j:log4j-core") + testRuntime("org.apache.logging.log4j:log4j-slf4j-impl") + testRuntime("org.apache.logging.log4j:log4j-jul") +} \ No newline at end of file diff --git a/spring-faces/spring-faces.gradle b/spring-faces/spring-faces.gradle index b6a4daad..b2150249 100644 --- a/spring-faces/spring-faces.gradle +++ b/spring-faces/spring-faces.gradle @@ -3,16 +3,23 @@ description = "Spring Faces" dependencies { compile(project(":spring-binding")) compile(project(":spring-webflow")) - compile("org.springframework:spring-web:$springVersion") - compile("org.springframework:spring-webmvc:$springVersion") - provided("javax.servlet:javax.servlet-api:$servletVersion") - provided("com.sun.faces:jsf-api:2.2.16") - provided("com.sun.faces:jsf-impl:2.2.16") - provided("org.apache.myfaces.core:myfaces-impl:2.2.12") - optional("com.sun.facelets:jsf-facelets:1.1.14") - optional("org.springframework.security:spring-security-core:$springSecurityVersion") - optional("org.springframework.security:spring-security-web:$springSecurityVersion") - optional("org.springframework.security:spring-security-taglibs:$springSecurityVersion") - testCompile("org.apache.myfaces.test:myfaces-test22:1.0.8") - testCompile("org.springframework:spring-test:$springVersion") + compile("org.springframework:spring-web") + compile("org.springframework:spring-webmvc") + compileOnly("javax.el:javax.el-api") + provided("javax.servlet:javax.servlet-api") + provided("com.sun.faces:jsf-api") + provided("com.sun.faces:jsf-impl") + provided("org.apache.myfaces.core:myfaces-impl") + optional("com.sun.facelets:jsf-facelets") + optional("org.springframework.security:spring-security-core") + optional("org.springframework.security:spring-security-web") + optional("org.springframework.security:spring-security-taglibs") + testCompile("org.junit.jupiter:junit-jupiter") + testCompile("org.easymock:easymock") + testCompile("org.apache.myfaces.test:myfaces-test22") + testCompile("org.apache.tomcat:tomcat-jasper-el") + testCompile("org.springframework:spring-test") + testRuntime("org.apache.logging.log4j:log4j-core") + testRuntime("org.apache.logging.log4j:log4j-slf4j-impl") + testRuntime("org.apache.logging.log4j:log4j-jul") } diff --git a/spring-webflow/spring-webflow.gradle b/spring-webflow/spring-webflow.gradle index e8b3b1a3..1afcee8b 100644 --- a/spring-webflow/spring-webflow.gradle +++ b/spring-webflow/spring-webflow.gradle @@ -2,29 +2,34 @@ description = "Spring Web Flow" dependencies { compile(project(":spring-binding")) - compile("org.springframework:spring-web:$springVersion") - compile("org.springframework:spring-webmvc:$springVersion") - provided("javax.servlet:javax.servlet-api:$servletVersion") - optional("org.hibernate:hibernate-core:$hibernate5Version") - optional("org.springframework.security:spring-security-core:$springSecurityVersion") - optional("org.springframework:spring-orm:$springVersion") - optional("org.springframework:spring-tx:$springVersion") - optional("org.apache.tiles:tiles-api:$tiles3Version") - optional("org.apache.tiles:tiles-core:$tiles3Version") - optional("org.apache.tiles:tiles-servlet:$tiles3Version") - optional("org.apache.tiles:tiles-jsp:$tiles3Version") - optional("org.apache.tiles:tiles-el:$tiles3Version") - optional("org.apache.tiles:tiles-extras:$tiles3Version") { - exclude group: "org.springframework", module: "spring-web" - } - provided("junit:junit:4.12") - testCompile("org.springframework:spring-aop:$springVersion") - testCompile("org.springframework:spring-jdbc:$springVersion") - testCompile("org.springframework:spring-test:$springVersion") - testCompile("javax.validation:validation-api:2.0.1.Final") - testCompile("org.hibernate:hibernate-entitymanager:$hibernate5Version") - testCompile("org.hibernate:hibernate-validator:6.1.4.Final") - testCompile("org.hsqldb:hsqldb:2.5.0") - testCompile("javax.servlet.jsp:javax.servlet.jsp-api:2.3.2-b02") - testCompile("javax.servlet:jstl:1.2") + compile("org.springframework:spring-web") + compile("org.springframework:spring-webmvc") + compileOnly("javax.el:javax.el-api") + provided("javax.servlet:javax.servlet-api") + optional("org.hibernate:hibernate-core") + optional("org.springframework.security:spring-security-core") + optional("org.springframework:spring-orm") + optional("org.springframework:spring-tx") + optional("org.apache.tiles:tiles-api") + optional("org.apache.tiles:tiles-core") + optional("org.apache.tiles:tiles-servlet") + optional("org.apache.tiles:tiles-jsp") + optional("org.apache.tiles:tiles-el") + optional("org.apache.tiles:tiles-extras") + provided("junit:junit") + testCompile("org.junit.jupiter:junit-jupiter") + testCompile("org.easymock:easymock") + testCompile("org.apache.tomcat:tomcat-jasper-el") + testCompile("org.springframework:spring-aop") + testCompile("org.springframework:spring-jdbc") + testCompile("org.springframework:spring-test") + testCompile("javax.validation:validation-api") + testCompile("org.hibernate:hibernate-entitymanager") + testCompile("org.hibernate:hibernate-validator") + testCompile("org.hsqldb:hsqldb") + testCompile("javax.servlet.jsp:javax.servlet.jsp-api") + testCompile("javax.servlet:jstl") + testRuntime("org.apache.logging.log4j:log4j-core") + testRuntime("org.apache.logging.log4j:log4j-slf4j-impl") + testRuntime("org.apache.logging.log4j:log4j-jul") } \ No newline at end of file