Remove DepencencyManagementPlugin

Issue gh-9540
This commit is contained in:
Rob Winch 2021-04-05 10:14:13 -05:00
parent 0f0e8eded4
commit de1b3e9d30
15 changed files with 13 additions and 141 deletions

View File

@ -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()
}

View File

@ -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'

View File

@ -56,7 +56,6 @@ public abstract class AbstractSpringJavaPlugin implements Plugin<Project> {
}
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");

View File

@ -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);
}
}

View File

@ -57,8 +57,6 @@ class RootProjectPlugin implements Plugin<Project> {
}
}
project.tasks.create("dependencyManagementExport", DependencyManagementExportTask)
def finalizeDeployArtifacts = project.task("finalizeDeployArtifacts")
if (Utils.isRelease(project) && project.hasProperty("ossrhUsername")) {
project.ext.nexusUsername = project.ossrhUsername

View File

@ -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}.
* <p>
* Additionally, if 'gradle/dependency-management.gradle' file is present it will be
* automatically applied file for configuring the dependencies.
*/
class SpringDependencyManagementConventionPlugin implements Plugin<Project> {
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<File> 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
}
}
}
}

View File

@ -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> {
}
}
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<Project> {
}
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<Project> {
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()

View File

@ -1 +0,0 @@
implementation-class=io.spring.gradle.convention.SpringDependencyManagementConventionPlugin

View File

@ -1,3 +0,0 @@
dependencies {
management platform('io.spring.platform:platform-bom:Brussels-RELEASE')
}

View File

@ -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'

View File

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

View File

@ -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'

View File

@ -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'

View File

@ -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'

View File

@ -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'