From b259ee414d56ed29950a80d9053173ae37af1d6e Mon Sep 17 00:00:00 2001 From: John Blum Date: Fri, 9 Jun 2023 19:02:29 -0700 Subject: [PATCH] Format source code in SpringModulePlugin and AbstractSpringJavaPlugin. --- .../AbstractSpringJavaPlugin.groovy | 47 +++++++++++-------- .../convention/SpringModulePlugin.groovy | 7 ++- 2 files changed, 33 insertions(+), 21 deletions(-) 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 3c991db..e4636ea 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/AbstractSpringJavaPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/AbstractSpringJavaPlugin.groovy @@ -13,47 +13,52 @@ * License for the specific language governing permissions and limitations under * the License. */ +package io.spring.gradle.convention -package io.spring.gradle.convention; - -import io.spring.gradle.propdeps.PropDepsMavenPlugin; -import org.gradle.api.Plugin; -import org.gradle.api.Project; -import org.gradle.api.plugins.GroovyPlugin; -import org.gradle.api.plugins.JavaPlugin; -import org.gradle.api.plugins.MavenPlugin; -import org.gradle.api.plugins.PluginManager; -import org.gradle.internal.impldep.org.apache.maven.Maven; -import org.gradle.plugins.ide.eclipse.EclipseWtpPlugin; -import org.gradle.plugins.ide.idea.IdeaPlugin; -import io.spring.gradle.propdeps.PropDepsEclipsePlugin; -import io.spring.gradle.propdeps.PropDepsIdeaPlugin; -import io.spring.gradle.propdeps.PropDepsPlugin; +import io.spring.gradle.propdeps.PropDepsEclipsePlugin +import io.spring.gradle.propdeps.PropDepsIdeaPlugin +import io.spring.gradle.propdeps.PropDepsMavenPlugin +import io.spring.gradle.propdeps.PropDepsPlugin +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.plugins.GroovyPlugin +import org.gradle.api.plugins.JavaPlugin +import org.gradle.api.plugins.MavenPlugin +import org.gradle.api.plugins.PluginManager +import org.gradle.plugins.ide.eclipse.EclipseWtpPlugin +import org.gradle.plugins.ide.idea.IdeaPlugin /** * @author Rob Winch */ -public abstract class AbstractSpringJavaPlugin implements Plugin { +abstract class AbstractSpringJavaPlugin implements Plugin { @Override - public final void apply(Project project) { + final void apply(Project project) { + PluginManager pluginManager = project.getPluginManager(); + pluginManager.apply(JavaPlugin.class); pluginManager.apply(ManagementConfigurationPlugin.class); + if (project.file("src/main/groovy").exists() || project.file("src/test/groovy").exists() || project.file("src/integration-test/groovy").exists()) { pluginManager.apply(GroovyPlugin.class); } + pluginManager.apply("io.spring.convention.repository"); + pluginManager.apply(EclipseWtpPlugin); pluginManager.apply(IdeaPlugin); pluginManager.apply(PropDepsPlugin); pluginManager.apply(PropDepsEclipsePlugin); pluginManager.apply(PropDepsIdeaPlugin); + project.getPlugins().withType(MavenPlugin) { pluginManager.apply(PropDepsMavenPlugin); } + pluginManager.apply("io.spring.convention.tests-configuration"); pluginManager.apply("io.spring.convention.integration-test"); pluginManager.apply("io.spring.convention.springdependencymangement"); @@ -68,21 +73,25 @@ public abstract class AbstractSpringJavaPlugin implements Plugin { project.jar { manifest.attributes["Created-By"] = - "${System.getProperty("java.version")} (${System.getProperty("java.specification.vendor")})" + "${System.getProperty("java.version")} (${System.getProperty("java.specification.vendor")})" manifest.attributes["Implementation-Title"] = project.name manifest.attributes["Implementation-Version"] = project.version manifest.attributes["Automatic-Module-Name"] = project.name.replace('-', '.') } + additionalPlugins(project); } private void copyPropertyFromRootProjectTo(String propertyName, Project project) { + Project rootProject = project.getRootProject(); Object property = rootProject.findProperty(propertyName); - if(property != null) { + + if (property != null) { project.setProperty(propertyName, property); } } protected abstract void additionalPlugins(Project project); + } diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringModulePlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringModulePlugin.groovy index 5c509e9..a544dc0 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringModulePlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringModulePlugin.groovy @@ -13,7 +13,6 @@ * License for the specific language governing permissions and limitations under * the License. */ - package io.spring.gradle.convention; import org.gradle.api.Project @@ -28,17 +27,22 @@ class SpringModulePlugin extends AbstractSpringJavaPlugin { @Override void additionalPlugins(Project project) { + PluginManager pluginManager = project.getPluginManager(); + pluginManager.apply(JavaLibraryPlugin.class) pluginManager.apply(MavenPlugin.class); + pluginManager.apply("io.spring.convention.maven"); pluginManager.apply("io.spring.convention.artifactory"); pluginManager.apply("io.spring.convention.jacoco"); pluginManager.apply("io.spring.convention.merge"); def deployArtifacts = project.task("deployArtifacts") + deployArtifacts.group = 'Deploy tasks' deployArtifacts.description = "Deploys the artifacts to either Artifactory or Maven Central" + if (Utils.isRelease(project)) { deployArtifacts.dependsOn project.tasks.uploadArchives } @@ -46,5 +50,4 @@ class SpringModulePlugin extends AbstractSpringJavaPlugin { deployArtifacts.dependsOn project.tasks.artifactoryPublish } } - }