From de1b3e9d305b18015b14677515b072f2327eed78 Mon Sep 17 00:00:00 2001 From: Rob Winch Date: Mon, 5 Apr 2021 10:14:13 -0500 Subject: [PATCH] Remove DepencencyManagementPlugin Issue gh-9540 --- build.gradle | 2 - buildSrc/build.gradle | 5 +- .../AbstractSpringJavaPlugin.groovy | 1 - .../DependencyManagementExportTask.groovy | 61 ------------------- .../convention/RootProjectPlugin.groovy | 2 - ...ependencyManagementConventionPlugin.groovy | 54 ---------------- .../convention/SpringMavenPlugin.groovy | 13 +--- ...ntion.springdependencymangement.properties | 1 - .../gradle/dependency-management.gradle | 3 - .../showcase/sgbcs-api/sgbcs-api.gradle | 1 + .../showcase/sgbcs-core/sgbcs-core.gradle | 3 +- .../manual/spring-security-docs-manual.gradle | 2 +- .../core/saml2-service-provider-core.gradle | 2 +- .../saml2-service-provider-opensaml3.gradle | 2 +- .../saml2-service-provider-opensaml4.gradle | 2 +- 15 files changed, 13 insertions(+), 141 deletions(-) delete mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/DependencyManagementExportTask.groovy delete mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/SpringDependencyManagementConventionPlugin.groovy delete mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.springdependencymangement.properties delete mode 100644 buildSrc/src/test/resources/samples/showcase/gradle/dependency-management.gradle diff --git a/build.gradle b/build.gradle index ca65936d4e..721ba5d0d4 100644 --- a/build.gradle +++ b/build.gradle @@ -24,8 +24,6 @@ ext.snapshotBuild = version.contains("SNAPSHOT") ext.releaseBuild = version.contains("SNAPSHOT") ext.milestoneBuild = !(snapshotBuild || releaseBuild) -dependencyManagementExport.projects = subprojects.findAll { !it.name.contains('-boot') } - repositories { mavenCentral() } diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 6e45c8d767..3c9558e539 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -21,6 +21,10 @@ gradlePlugin { id = "locks" implementationClass = "lock.GlobalLockPlugin" } + managementConfiguration { + id = "io.spring.convention.management-configuration" + implementationClass = "io.spring.gradle.convention.ManagementConfigurationPlugin" + } } } @@ -37,7 +41,6 @@ dependencies { implementation 'com.github.ben-manes:gradle-versions-plugin:0.25.0' implementation 'io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.21.1' - implementation 'io.spring.gradle:dependency-management-plugin:1.0.9.RELEASE' implementation 'io.spring.gradle:docbook-reference-plugin:0.3.1' implementation 'io.spring.gradle:propdeps-plugin:0.0.10.RELEASE' implementation 'io.spring.javaformat:spring-javaformat-gradle-plugin:0.0.15' diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/AbstractSpringJavaPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/AbstractSpringJavaPlugin.groovy index 3c991dbade..55034f348f 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/AbstractSpringJavaPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/AbstractSpringJavaPlugin.groovy @@ -56,7 +56,6 @@ public abstract class AbstractSpringJavaPlugin implements Plugin { } pluginManager.apply("io.spring.convention.tests-configuration"); pluginManager.apply("io.spring.convention.integration-test"); - pluginManager.apply("io.spring.convention.springdependencymangement"); pluginManager.apply("io.spring.convention.dependency-set"); pluginManager.apply("io.spring.convention.javadoc-options"); pluginManager.apply("io.spring.convention.checkstyle"); diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/DependencyManagementExportTask.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/DependencyManagementExportTask.groovy deleted file mode 100644 index f70afc1b6b..0000000000 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/DependencyManagementExportTask.groovy +++ /dev/null @@ -1,61 +0,0 @@ -package io.spring.gradle.convention - -import org.gradle.api.Project -import org.gradle.api.artifacts.component.ModuleComponentSelector -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.Internal; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.Map; -import java.util.Properties; - -import org.gradle.api.DefaultTask; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.tasks.TaskAction; - -import io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension; - -public class DependencyManagementExportTask extends DefaultTask { - @Internal - def projects; - - @Input - String getProjectNames() { - return projects*.name - } - - @TaskAction - public void dependencyManagementExport() throws IOException { - def projects = this.projects ?: project.subprojects + project - def configurations = projects*.configurations*.findAll { ['testRuntime','integrationTestRuntime','grettyRunnerTomcat8','ajtools'].contains(it.name) } - def dependencyResults = configurations*.incoming*.resolutionResult*.allDependencies.flatten() - def moduleVersionVersions = dependencyResults.findAll { r -> r.requested instanceof ModuleComponentSelector }.collect { r-> r.selected.moduleVersion } - - def projectDependencies = projects.collect { p-> "${p.group}:${p.name}:${p.version}".toString() } as Set - def dependencies = moduleVersionVersions.collect { d -> - "${d.group}:${d.name}:${d.version}".toString() - }.sort() as Set - - println '' - println '' - println 'dependencyManagement {' - println '\tdependencies {' - dependencies.findAll { d-> !projectDependencies.contains(d)}.each { - println "\t\tdependency '$it'" - } - println '\t}' - println '}' - println '' - println '' - println 'TIP Use this to find duplicates:\n$ sort gradle/dependency-management.gradle| uniq -c | grep -v \'^\\s*1\'' - println '' - println '' - } - - void setOutputFile(File file) throws IOException { - this.output = new FileOutputStream(file); - } -} diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/RootProjectPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/RootProjectPlugin.groovy index 843d5b57cb..07fc444323 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/RootProjectPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/RootProjectPlugin.groovy @@ -57,8 +57,6 @@ class RootProjectPlugin implements Plugin { } } - project.tasks.create("dependencyManagementExport", DependencyManagementExportTask) - def finalizeDeployArtifacts = project.task("finalizeDeployArtifacts") if (Utils.isRelease(project) && project.hasProperty("ossrhUsername")) { project.ext.nexusUsername = project.ossrhUsername diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringDependencyManagementConventionPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringDependencyManagementConventionPlugin.groovy deleted file mode 100644 index 19df0e7d8f..0000000000 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringDependencyManagementConventionPlugin.groovy +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2016-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package io.spring.gradle.convention - -import io.spring.gradle.dependencymanagement.DependencyManagementPlugin -import org.gradle.api.Plugin -import org.gradle.api.Project - -/** - * Adds and configures {@link DependencyManagementPlugin}. - *

- * Additionally, if 'gradle/dependency-management.gradle' file is present it will be - * automatically applied file for configuring the dependencies. - */ -class SpringDependencyManagementConventionPlugin implements Plugin { - - static final String DEPENDENCY_MANAGEMENT_RESOURCE = "gradle/dependency-management.gradle" - - @Override - void apply(Project project) { - project.getPluginManager().apply(ManagementConfigurationPlugin) - project.getPluginManager().apply(DependencyManagementPlugin) - project.dependencyManagement { - resolutionStrategy { - cacheChangingModulesFor 0, "seconds" - } - } - File rootDir = project.rootDir - List dependencyManagementFiles = [project.rootProject.file(DEPENDENCY_MANAGEMENT_RESOURCE)] - for (File dir = project.projectDir; dir != rootDir; dir = dir.parentFile) { - dependencyManagementFiles.add(new File(dir, DEPENDENCY_MANAGEMENT_RESOURCE)) - } - dependencyManagementFiles.each { f -> - if (f.exists()) { - project.apply from: f.absolutePath - } - } - } - -} diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringMavenPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringMavenPlugin.groovy index a8d9be2705..454aebfba7 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringMavenPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringMavenPlugin.groovy @@ -1,9 +1,5 @@ package io.spring.gradle.convention -import io.spring.gradle.dependencymanagement.DependencyManagementPlugin -import io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension -import io.spring.gradle.dependencymanagement.dsl.GeneratedPomCustomizationHandler -import org.gradle.api.Action import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.XmlProvider @@ -57,9 +53,7 @@ public class SpringMavenPlugin implements Plugin { } } - project.plugins.withType(DependencyManagementPlugin) { - inlineDependencyManagement(project); - } + inlineDependencyManagement(project); def hasSigningKey = project.hasProperty("signing.keyId") || project.findProperty("signingKey") if(hasSigningKey && Utils.isRelease(project)) { @@ -70,9 +64,6 @@ public class SpringMavenPlugin implements Plugin { } private void inlineDependencyManagement(Project project) { - final DependencyManagementExtension dependencyManagement = project.getExtensions().findByType(DependencyManagementExtension.class); - dependencyManagement.generatedPomCustomization( { handler -> handler.setEnabled(false) }); - project.install { repositories.mavenInstaller { configurePomForInlineDependencies(project, pom) @@ -89,7 +80,7 @@ public class SpringMavenPlugin implements Plugin { pom.withXml { XmlProvider xml -> project.plugins.withType(JavaBasePlugin) { def dependencies = xml.asNode()?.dependencies?.dependency - def configuredDependencies = project.configurations.findAll{ it.canBeResolved }*.incoming*.resolutionResult*.allDependencies.flatten() + def configuredDependencies = project.configurations.findAll{ it.canBeResolved && it.canBeConsumed }*.incoming*.resolutionResult*.allDependencies.flatten() dependencies?.each { Node dep -> def group = dep.groupId.text() def name = dep.artifactId.text() diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.springdependencymangement.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.springdependencymangement.properties deleted file mode 100644 index 406e5690c4..0000000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.springdependencymangement.properties +++ /dev/null @@ -1 +0,0 @@ -implementation-class=io.spring.gradle.convention.SpringDependencyManagementConventionPlugin \ No newline at end of file diff --git a/buildSrc/src/test/resources/samples/showcase/gradle/dependency-management.gradle b/buildSrc/src/test/resources/samples/showcase/gradle/dependency-management.gradle deleted file mode 100644 index 9c6c3ce038..0000000000 --- a/buildSrc/src/test/resources/samples/showcase/gradle/dependency-management.gradle +++ /dev/null @@ -1,3 +0,0 @@ -dependencies { - management platform('io.spring.platform:platform-bom:Brussels-RELEASE') -} \ No newline at end of file diff --git a/buildSrc/src/test/resources/samples/showcase/sgbcs-api/sgbcs-api.gradle b/buildSrc/src/test/resources/samples/showcase/sgbcs-api/sgbcs-api.gradle index 8d0c2dab27..a5fd4ea896 100644 --- a/buildSrc/src/test/resources/samples/showcase/sgbcs-api/sgbcs-api.gradle +++ b/buildSrc/src/test/resources/samples/showcase/sgbcs-api/sgbcs-api.gradle @@ -1,6 +1,7 @@ apply plugin: 'io.spring.convention.spring-module' dependencies { + management platform('io.spring.platform:platform-bom:Brussels-RELEASE') compile 'org.springframework:spring-web' compile 'org.springframework:spring-core' testCompile 'junit:junit' diff --git a/buildSrc/src/test/resources/samples/showcase/sgbcs-core/sgbcs-core.gradle b/buildSrc/src/test/resources/samples/showcase/sgbcs-core/sgbcs-core.gradle index f4a73751bc..e5f419b337 100644 --- a/buildSrc/src/test/resources/samples/showcase/sgbcs-core/sgbcs-core.gradle +++ b/buildSrc/src/test/resources/samples/showcase/sgbcs-core/sgbcs-core.gradle @@ -1,6 +1,7 @@ apply plugin: 'io.spring.convention.spring-module' dependencies { + management platform('io.spring.platform:platform-bom:Brussels-RELEASE') optional 'ch.qos.logback:logback-classic' testCompile 'junit:junit' -} \ No newline at end of file +} diff --git a/docs/manual/spring-security-docs-manual.gradle b/docs/manual/spring-security-docs-manual.gradle index f8b83fd874..fabd140198 100644 --- a/docs/manual/spring-security-docs-manual.gradle +++ b/docs/manual/spring-security-docs-manual.gradle @@ -1,5 +1,5 @@ apply plugin: 'io.spring.convention.docs' -apply plugin: 'io.spring.convention.springdependencymangement' +apply plugin: 'io.spring.convention.management-configuration' apply plugin: 'io.spring.convention.dependency-set' apply plugin: 'io.spring.convention.repository' apply plugin: 'java' diff --git a/saml2/saml2-service-provider/core/saml2-service-provider-core.gradle b/saml2/saml2-service-provider/core/saml2-service-provider-core.gradle index 2deaee16c7..f953138415 100644 --- a/saml2/saml2-service-provider/core/saml2-service-provider-core.gradle +++ b/saml2/saml2-service-provider/core/saml2-service-provider-core.gradle @@ -10,7 +10,7 @@ buildscript { plugins { id 'java-library' id 'io.spring.convention.repository' - id 'io.spring.convention.springdependencymangement' + id 'io.spring.convention.management-configuration' id 'io.spring.convention.dependency-set' id 'io.spring.convention.checkstyle' id 'io.spring.convention.tests-configuration' diff --git a/saml2/saml2-service-provider/opensaml3/saml2-service-provider-opensaml3.gradle b/saml2/saml2-service-provider/opensaml3/saml2-service-provider-opensaml3.gradle index 71c2af9eac..e4e99292ef 100644 --- a/saml2/saml2-service-provider/opensaml3/saml2-service-provider-opensaml3.gradle +++ b/saml2/saml2-service-provider/opensaml3/saml2-service-provider-opensaml3.gradle @@ -10,7 +10,7 @@ buildscript { plugins { id 'java-library' id 'io.spring.convention.repository' - id 'io.spring.convention.springdependencymangement' + id 'io.spring.convention.management-configuration' id 'io.spring.convention.dependency-set' id 'io.spring.convention.checkstyle' id 'io.spring.convention.tests-configuration' diff --git a/saml2/saml2-service-provider/opensaml4/saml2-service-provider-opensaml4.gradle b/saml2/saml2-service-provider/opensaml4/saml2-service-provider-opensaml4.gradle index e57080b7e9..00ec92b011 100644 --- a/saml2/saml2-service-provider/opensaml4/saml2-service-provider-opensaml4.gradle +++ b/saml2/saml2-service-provider/opensaml4/saml2-service-provider-opensaml4.gradle @@ -10,7 +10,7 @@ buildscript { plugins { id 'java-library' id 'io.spring.convention.repository' - id 'io.spring.convention.springdependencymangement' + id 'io.spring.convention.management-configuration' id 'io.spring.convention.dependency-set' id 'io.spring.convention.checkstyle' id 'io.spring.convention.tests-configuration'