diff --git a/buildSrc/src/main/groovy/io/spring/gradle/IncludeRepoTask.groovy b/buildSrc/src/main/groovy/io/spring/gradle/IncludeRepoTask.groovy deleted file mode 100644 index b549ff7..0000000 --- a/buildSrc/src/main/groovy/io/spring/gradle/IncludeRepoTask.groovy +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright 2002-2021 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 - -import groovy.transform.CompileStatic -import groovy.transform.TypeChecked -import groovy.transform.TypeCheckingMode -import org.gradle.api.DefaultTask -import org.gradle.api.Task -import org.gradle.api.provider.Property -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.OutputDirectory -import org.gradle.api.tasks.TaskAction - -/** - * Checkout a project template from a git repository. - * - * @author Marcus Da Coregio - */ -@CompileStatic -abstract class IncludeRepoTask extends DefaultTask { - - private static final String DEFAULT_URI_PREFIX = 'https://github.com/' - - /** - * Git repository to use. Will be prefixed with {@link #DEFAULT_URI_PREFIX} if it isn't already - * @return - */ - @Input - abstract Property getRepository(); - - /** - * Git reference to use. - */ - @Input - abstract Property getRef() - - /** - * Directory where the project template should be copied. - */ - @OutputDirectory - final File outputDirectory = project.file("$project.buildDir/$name") - - @TaskAction - void checkoutAndCopy() { - outputDirectory.deleteDir() - File checkoutDir = checkout(this, getRemoteUri(), ref.get()) - moveToOutputDir(checkoutDir, outputDirectory) - } - - private static File cleanTemporaryDir(Task task, File tmpDir) { - if (tmpDir.exists()) { - task.project.delete(tmpDir) - } - return tmpDir - } - - static File checkout(Task task, String remoteUri, String ref) { - checkout(task, remoteUri, ref, task.getTemporaryDir()) - } - - @TypeChecked(TypeCheckingMode.SKIP) - static File checkout(Task task, String remoteUri, String ref, File checkoutDir) { - cleanTemporaryDir(task, checkoutDir) - task.project.exec { - commandLine = ["git", "clone", "--no-checkout", remoteUri, checkoutDir.absolutePath] - errorOutput = System.err - } - task.project.exec { - commandLine = ["git", "checkout", ref] - workingDir = checkoutDir - errorOutput = System.err - } - return checkoutDir - } - - private static void moveToOutputDir(File tmpDir, File outputDirectory) { - File baseDir = tmpDir - baseDir.renameTo(outputDirectory) - } - - private String getRemoteUri() { - String remoteUri = this.repository.get() - if (remoteUri.startsWith(DEFAULT_URI_PREFIX)) { - return remoteUri - } - return DEFAULT_URI_PREFIX + remoteUri - } -} 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 9d09a31..0ec21f2 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/AbstractSpringJavaPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/AbstractSpringJavaPlugin.groovy @@ -28,7 +28,12 @@ import org.springframework.gradle.propdeps.PropDepsIdeaPlugin import org.springframework.gradle.propdeps.PropDepsPlugin /** + * Base Gradle API Plugin for all Spring Java project Gradle Plugins. + * * @author Rob Winch + * @author John Blum + * @see org.gradle.api.Plugin + * @see org.gradle.api.Project */ abstract class AbstractSpringJavaPlugin implements Plugin { diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/ArtifactoryPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/ArtifactoryPlugin.groovy index 6e750b5..16810d5 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/ArtifactoryPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/ArtifactoryPlugin.groovy @@ -13,26 +13,33 @@ * License for the specific language governing permissions and limitations under * the License. */ - package io.spring.gradle.convention import org.gradle.api.Plugin import org.gradle.api.Project +/** + * @author Rob Winch + * @author John Blum + */ class ArtifactoryPlugin implements Plugin { @Override void apply(Project project) { + project.plugins.apply('com.jfrog.artifactory') - String name = Utils.getProjectName(project); + boolean isSnapshot = Utils.isSnapshot(project); boolean isMilestone = Utils.isMilestone(project); + project.artifactory { contextUrl = 'https://repo.spring.io' publish { repository { - repoKey = isSnapshot ? 'libs-snapshot-local' : isMilestone ? 'libs-milestone-local' : 'libs-release-local' - if(project.hasProperty('artifactoryUsername')) { + repoKey = isSnapshot ? 'libs-snapshot-local' + : isMilestone ? 'libs-milestone-local' + : 'libs-release-local' + if (project.hasProperty('artifactoryUsername')) { username = artifactoryUsername password = artifactoryPassword } diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/CheckstylePlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/CheckstylePlugin.groovy index 0c9fdec..4482103 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/CheckstylePlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/CheckstylePlugin.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.Plugin @@ -24,26 +23,32 @@ import org.gradle.api.plugins.JavaPlugin * Adds and configures Checkstyle plugin. * * @author Vedran Pavic + * @author John Blum */ class CheckstylePlugin implements Plugin { - final CHECKSTYLE_DIR = 'etc/checkstyle' + static final String CHECKSTYLE_PATHNAME = 'etc/checkstyle' @Override void apply(Project project) { + project.plugins.withType(JavaPlugin) { - def checkstyleDir = project.rootProject.file(CHECKSTYLE_DIR) - if (checkstyleDir.exists() && checkstyleDir.directory) { + + def checkstyleDirectory = project.rootProject.file(CHECKSTYLE_PATHNAME) + + if (checkstyleDirectory.exists() && checkstyleDirectory.directory) { + project.getPluginManager().apply('checkstyle') - project.dependencies.add('checkstyle', 'io.spring.javaformat:spring-javaformat-checkstyle:0.0.29') - project.dependencies.add('checkstyle', 'io.spring.nohttp:nohttp-checkstyle:0.0.3.RELEASE') + project.dependencies.add('checkstyle', + 'io.spring.javaformat:spring-javaformat-checkstyle:0.0.29') + project.dependencies.add('checkstyle', + 'io.spring.nohttp:nohttp-checkstyle:0.0.3.RELEASE') project.checkstyle { - configDirectory = checkstyleDir + configDirectory = checkstyleDirectory toolVersion = '8.21' } } } } - } diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/DependencyManagementExportTask.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/DependencyManagementExportTask.groovy index 4ab559c..ada3583 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/DependencyManagementExportTask.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/DependencyManagementExportTask.groovy @@ -1,61 +1,80 @@ +/* + * Copyright 2016-2021 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 org.gradle.api.Project +import org.gradle.api.DefaultTask import org.gradle.api.artifacts.component.ModuleComponentSelector import org.gradle.api.tasks.Input -import org.gradle.api.tasks.Internal; +import org.gradle.api.tasks.Internal +import org.gradle.api.tasks.TaskAction -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.Map; -import java.util.Properties; +/** + * Gradle API Task to output all the configured project & subproject (runtime) dependencies. + * + * @author Rob Winch + * @author John Blum + */ +class DependencyManagementExportTask extends DefaultTask { -import org.gradle.api.DefaultTask; -import org.gradle.api.artifacts.Configuration; -import org.gradle.api.tasks.TaskAction; + @Internal + def projects; -import io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension; + @Input + String getProjectNames() { + return this.projects*.name + } -public class DependencyManagementExportTask extends DefaultTask { - @Internal - def projects; + @TaskAction + void dependencyManagementExport() throws IOException { - @Input - String getProjectNames() { - return projects*.name - } + def projects = this.projects ?: project.subprojects + project - @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 configurations = projects*.configurations*.findAll { + [ 'testRuntime', 'integrationTestRuntime', 'grettyRunnerTomcat10', 'ajtools' ].contains(it.name) + } - 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 + def dependencyResults = configurations*.incoming*.resolutionResult*.allDependencies.flatten() - 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 '' - } + def moduleVersionVersions = dependencyResults + .findAll { r -> r.requested instanceof ModuleComponentSelector } + .collect { r -> r.selected.moduleVersion } - void setOutputFile(File file) throws IOException { - this.output = new FileOutputStream(file); - } + 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 '' + } } diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/DependencySetPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/DependencySetPlugin.groovy index 0267cf5..ed70f17 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/DependencySetPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/DependencySetPlugin.groovy @@ -30,6 +30,7 @@ import org.gradle.api.plugins.JavaPlugin * * * @author Rob Winch + * @author John Blum */ class DependencySetPlugin implements Plugin { diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/DeployDocsPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/DeployDocsPlugin.groovy index 0aae3ae..ed97afa 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/DeployDocsPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/DeployDocsPlugin.groovy @@ -18,6 +18,10 @@ package io.spring.gradle.convention import org.gradle.api.Plugin import org.gradle.api.Project +/** + * @author Rob Winch + * @author John Blum + */ class DeployDocsPlugin implements Plugin { @Override diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/DocsPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/DocsPlugin.groovy index e7b46c6..3786d53 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/DocsPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/DocsPlugin.groovy @@ -1,3 +1,18 @@ +/* + * Copyright 2002-2017 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 org.gradle.api.Plugin @@ -7,7 +22,10 @@ import org.gradle.api.plugins.PluginManager import org.gradle.api.tasks.bundling.Zip /** - * Aggregates asciidoc, javadoc, and deploying of the docs into a single plugin + * Aggregates Asciidoc, Javadoc, and deploying of the docs into a single Gradle Plugin. + * + * @author Rob Winch + * @author John Blum */ class DocsPlugin implements Plugin { diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/IncludeCheckRemotePlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/IncludeCheckRemotePlugin.groovy deleted file mode 100644 index 5ba6e35..0000000 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/IncludeCheckRemotePlugin.groovy +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2002-2021 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.IncludeRepoTask -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.api.provider.Property -import org.gradle.api.tasks.GradleBuild -import org.gradle.api.tasks.TaskProvider - -/** - * Adds a set of tasks that make easy to clone a remote repository and perform some task - * - * @author Marcus Da Coregio - */ -class IncludeCheckRemotePlugin implements Plugin { - @Override - void apply(Project project) { - IncludeCheckRemoteExtension extension = project.extensions.create('includeCheckRemote', IncludeCheckRemoteExtension) - TaskProvider includeRepoTask = project.tasks.register('includeRepo', IncludeRepoTask) { IncludeRepoTask it -> - it.repository = extension.repository - it.ref = extension.ref - } - project.tasks.register('checkRemote', GradleBuild) { - it.dependsOn 'includeRepo' - it.dir = includeRepoTask.get().outputDirectory - it.tasks = extension.getTasks() - } - } - - abstract static class IncludeCheckRemoteExtension { - - /** - * Git repository to clone - */ - String repository; - - /** - * Git ref to checkout - */ - String ref - - /** - * Task to run in the repository - */ - List tasks = ['check'] - - } - -} diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/IntegrationTestPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/IntegrationTestPlugin.groovy index 23e4c76..d8591f1 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/IntegrationTestPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/IntegrationTestPlugin.groovy @@ -26,8 +26,7 @@ import org.gradle.plugins.ide.idea.IdeaPlugin import org.springframework.gradle.propdeps.PropDepsPlugin /** - * - * Adds support for integration tests to java projects. + * Adds support for integration tests to Java projects. * *
    *
  • Adds integrationTestCompile and integrationTestRuntime configurations
  • @@ -37,6 +36,7 @@ import org.springframework.gradle.propdeps.PropDepsPlugin *
* * @author Rob Winch + * @author John Blum */ class IntegrationTestPlugin implements Plugin { diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/JacocoPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/JacocoPlugin.groovy index d22d943..adae14f 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/JacocoPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/JacocoPlugin.groovy @@ -23,6 +23,7 @@ import org.gradle.api.plugins.JavaPlugin * Adds a version of jacoco to use and makes check depend on jacocoTestReport. * * @author Rob Winch + * @author John Blum */ class JacocoPlugin implements Plugin { diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/JavadocOptionsPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/JavadocOptionsPlugin.groovy index e0fef7e..a968efc 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/JavadocOptionsPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/JavadocOptionsPlugin.groovy @@ -1,13 +1,32 @@ +/* + * Copyright 2002-2016 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 org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.tasks.javadoc.Javadoc -public class JavadocOptionsPlugin implements Plugin { +/** + * @author Rob Winch + * @author John Blum + */ +class JavadocOptionsPlugin implements Plugin { @Override - public void apply(Project project) { + void apply(Project project) { project.getTasks().withType(Javadoc).all { t-> t.options.addStringOption('Xdoclint:none', '-quiet') } diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/ManagementConfigurationPlugin.java b/buildSrc/src/main/groovy/io/spring/gradle/convention/ManagementConfigurationPlugin.java index 8db6fd9..a7e7410 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/ManagementConfigurationPlugin.java +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/ManagementConfigurationPlugin.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package io.spring.gradle.convention; import org.gradle.api.Plugin; @@ -23,16 +22,20 @@ import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.plugins.JavaTestFixturesPlugin; import org.gradle.api.plugins.PluginContainer; import org.gradle.api.publish.PublishingExtension; +import org.gradle.api.publish.VariantVersionMappingStrategy; import org.gradle.api.publish.maven.MavenPublication; import org.gradle.api.publish.maven.plugins.MavenPublishPlugin; import org.springframework.gradle.propdeps.PropDepsPlugin; /** - * Creates a Management configuration that is appropriate for adding a platform to that is not exposed externally. If - * the JavaPlugin is applied, the compileClasspath, runtimeClasspath, testCompileClasspath, and testRuntimeClasspath + * Creates a Management configuration that is appropriate for adding a platform so that it is not exposed externally. + * + * If the JavaPlugin is applied, the compileClasspath, runtimeClasspath, testCompileClasspath, and testRuntimeClasspath * will extend from it. + * * @author Rob Winch + * @author John Blum */ public class ManagementConfigurationPlugin implements Plugin { @@ -40,35 +43,42 @@ public class ManagementConfigurationPlugin implements Plugin { @Override public void apply(Project project) { + ConfigurationContainer configurations = project.getConfigurations(); - configurations.create(MANAGEMENT_CONFIGURATION_NAME, (management) -> { - management.setVisible(false); + + configurations.create(MANAGEMENT_CONFIGURATION_NAME, management -> { + management.setCanBeConsumed(false); management.setCanBeResolved(false); + management.setVisible(false); PluginContainer plugins = project.getPlugins(); - plugins.withType(JavaPlugin.class, (javaPlugin) -> { + + plugins.withType(JavaPlugin.class, javaPlugin -> { configurations.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME).extendsFrom(management); configurations.getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME).extendsFrom(management); configurations.getByName(JavaPlugin.TEST_COMPILE_CLASSPATH_CONFIGURATION_NAME).extendsFrom(management); configurations.getByName(JavaPlugin.TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME).extendsFrom(management); }); - plugins.withType(JavaTestFixturesPlugin.class, (javaTestFixturesPlugin) -> { + + plugins.withType(JavaTestFixturesPlugin.class, javaTestFixturesPlugin -> { configurations.getByName("testFixturesCompileClasspath").extendsFrom(management); configurations.getByName("testFixturesRuntimeClasspath").extendsFrom(management); }); - plugins.withType(MavenPublishPlugin.class, (mavenPublish) -> { + + plugins.withType(MavenPublishPlugin.class, mavenPublish -> { + PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class); - publishing.getPublications().withType(MavenPublication.class, (mavenPublication -> { - mavenPublication.versionMapping((versions) -> - versions.allVariants(versionMapping -> versionMapping.fromResolutionResult()) - ); - })); + + publishing.getPublications().withType(MavenPublication.class, mavenPublication -> + mavenPublication.versionMapping(versions -> + versions.allVariants(VariantVersionMappingStrategy::fromResolutionResult))); }); - plugins.withType(PropDepsPlugin.class, (propDepsPlugin -> { + + plugins.withType(PropDepsPlugin.class, propDepsPlugin -> { configurations.getByName("optional").extendsFrom(management); configurations.getByName("provided").extendsFrom(management); - })); + }); }); } -} \ No newline at end of file +} diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/MavenBomPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/MavenBomPlugin.groovy index fe94e81..c69e1e1 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/MavenBomPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/MavenBomPlugin.groovy @@ -1,16 +1,33 @@ +/* + * Copyright 2002-2021 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 org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.plugins.JavaPlatformPlugin -import org.sonarqube.gradle.SonarQubePlugin import org.springframework.gradle.CopyPropertiesPlugin import org.springframework.gradle.maven.SpringMavenPlugin -public class MavenBomPlugin implements Plugin { - static String MAVEN_BOM_TASK_NAME = "mavenBom" +/** + * @author Rob Winch + * @author John Blum + */ +class MavenBomPlugin implements Plugin { - public void apply(Project project) { + void apply(Project project) { project.plugins.apply(JavaPlatformPlugin) project.plugins.apply(SpringMavenPlugin) project.plugins.apply(CopyPropertiesPlugin) diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/RepositoryConventionPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/RepositoryConventionPlugin.groovy index 03601a3..f2ef3b0 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/RepositoryConventionPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/RepositoryConventionPlugin.groovy @@ -18,12 +18,17 @@ package io.spring.gradle.convention; import org.gradle.api.Plugin import org.gradle.api.Project +/** + * @author Rob Winch + * @author John Blum + */ class RepositoryConventionPlugin implements Plugin { @Override void apply(Project project) { - String[] forceMavenRepositories = ((String) project.findProperty("forceMavenRepositories"))?.split(',') + String[] forceMavenRepositories = + ((String) project.findProperty("forceMavenRepositories"))?.split(',') boolean isImplicitSnapshotRepository = forceMavenRepositories == null && Utils.isSnapshot(project) boolean isImplicitMilestoneRepository = forceMavenRepositories == null && Utils.isMilestone(project) 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 01212bc..8c7399d 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/RootProjectPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/RootProjectPlugin.groovy @@ -22,6 +22,10 @@ import org.gradle.api.plugins.BasePlugin import org.gradle.api.plugins.PluginManager import org.springframework.gradle.maven.SpringNexusPublishPlugin +/** + * @author Rob Winch + * @author John Blum + */ class RootProjectPlugin implements Plugin { @Override @@ -30,8 +34,8 @@ class RootProjectPlugin implements Plugin { PluginManager pluginManager = project.getPluginManager() pluginManager.apply(BasePlugin) - pluginManager.apply(SchemaPlugin) pluginManager.apply(NoHttpPlugin) + pluginManager.apply(SchemaPlugin) pluginManager.apply(SpringNexusPublishPlugin) pluginManager.apply("org.sonarqube") diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/SchemaDeployPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/SchemaDeployPlugin.groovy index 4b9c038..07d01c0 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/SchemaDeployPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/SchemaDeployPlugin.groovy @@ -1,38 +1,60 @@ +/* + * 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 org.gradle.api.plugins.JavaPlugin -import org.gradle.api.tasks.bundling.Zip import org.gradle.api.Plugin import org.gradle.api.Project -public class SchemaDeployPlugin implements Plugin { +/** + * @author Rob Winch + * @author John Blum + */ +class SchemaDeployPlugin implements Plugin { @Override - public void apply(Project project) { + void apply(Project project) { + project.getPluginManager().apply('org.hidetake.ssh') project.ssh.settings { knownHosts = allowAnyHosts } + project.remotes { docs { + + retryCount = 5 // Retry 5 times (default is 0) + retryWaitSec = 10 // Wait 10 seconds between retries (default is 0) role 'docs' - if (project.hasProperty('deployDocsHost')) { - host = project.findProperty('deployDocsHost') - } else { - host = 'docs.af.pivotal.io' - } - retryCount = 5 // retry 5 times (default is 0) - retryWaitSec = 10 // wait 10 seconds between retries (default is 0) + + host = project.hasProperty('deployDocsHost') + ? project.findProperty('deployDocsHost') + : 'docs.af.pivotal.io' + user = project.findProperty('deployDocsSshUsername') - if(project.hasProperty('deployDocsSshKeyPath')) { - identity = project.file(project.findProperty('deployDocsSshKeyPath')) - } else if (project.hasProperty('deployDocsSshKey')) { - identity = project.findProperty('deployDocsSshKey') - } - if(project.hasProperty('deployDocsSshPassphrase')) { - passphrase = project.findProperty('deployDocsSshPassphrase') - } + + identity = project.hasProperty('deployDocsSshKeyPath') + ? project.file(project.findProperty('deployDocsSshKeyPath')) + : project.hasProperty('deployDocsSshKey') + ? project.findProperty('deployDocsSshKey') + : identity + + passphrase = project.hasProperty('deployDocsSshPassphrase') + ? project.findProperty('deployDocsSshPassphrase') + : passphrase } } @@ -41,6 +63,7 @@ public class SchemaDeployPlugin implements Plugin { doFirst { project.ssh.run { session(project.remotes.docs) { + def now = System.currentTimeMillis() def name = project.rootProject.name def version = project.rootProject.version @@ -68,4 +91,4 @@ public class SchemaDeployPlugin implements Plugin { } } } -} \ No newline at end of file +} diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/SchemaPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/SchemaPlugin.groovy index 769ae80..591b7df 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/SchemaPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/SchemaPlugin.groovy @@ -1,15 +1,32 @@ +/* + * 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 org.gradle.api.plugins.JavaPlugin -import org.gradle.api.tasks.bundling.Zip import org.gradle.api.Plugin import org.gradle.api.Project -public class SchemaPlugin implements Plugin { +/** + * @author Rob Winch + * @author John Blum + */ +class SchemaPlugin implements Plugin { @Override - public void apply(Project project) { - project.getPluginManager().apply(SchemaZipPlugin) + void apply(Project project) { project.getPluginManager().apply(SchemaDeployPlugin) + project.getPluginManager().apply(SchemaZipPlugin) } -} \ No newline at end of file +} diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/SchemaZipPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/SchemaZipPlugin.groovy index 72de4b3..eecf2e0 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/SchemaZipPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/SchemaZipPlugin.groovy @@ -1,37 +1,64 @@ +/* + * 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 org.gradle.api.plugins.JavaPlugin -import org.gradle.api.tasks.bundling.Zip import org.gradle.api.Plugin import org.gradle.api.Project +import org.gradle.api.plugins.JavaPlugin +import org.gradle.api.tasks.bundling.Zip -public class SchemaZipPlugin implements Plugin { +/** + * @author Rob Winch + * @author John Blum + */ +class SchemaZipPlugin implements Plugin { @Override - public void apply(Project project) { + void apply(Project project) { + Zip schemaZip = project.tasks.create('schemaZip', Zip) - schemaZip.group = 'Distribution' + schemaZip.archiveBaseName = project.rootProject.name schemaZip.archiveClassifier = 'schema' schemaZip.description = "Builds -${schemaZip.archiveClassifier} archive containing all " + "XSDs for deployment at static.springframework.org/schema." + schemaZip.group = 'Distribution' project.rootProject.subprojects.each { module -> module.getPlugins().withType(JavaPlugin.class).all { - def Properties schemas = new Properties(); - module.sourceSets.main.resources.find { - it.path.endsWith('META-INF/spring.schemas') - }?.withInputStream { schemas.load(it) } + Properties schemas = new Properties(); + + module.sourceSets.main.resources + .find { it.path.endsWith('META-INF/spring.schemas') } + ?.withInputStream { schemas.load(it) } for (def key : schemas.keySet()) { + def shortName = key.replaceAll(/http.*schema.(.*).spring-.*/, '$1') + assert shortName != key + File xsdFile = module.sourceSets.main.resources.find { it.path.endsWith(schemas.get(key)) } + assert xsdFile != null + schemaZip.into (shortName) { duplicatesStrategy 'exclude' from xsdFile.path diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringDependencyManagementConventionPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringDependencyManagementConventionPlugin.groovy index 20ded1a..f6c7f98 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringDependencyManagementConventionPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringDependencyManagementConventionPlugin.groovy @@ -24,6 +24,9 @@ import org.gradle.api.Project *

* Additionally, if 'gradle/dependency-management.gradle' file is present it will be * automatically applied file for configuring the dependencies. + * + * @author Rob Winch + * @author John Blum */ class SpringDependencyManagementConventionPlugin implements Plugin { @@ -54,5 +57,4 @@ class SpringDependencyManagementConventionPlugin implements Plugin { } } } - } 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 cba3a01..d6704bf 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringModulePlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringModulePlugin.groovy @@ -21,7 +21,10 @@ import org.gradle.api.plugins.PluginManager import org.springframework.gradle.maven.SpringMavenPlugin /** + * Defines the Gradle project as a proper Spring Module. + * * @author Rob Winch + * @author John Blum */ class SpringModulePlugin extends AbstractSpringJavaPlugin { diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringSampleBootPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringSampleBootPlugin.groovy index e947e0a..6b05495 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringSampleBootPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringSampleBootPlugin.groovy @@ -20,6 +20,7 @@ import org.gradle.api.plugins.PluginManager /** * @author Rob Winch + * @author John Blum */ class SpringSampleBootPlugin extends SpringSamplePlugin { diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringSamplePlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringSamplePlugin.groovy index 3714c06..aaec859 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringSamplePlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringSamplePlugin.groovy @@ -20,6 +20,7 @@ import org.sonarqube.gradle.SonarQubePlugin; /** * @author Rob Winch + * @author John Blum */ class SpringSamplePlugin extends AbstractSpringJavaPlugin { diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringSampleWarPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringSampleWarPlugin.groovy index 7eed436..4ae3e90 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringSampleWarPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringSampleWarPlugin.groovy @@ -22,6 +22,7 @@ import org.gradle.api.tasks.testing.Test /** * @author Rob Winch + * @author John Blum */ class SpringSampleWarPlugin extends SpringSamplePlugin { @@ -68,16 +69,22 @@ class SpringSampleWarPlugin extends SpringSamplePlugin { project.gretty.integrationTestTask = integrationTest.name integrationTest.doFirst { + def gretty = project.gretty - String host = project.gretty.host ?: 'localhost' + boolean isHttps = gretty.httpsEnabled + Integer httpPort = integrationTest.systemProperties['gretty.httpPort'] Integer httpsPort = integrationTest.systemProperties['gretty.httpsPort'] + int port = isHttps ? httpsPort : httpPort + + String host = project.gretty.host ?: 'localhost' String contextPath = project.gretty.contextPath String httpBaseUrl = "http://${host}:${httpPort}${contextPath}" String httpsBaseUrl = "https://${host}:${httpsPort}${contextPath}" String baseUrl = isHttps ? httpsBaseUrl : httpBaseUrl + integrationTest.systemProperty 'app.port', port integrationTest.systemProperty 'app.httpPort', httpPort integrationTest.systemProperty 'app.httpsPort', httpsPort diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringTestPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringTestPlugin.groovy index 42466af..9d9c842 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringTestPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/SpringTestPlugin.groovy @@ -19,6 +19,7 @@ import org.gradle.api.Project; /** * @author Rob Winch + * @author John Blum */ class SpringTestPlugin extends AbstractSpringJavaPlugin { diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/TestsConfigurationPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/TestsConfigurationPlugin.groovy index 7b89f0d..22151cb 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/TestsConfigurationPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/TestsConfigurationPlugin.groovy @@ -28,6 +28,7 @@ import org.gradle.jvm.tasks.Jar * * * @author Rob Winch + * @author John Blum */ class TestsConfigurationPlugin implements Plugin { diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/Utils.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/Utils.groovy index 830986c..18bb814 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/Utils.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/Utils.groovy @@ -1,7 +1,26 @@ +/* + * Copyright 2002-2021 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 org.gradle.api.Project; +/** + * @author Rob Winch + * @author John Blum + */ class Utils { private Utils() {} diff --git a/buildSrc/src/main/java/org/springframework/gradle/maven/SpringMavenPlugin.java b/buildSrc/src/main/java/org/springframework/gradle/maven/SpringMavenPlugin.java index 8b06212..7a042ce 100644 --- a/buildSrc/src/main/java/org/springframework/gradle/maven/SpringMavenPlugin.java +++ b/buildSrc/src/main/java/org/springframework/gradle/maven/SpringMavenPlugin.java @@ -1,3 +1,18 @@ +/* + * Copyright 2002-2017 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 org.springframework.gradle.maven; import io.spring.gradle.convention.ArtifactoryPlugin; @@ -6,10 +21,17 @@ import org.gradle.api.Project; import org.gradle.api.plugins.PluginManager; import org.gradle.api.publish.maven.plugins.MavenPublishPlugin; +/** + * @author Rob Winch + * @author John Blum + */ public class SpringMavenPlugin implements Plugin { + @Override public void apply(Project project) { + PluginManager pluginManager = project.getPluginManager(); + pluginManager.apply(MavenPublishPlugin.class); pluginManager.apply(SpringSigningPlugin.class); pluginManager.apply(MavenPublishingConventionsPlugin.class); diff --git a/buildSrc/src/main/java/org/springframework/gradle/maven/SpringNexusPublishPlugin.java b/buildSrc/src/main/java/org/springframework/gradle/maven/SpringNexusPublishPlugin.java index 3002824..4376e5f 100644 --- a/buildSrc/src/main/java/org/springframework/gradle/maven/SpringNexusPublishPlugin.java +++ b/buildSrc/src/main/java/org/springframework/gradle/maven/SpringNexusPublishPlugin.java @@ -1,27 +1,44 @@ +/* + * Copyright 2002-2016 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 org.springframework.gradle.maven; -import io.github.gradlenexus.publishplugin.NexusPublishExtension; -import io.github.gradlenexus.publishplugin.NexusPublishPlugin; -import io.github.gradlenexus.publishplugin.NexusRepository; -import org.gradle.api.Action; -import org.gradle.api.Plugin; -import org.gradle.api.Project; - import java.net.URI; import java.time.Duration; +import org.gradle.api.Plugin; +import org.gradle.api.Project; + +import io.github.gradlenexus.publishplugin.NexusPublishExtension; +import io.github.gradlenexus.publishplugin.NexusPublishPlugin; + public class SpringNexusPublishPlugin implements Plugin { + @Override public void apply(Project project) { + project.getPlugins().apply(NexusPublishPlugin.class); + NexusPublishExtension nexusPublishing = project.getExtensions().findByType(NexusPublishExtension.class); - nexusPublishing.getRepositories().create("ossrh", new Action() { - @Override - public void execute(NexusRepository nexusRepository) { - nexusRepository.getNexusUrl().set(URI.create("https://s01.oss.sonatype.org/service/local/")); - nexusRepository.getSnapshotRepositoryUrl().set(URI.create("https://s01.oss.sonatype.org/content/repositories/snapshots/")); - } + + nexusPublishing.getRepositories().create("ossrh", nexusRepository -> { + nexusRepository.getNexusUrl().set(URI.create("https://s01.oss.sonatype.org/service/local/")); + nexusRepository.getSnapshotRepositoryUrl() + .set(URI.create("https://s01.oss.sonatype.org/content/repositories/snapshots/")); }); + nexusPublishing.getConnectTimeout().set(Duration.ofMinutes(3)); nexusPublishing.getClientTimeout().set(Duration.ofMinutes(3)); } diff --git a/buildSrc/src/main/java/org/springframework/gradle/maven/SpringSigningPlugin.java b/buildSrc/src/main/java/org/springframework/gradle/maven/SpringSigningPlugin.java index 112651b..53acf0a 100644 --- a/buildSrc/src/main/java/org/springframework/gradle/maven/SpringSigningPlugin.java +++ b/buildSrc/src/main/java/org/springframework/gradle/maven/SpringSigningPlugin.java @@ -13,58 +13,57 @@ * License for the specific language governing permissions and limitations under * the License. */ - package org.springframework.gradle.maven; -import org.gradle.api.Action; +import java.util.concurrent.Callable; + import org.gradle.api.Plugin; import org.gradle.api.Project; import org.gradle.api.publish.Publication; import org.gradle.api.publish.PublishingExtension; -import org.gradle.api.publish.plugins.PublishingPlugin; import org.gradle.plugins.signing.SigningExtension; import org.gradle.plugins.signing.SigningPlugin; -import java.util.concurrent.Callable; - public class SpringSigningPlugin implements Plugin { + @Override public void apply(Project project) { + project.getPluginManager().apply(SigningPlugin.class); - project.getPlugins().withType(SigningPlugin.class).all(new Action() { - @Override - public void execute(SigningPlugin signingPlugin) { - boolean hasSigningKey = project.hasProperty("signing.keyId") || project.hasProperty("signingKey"); - if (hasSigningKey) { - sign(project); - } + + project.getPlugins().withType(SigningPlugin.class).all(signingPlugin -> { + + boolean hasSigningKey = project.hasProperty("signing.keyId") + || project.hasProperty("signingKey"); + + if (hasSigningKey) { + sign(project); } }); } private void sign(Project project) { + SigningExtension signing = project.getExtensions().findByType(SigningExtension.class); - signing.setRequired(new Callable() { - @Override - public Boolean call() throws Exception { - return project.getGradle().getTaskGraph().hasTask("publishArtifacts"); - } - }); - String signingKeyId = (String) project.findProperty("signingKeyId"); + + signing.setRequired((Callable) () -> + project.getGradle().getTaskGraph().hasTask("publishArtifacts")); + String signingKey = (String) project.findProperty("signingKey"); + String signingKeyId = (String) project.findProperty("signingKeyId"); String signingPassword = (String) project.findProperty("signingPassword"); + if (signingKeyId != null) { signing.useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword); - } else { + } + else { signing.useInMemoryPgpKeys(signingKey, signingPassword); } - project.getPlugins().withType(PublishAllJavaComponentsPlugin.class).all(new Action() { - @Override - public void execute(PublishAllJavaComponentsPlugin publishingPlugin) { - PublishingExtension publishing = project.getExtensions().findByType(PublishingExtension.class); - Publication maven = publishing.getPublications().getByName("mavenJava"); - signing.sign(maven); - } + + project.getPlugins().withType(PublishAllJavaComponentsPlugin.class).all(publishingPlugin -> { + PublishingExtension publishing = project.getExtensions().findByType(PublishingExtension.class); + Publication maven = publishing.getPublications().getByName("mavenJava"); + signing.sign(maven); }); } } diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.include-check-remote.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.include-check-remote.properties deleted file mode 100644 index 298e1bb..0000000 --- a/buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.include-check-remote.properties +++ /dev/null @@ -1 +0,0 @@ -implementation-class=io.spring.gradle.convention.IncludeCheckRemotePlugin