From 6b3918ff7bfc813963e1c86420ae86f034592672 Mon Sep 17 00:00:00 2001 From: Rob Winch Date: Fri, 2 Apr 2021 13:13:07 -0500 Subject: [PATCH] Add buildSrc Closes gh-9539 --- build.gradle | 3 +- buildSrc/build.gradle | 41 +- .../AbstractSpringJavaPlugin.groovy | 88 +++ .../convention/ArtifactoryPlugin.groovy | 58 ++ .../gradle/convention/CheckstylePlugin.groovy | 49 ++ .../DependencyManagementExportTask.groovy | 61 ++ .../convention/DependencySetPlugin.groovy | 126 +++ .../gradle/convention/DeployDocsPlugin.groovy | 82 ++ .../gradle/convention/DocsPlugin.groovy | 73 ++ .../convention/IntegrationTestPlugin.groovy | 121 +++ .../gradle/convention/JacocoPlugin.groovy | 41 + .../gradle/convention/JavadocApiPlugin.groovy | 105 +++ .../convention/JavadocOptionsPlugin.groovy | 15 + .../ManagementConfigurationPlugin.java | 33 + .../gradle/convention/MavenBomPlugin.groovy | 54 ++ .../gradle/convention/MavenBomTask.groovy | 87 +++ .../gradle/convention/MergePlugin.groovy | 182 +++++ .../gradle/convention/OssrhPlugin.groovy | 26 + .../RepositoryConventionPlugin.groovy | 80 ++ .../convention/RootProjectPlugin.groovy | 78 ++ .../convention/SchemaDeployPlugin.groovy | 71 ++ .../gradle/convention/SchemaPlugin.groovy | 15 + .../gradle/convention/SchemaZipPlugin.groovy | 43 ++ .../gradle/convention/SortedProperties.groovy | 52 ++ ...ependencyManagementConventionPlugin.groovy | 54 ++ .../convention/SpringMavenPlugin.groovy | 221 ++++++ .../convention/SpringModulePlugin.groovy | 50 ++ .../gradle/convention/SpringPomPlugin.groovy | 24 + .../convention/SpringSampleBootPlugin.groovy | 43 ++ .../convention/SpringSamplePlugin.groovy | 33 + .../convention/SpringSampleWarPlugin.groovy | 97 +++ .../gradle/convention/SpringTestPlugin.groovy | 30 + .../TestsConfigurationPlugin.groovy | 54 ++ .../io/spring/gradle/convention/Utils.groovy | 34 + .../AsciidoctorConventionPlugin.java | 208 +++++ ...o.spring.convention.artifactory.properties | 1 + .../io.spring.convention.bom.properties | 1 + ...io.spring.convention.checkstyle.properties | 1 + ...pring.convention.dependency-set.properties | 1 + .../io.spring.convention.docs.properties | 1 + ...ing.convention.integration-test.properties | 1 + .../io.spring.convention.jacoco.properties | 1 + ...o.spring.convention.javadoc-api.properties | 1 + ...ring.convention.javadoc-options.properties | 1 + .../io.spring.convention.maven.properties | 1 + .../io.spring.convention.merge.properties | 1 + .../io.spring.convention.ossrh.properties | 1 + ...io.spring.convention.repository.properties | 1 + .../io.spring.convention.root.properties | 1 + ...spring.convention.spring-module.properties | 1 + ...io.spring.convention.spring-pom.properties | 1 + ...g.convention.spring-sample-boot.properties | 1 + ...ng.convention.spring-sample-war.properties | 1 + ...spring.convention.spring-sample.properties | 1 + ...o.spring.convention.spring-test.properties | 1 + ...ntion.springdependencymangement.properties | 1 + ....convention.tests-configuration.properties | 1 + .../DependencySetPluginITest.groovy | 37 + .../gradle/convention/DocsPluginITest.groovy | 95 +++ .../IntegrationTestPluginITest.groovy | 63 ++ .../convention/JacocoPluginITest.groovy | 39 + .../convention/JavadocApiPluginITest.groovy | 48 ++ .../gradle/convention/ShowcaseITest.groovy | 130 ++++ .../convention/SpringMavenPluginITest.groovy | 88 +++ .../TestsConfigurationPluginITest.groovy | 36 + .../gradle/testkit/junit/rules/TestKit.java | 75 ++ .../convention/IntegrationPluginTest.java | 53 ++ .../convention/JavadocApiPluginTest.java | 56 ++ .../RepositoryConventionPluginTests.java | 158 ++++ .../spring/gradle/convention/UtilsTest.java | 151 ++++ .../samples/dependencyset/build.gradle | 21 + .../gradle/dependency-management.gradle | 724 ++++++++++++++++++ .../docs/missing-attribute/build.gradle | 6 + .../docs/missing-attribute/settings.gradle | 1 + .../src/docs/asciidoc/index.adoc | 3 + .../docs/missing-cross-reference/build.gradle | 6 + .../missing-cross-reference/settings.gradle | 1 + .../src/docs/asciidoc/index.adoc | 3 + .../samples/docs/missing-include/build.gradle | 6 + .../docs/missing-include/settings.gradle | 1 + .../src/docs/asciidoc/index.adoc | 5 + .../samples/docs/simple/build.gradle | 13 + .../samples/docs/simple/settings.gradle | 1 + .../simple/src/docs/asciidoc/docinfo.html | 1 + .../src/docs/asciidoc/images/sunset.jpg | Bin 0 -> 122404 bytes .../docs/simple/src/docs/asciidoc/index.adoc | 60 ++ .../simple/src/docs/asciidoc/subdir/_b.adoc | 7 + .../simple/src/docs/asciidoc/subdir/_c.adoc | 1 + .../src/main/java/example/StringUtils.java | 9 + .../integrationtest/withgroovy/build.gradle | 16 + .../groovy/sample/TheTest.groovy | 31 + .../integrationtest/withjava/build.gradle | 14 + .../integration-test/java/sample/TheTest.java | 16 + .../integrationtest/withpropdeps/build.gradle | 15 + .../integration-test/java/sample/TheTest.java | 11 + .../samples/jacoco/java/build.gradle | 13 + .../java/src/main/java/sample/TheClass.java | 11 + .../src/test/java/sample/TheClassTest.java | 19 + .../javadocapi/multimodule/api/build.gradle | 1 + .../api/src/main/java/sample/Api.java | 14 + .../javadocapi/multimodule/build.gradle | 5 + .../javadocapi/multimodule/impl/build.gradle | 1 + .../impl/src/main/java/sample/Impl.java | 14 + .../multimodule/sample/build.gradle | 1 + .../sample/src/main/java/sample/Sample.java | 14 + .../javadocapi/multimodule/settings.gradle | 3 + .../maven/install-with-springio/build.gradle | 12 + .../gradle/dependency-management.gradle | 5 + .../samples/maven/install/build.gradle | 15 + .../samples/maven/signing/build.gradle | 17 + .../samples/maven/signing/settings.gradle | 1 + .../samples/maven/upload/build.gradle | 22 + .../resources/samples/showcase/Jenkinsfile | 52 ++ .../resources/samples/showcase/bom/bom.gradle | 2 + .../resources/samples/showcase/build.gradle | 6 + .../showcase/etc/checkstyle/checkstyle.xml | 5 + .../gradle/dependency-management.gradle | 3 + .../samples/sgbcs-sample-war/build.gradle | 7 + .../java/sample/HelloServletTest.java | 23 + .../src/main/java/sample/HelloServlet.java | 35 + .../samples/showcase/settings.gradle | 23 + .../showcase/sgbcs-api/sgbcs-api.gradle | 8 + .../sgbcs-api/src/main/java/api/Api.java | 10 + .../sgbcs-api/src/test/java/api/ApiTest.java | 9 + .../showcase/sgbcs-core/sgbcs-core.gradle | 6 + .../src/main/java/core/CoreClass.java | 13 + .../src/main/java/core/HasOptional.java | 14 + .../main/resources/META-INF/spring.handlers | 1 + .../main/resources/META-INF/spring.schemas | 4 + .../spring-springgradlebuildsample-2.0.xsd | 468 +++++++++++ .../spring-springgradlebuildsample-2.1.xsd | 685 +++++++++++++++++ .../spring-springgradlebuildsample-2.2.xsd | 685 +++++++++++++++++ .../src/test/java/core/CoreClassTest.java | 12 + .../src/test/java/core/HasOptionalTest.java | 12 + .../showcase/sgbcs-docs/sgbcs-docs.gradle | 11 + .../sgbcs-docs/src/docs/asciidoc/docinfo.html | 1 + .../src/docs/asciidoc/images/sunset.jpg | Bin 0 -> 122404 bytes .../sgbcs-docs/src/docs/asciidoc/index.adoc | 60 ++ .../src/docs/asciidoc/subdir/_b.adoc | 7 + .../src/docs/asciidoc/subdir/_c.adoc | 1 + .../src/main/java/example/StringUtils.java | 9 + .../samples/testsconfiguration/build.gradle | 4 + .../testsconfiguration/core/build.gradle | 2 + .../core/src/test/java/sample/Dependency.java | 3 + .../testsconfiguration/settings.gradle | 2 + .../testsconfiguration/web/build.gradle | 10 + .../src/test/java/sample/DependencyTest.java | 10 + buildSrc/src/test/resources/test-private.pgp | 83 ++ 148 files changed, 6902 insertions(+), 7 deletions(-) create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/AbstractSpringJavaPlugin.groovy create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/ArtifactoryPlugin.groovy create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/CheckstylePlugin.groovy create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/DependencyManagementExportTask.groovy create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/DependencySetPlugin.groovy create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/DeployDocsPlugin.groovy create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/DocsPlugin.groovy create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/IntegrationTestPlugin.groovy create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/JacocoPlugin.groovy create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/JavadocApiPlugin.groovy create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/JavadocOptionsPlugin.groovy create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/ManagementConfigurationPlugin.java create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/MavenBomPlugin.groovy create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/MavenBomTask.groovy create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/MergePlugin.groovy create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/OssrhPlugin.groovy create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/RepositoryConventionPlugin.groovy create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/RootProjectPlugin.groovy create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/SchemaDeployPlugin.groovy create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/SchemaPlugin.groovy create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/SchemaZipPlugin.groovy create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/SortedProperties.groovy create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/SpringDependencyManagementConventionPlugin.groovy create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/SpringMavenPlugin.groovy create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/SpringModulePlugin.groovy create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/SpringPomPlugin.groovy create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/SpringSampleBootPlugin.groovy create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/SpringSamplePlugin.groovy create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/SpringSampleWarPlugin.groovy create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/SpringTestPlugin.groovy create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/TestsConfigurationPlugin.groovy create mode 100644 buildSrc/src/main/groovy/io/spring/gradle/convention/Utils.groovy create mode 100644 buildSrc/src/main/java/io/spring/gradle/convention/AsciidoctorConventionPlugin.java create mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.artifactory.properties create mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.bom.properties create mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.checkstyle.properties create mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.dependency-set.properties create mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.docs.properties create mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.integration-test.properties create mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.jacoco.properties create mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.javadoc-api.properties create mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.javadoc-options.properties create mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.maven.properties create mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.merge.properties create mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.ossrh.properties create mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.repository.properties create mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.root.properties create mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.spring-module.properties create mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.spring-pom.properties create mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.spring-sample-boot.properties create mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.spring-sample-war.properties create mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.spring-sample.properties create mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.spring-test.properties create mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.springdependencymangement.properties create mode 100644 buildSrc/src/main/resources/META-INF/gradle-plugins/io.spring.convention.tests-configuration.properties create mode 100644 buildSrc/src/test/groovy/io/spring/gradle/convention/DependencySetPluginITest.groovy create mode 100644 buildSrc/src/test/groovy/io/spring/gradle/convention/DocsPluginITest.groovy create mode 100644 buildSrc/src/test/groovy/io/spring/gradle/convention/IntegrationTestPluginITest.groovy create mode 100644 buildSrc/src/test/groovy/io/spring/gradle/convention/JacocoPluginITest.groovy create mode 100644 buildSrc/src/test/groovy/io/spring/gradle/convention/JavadocApiPluginITest.groovy create mode 100644 buildSrc/src/test/groovy/io/spring/gradle/convention/ShowcaseITest.groovy create mode 100644 buildSrc/src/test/groovy/io/spring/gradle/convention/SpringMavenPluginITest.groovy create mode 100644 buildSrc/src/test/groovy/io/spring/gradle/convention/TestsConfigurationPluginITest.groovy create mode 100644 buildSrc/src/test/groovy/io/spring/gradle/testkit/junit/rules/TestKit.java create mode 100644 buildSrc/src/test/java/io/spring/gradle/convention/IntegrationPluginTest.java create mode 100644 buildSrc/src/test/java/io/spring/gradle/convention/JavadocApiPluginTest.java create mode 100644 buildSrc/src/test/java/io/spring/gradle/convention/RepositoryConventionPluginTests.java create mode 100644 buildSrc/src/test/java/io/spring/gradle/convention/UtilsTest.java create mode 100644 buildSrc/src/test/resources/samples/dependencyset/build.gradle create mode 100644 buildSrc/src/test/resources/samples/dependencyset/gradle/dependency-management.gradle create mode 100644 buildSrc/src/test/resources/samples/docs/missing-attribute/build.gradle create mode 100644 buildSrc/src/test/resources/samples/docs/missing-attribute/settings.gradle create mode 100644 buildSrc/src/test/resources/samples/docs/missing-attribute/src/docs/asciidoc/index.adoc create mode 100644 buildSrc/src/test/resources/samples/docs/missing-cross-reference/build.gradle create mode 100644 buildSrc/src/test/resources/samples/docs/missing-cross-reference/settings.gradle create mode 100644 buildSrc/src/test/resources/samples/docs/missing-cross-reference/src/docs/asciidoc/index.adoc create mode 100644 buildSrc/src/test/resources/samples/docs/missing-include/build.gradle create mode 100644 buildSrc/src/test/resources/samples/docs/missing-include/settings.gradle create mode 100644 buildSrc/src/test/resources/samples/docs/missing-include/src/docs/asciidoc/index.adoc create mode 100644 buildSrc/src/test/resources/samples/docs/simple/build.gradle create mode 100644 buildSrc/src/test/resources/samples/docs/simple/settings.gradle create mode 100644 buildSrc/src/test/resources/samples/docs/simple/src/docs/asciidoc/docinfo.html create mode 100644 buildSrc/src/test/resources/samples/docs/simple/src/docs/asciidoc/images/sunset.jpg create mode 100644 buildSrc/src/test/resources/samples/docs/simple/src/docs/asciidoc/index.adoc create mode 100644 buildSrc/src/test/resources/samples/docs/simple/src/docs/asciidoc/subdir/_b.adoc create mode 100644 buildSrc/src/test/resources/samples/docs/simple/src/docs/asciidoc/subdir/_c.adoc create mode 100644 buildSrc/src/test/resources/samples/docs/simple/src/main/java/example/StringUtils.java create mode 100644 buildSrc/src/test/resources/samples/integrationtest/withgroovy/build.gradle create mode 100644 buildSrc/src/test/resources/samples/integrationtest/withgroovy/src/integration-test/groovy/sample/TheTest.groovy create mode 100644 buildSrc/src/test/resources/samples/integrationtest/withjava/build.gradle create mode 100644 buildSrc/src/test/resources/samples/integrationtest/withjava/src/integration-test/java/sample/TheTest.java create mode 100644 buildSrc/src/test/resources/samples/integrationtest/withpropdeps/build.gradle create mode 100644 buildSrc/src/test/resources/samples/integrationtest/withpropdeps/src/integration-test/java/sample/TheTest.java create mode 100644 buildSrc/src/test/resources/samples/jacoco/java/build.gradle create mode 100644 buildSrc/src/test/resources/samples/jacoco/java/src/main/java/sample/TheClass.java create mode 100644 buildSrc/src/test/resources/samples/jacoco/java/src/test/java/sample/TheClassTest.java create mode 100644 buildSrc/src/test/resources/samples/javadocapi/multimodule/api/build.gradle create mode 100644 buildSrc/src/test/resources/samples/javadocapi/multimodule/api/src/main/java/sample/Api.java create mode 100644 buildSrc/src/test/resources/samples/javadocapi/multimodule/build.gradle create mode 100644 buildSrc/src/test/resources/samples/javadocapi/multimodule/impl/build.gradle create mode 100644 buildSrc/src/test/resources/samples/javadocapi/multimodule/impl/src/main/java/sample/Impl.java create mode 100644 buildSrc/src/test/resources/samples/javadocapi/multimodule/sample/build.gradle create mode 100644 buildSrc/src/test/resources/samples/javadocapi/multimodule/sample/src/main/java/sample/Sample.java create mode 100644 buildSrc/src/test/resources/samples/javadocapi/multimodule/settings.gradle create mode 100644 buildSrc/src/test/resources/samples/maven/install-with-springio/build.gradle create mode 100644 buildSrc/src/test/resources/samples/maven/install-with-springio/gradle/dependency-management.gradle create mode 100644 buildSrc/src/test/resources/samples/maven/install/build.gradle create mode 100644 buildSrc/src/test/resources/samples/maven/signing/build.gradle create mode 100644 buildSrc/src/test/resources/samples/maven/signing/settings.gradle create mode 100644 buildSrc/src/test/resources/samples/maven/upload/build.gradle create mode 100644 buildSrc/src/test/resources/samples/showcase/Jenkinsfile create mode 100644 buildSrc/src/test/resources/samples/showcase/bom/bom.gradle create mode 100644 buildSrc/src/test/resources/samples/showcase/build.gradle create mode 100644 buildSrc/src/test/resources/samples/showcase/etc/checkstyle/checkstyle.xml create mode 100644 buildSrc/src/test/resources/samples/showcase/gradle/dependency-management.gradle create mode 100644 buildSrc/src/test/resources/samples/showcase/samples/sgbcs-sample-war/build.gradle create mode 100644 buildSrc/src/test/resources/samples/showcase/samples/sgbcs-sample-war/src/integration-test/java/sample/HelloServletTest.java create mode 100644 buildSrc/src/test/resources/samples/showcase/samples/sgbcs-sample-war/src/main/java/sample/HelloServlet.java create mode 100644 buildSrc/src/test/resources/samples/showcase/settings.gradle create mode 100644 buildSrc/src/test/resources/samples/showcase/sgbcs-api/sgbcs-api.gradle create mode 100644 buildSrc/src/test/resources/samples/showcase/sgbcs-api/src/main/java/api/Api.java create mode 100644 buildSrc/src/test/resources/samples/showcase/sgbcs-api/src/test/java/api/ApiTest.java create mode 100644 buildSrc/src/test/resources/samples/showcase/sgbcs-core/sgbcs-core.gradle create mode 100644 buildSrc/src/test/resources/samples/showcase/sgbcs-core/src/main/java/core/CoreClass.java create mode 100644 buildSrc/src/test/resources/samples/showcase/sgbcs-core/src/main/java/core/HasOptional.java create mode 100644 buildSrc/src/test/resources/samples/showcase/sgbcs-core/src/main/resources/META-INF/spring.handlers create mode 100644 buildSrc/src/test/resources/samples/showcase/sgbcs-core/src/main/resources/META-INF/spring.schemas create mode 100644 buildSrc/src/test/resources/samples/showcase/sgbcs-core/src/main/resources/org/springframework/springgradlebuildsample/config/spring-springgradlebuildsample-2.0.xsd create mode 100644 buildSrc/src/test/resources/samples/showcase/sgbcs-core/src/main/resources/org/springframework/springgradlebuildsample/config/spring-springgradlebuildsample-2.1.xsd create mode 100644 buildSrc/src/test/resources/samples/showcase/sgbcs-core/src/main/resources/org/springframework/springgradlebuildsample/config/spring-springgradlebuildsample-2.2.xsd create mode 100644 buildSrc/src/test/resources/samples/showcase/sgbcs-core/src/test/java/core/CoreClassTest.java create mode 100644 buildSrc/src/test/resources/samples/showcase/sgbcs-core/src/test/java/core/HasOptionalTest.java create mode 100644 buildSrc/src/test/resources/samples/showcase/sgbcs-docs/sgbcs-docs.gradle create mode 100644 buildSrc/src/test/resources/samples/showcase/sgbcs-docs/src/docs/asciidoc/docinfo.html create mode 100644 buildSrc/src/test/resources/samples/showcase/sgbcs-docs/src/docs/asciidoc/images/sunset.jpg create mode 100644 buildSrc/src/test/resources/samples/showcase/sgbcs-docs/src/docs/asciidoc/index.adoc create mode 100644 buildSrc/src/test/resources/samples/showcase/sgbcs-docs/src/docs/asciidoc/subdir/_b.adoc create mode 100644 buildSrc/src/test/resources/samples/showcase/sgbcs-docs/src/docs/asciidoc/subdir/_c.adoc create mode 100644 buildSrc/src/test/resources/samples/showcase/sgbcs-docs/src/main/java/example/StringUtils.java create mode 100644 buildSrc/src/test/resources/samples/testsconfiguration/build.gradle create mode 100644 buildSrc/src/test/resources/samples/testsconfiguration/core/build.gradle create mode 100644 buildSrc/src/test/resources/samples/testsconfiguration/core/src/test/java/sample/Dependency.java create mode 100644 buildSrc/src/test/resources/samples/testsconfiguration/settings.gradle create mode 100644 buildSrc/src/test/resources/samples/testsconfiguration/web/build.gradle create mode 100644 buildSrc/src/test/resources/samples/testsconfiguration/web/src/test/java/sample/DependencyTest.java create mode 100644 buildSrc/src/test/resources/test-private.pgp diff --git a/build.gradle b/build.gradle index 818f6408bb..ca65936d4e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,5 @@ buildscript { dependencies { - classpath 'io.spring.gradle:spring-build-conventions:0.0.37' classpath "io.spring.javaformat:spring-javaformat-gradle-plugin:$springJavaformatVersion" classpath "org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion" classpath 'io.spring.nohttp:nohttp-gradle:0.0.5.RELEASE' @@ -75,4 +74,6 @@ if (hasProperty('buildScan')) { nohttp { allowlistFile = project.file("etc/nohttp/allowlist.lines") + source.exclude "buildSrc/build/**" + } diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index d3eeb801df..38061e9378 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -1,7 +1,14 @@ apply plugin: "java-gradle-plugin" +apply plugin: 'java' +apply plugin: 'groovy' + +sourceCompatibility = 1.8 repositories { + jcenter() + gradlePluginPortal() mavenCentral() + maven { url 'https://repo.spring.io/plugins-release/' } } gradlePlugin { @@ -17,12 +24,34 @@ gradlePlugin { } } -dependencies { - compile 'com.thaiopensource:trang:20091111' - compile 'net.sourceforge.saxon:saxon:9.1.0.8' +configurations { + implementation { + exclude module: 'groovy-all' + } } -task ide(type: Copy) { - from configurations.runtime - into 'ide' +dependencies { + implementation 'com.thaiopensource:trang:20091111' + implementation 'net.sourceforge.saxon:saxon:9.1.0.8' + implementation localGroovy() + + implementation 'com.github.ben-manes:gradle-versions-plugin:0.25.0' + implementation 'gradle.plugin.org.gretty:gretty:3.0.1' + 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' + implementation 'io.spring.nohttp:nohttp-gradle:0.0.5.RELEASE' + implementation 'org.asciidoctor:asciidoctor-gradle-jvm:3.1.0' + implementation 'org.asciidoctor:asciidoctor-gradle-jvm-pdf:3.1.0' + implementation 'org.hidetake:gradle-ssh-plugin:2.10.1' + implementation 'org.jfrog.buildinfo:build-info-extractor-gradle:4.9.10' + implementation 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.7.1' + + testImplementation 'junit:junit:4.12' + testImplementation 'org.apache.commons:commons-io:1.3.2' + testImplementation 'org.assertj:assertj-core:3.13.2' + testImplementation 'org.mockito:mockito-core:3.0.0' + testImplementation 'org.spockframework:spock-core:1.3-groovy-2.5' } diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/AbstractSpringJavaPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/AbstractSpringJavaPlugin.groovy new file mode 100644 index 0000000000..3c991dbade --- /dev/null +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/AbstractSpringJavaPlugin.groovy @@ -0,0 +1,88 @@ +/* + * 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 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; + +/** + * @author Rob Winch + */ +public abstract class AbstractSpringJavaPlugin implements Plugin { + + @Override + public 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"); + pluginManager.apply("io.spring.convention.dependency-set"); + pluginManager.apply("io.spring.convention.javadoc-options"); + pluginManager.apply("io.spring.convention.checkstyle"); + pluginManager.apply('com.github.ben-manes.versions'); + + copyPropertyFromRootProjectTo("group", project); + copyPropertyFromRootProjectTo("version", project); + copyPropertyFromRootProjectTo("description", project); + + project.jar { + manifest.attributes["Created-By"] = + "${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) { + project.setProperty(propertyName, property); + } + } + + protected abstract void additionalPlugins(Project project); +} diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/ArtifactoryPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/ArtifactoryPlugin.groovy new file mode 100644 index 0000000000..d21e08bc5f --- /dev/null +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/ArtifactoryPlugin.groovy @@ -0,0 +1,58 @@ +/* + * 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 +import org.gradle.api.Project + +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')) { + username = artifactoryUsername + password = artifactoryPassword + } + } + } + } + + project.artifactoryPublish { + publishIvy false + properties = [ + 'bintray.package': "${project.group}:${name}", + 'bintray.version': "${project.version}" + ] + } + + project.artifactory { + publish { + defaults { + publishConfigs('archives') + } + } + } + } +} \ No newline at end of file diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/CheckstylePlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/CheckstylePlugin.groovy new file mode 100644 index 0000000000..1bfbbecbdf --- /dev/null +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/CheckstylePlugin.groovy @@ -0,0 +1,49 @@ +/* + * 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.Plugin +import org.gradle.api.Project +import org.gradle.api.plugins.JavaPlugin + +/** + * Adds and configures Checkstyle plugin. + * + * @author Vedran Pavic + */ +class CheckstylePlugin implements Plugin { + + final CHECKSTYLE_DIR = 'etc/checkstyle' + + @Override + void apply(Project project) { + project.plugins.withType(JavaPlugin) { + def checkstyleDir = project.rootProject.file(CHECKSTYLE_DIR) + if (checkstyleDir.exists() && checkstyleDir.directory) { + project.getPluginManager().apply('checkstyle') + project.dependencies.add('checkstyle', 'io.spring.javaformat:spring-javaformat-checkstyle:0.0.15') + project.dependencies.add('checkstyle', 'io.spring.nohttp:nohttp-checkstyle:0.0.3.RELEASE') + + project.checkstyle { + configDir = checkstyleDir + 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 new file mode 100644 index 0000000000..f70afc1b6b --- /dev/null +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/DependencyManagementExportTask.groovy @@ -0,0 +1,61 @@ +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/DependencySetPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/DependencySetPlugin.groovy new file mode 100644 index 0000000000..02b0037e28 --- /dev/null +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/DependencySetPlugin.groovy @@ -0,0 +1,126 @@ +/* + * 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 +import org.gradle.api.Project +import org.gradle.api.plugins.JavaPlugin + +/** + * Adds sets of dependencies to make it easy to add a grouping of dependencies. The + * dependencies added are: + * + *
    + *
  • sockDependencies
  • + *
  • seleniumDependencies
  • + *
  • gebDependencies
  • + *
  • powerMockDependencies
  • + *
  • slf4jDependencies
  • + *
  • jstlDependencies
  • + *
  • apachedsDependencies
  • + *
+ * + * @author Rob Winch + */ +public class DependencySetPlugin implements Plugin { + @Override + public void apply(Project project) { + + project.ext.spockDependencies = [ + project.dependencies.create("org.spockframework:spock-spring") { + exclude group: 'junit', module: 'junit-dep' + }, + project.dependencies.create("org.spockframework:spock-core") { + exclude group: 'junit', module: 'junit-dep' + } + ] + + project.ext.seleniumDependencies = [ + "org.seleniumhq.selenium:htmlunit-driver", + "org.seleniumhq.selenium:selenium-support" + ] + + project.ext.gebDependencies = project.spockDependencies + + project.seleniumDependencies + [ + "org.gebish:geb-spock", + 'commons-httpclient:commons-httpclient', + "org.codehaus.groovy:groovy", + "org.codehaus.groovy:groovy-all" + ] + + project.ext.powerMockDependencies = [ + "org.powermock:powermock-core", + "org.powermock:powermock-api-support", + "org.powermock:powermock-module-junit4-common", + "org.powermock:powermock-module-junit4", + project.dependencies.create("org.powermock:powermock-api-mockito") { + exclude group: 'org.mockito', module: 'mockito-all' + }, + "org.powermock:powermock-reflect" + ] + + project.ext.powerMock2Dependencies = [ + "org.powermock:powermock-core", + "org.powermock:powermock-api-support", + "org.powermock:powermock-module-junit4-common", + "org.powermock:powermock-module-junit4", + project.dependencies.create("org.powermock:powermock-api-mockito2") { + exclude group: 'org.mockito', module: 'mockito-all' + }, + "org.powermock:powermock-reflect" + ] + + project.ext.slf4jDependencies = [ + "org.slf4j:slf4j-api", + "org.slf4j:jcl-over-slf4j", + "org.slf4j:log4j-over-slf4j", + "ch.qos.logback:logback-classic" + ] + + project.ext.springCoreDependency = [ + project.dependencies.create("org.springframework:spring-core") { + exclude(group: 'commons-logging', module: 'commons-logging') + } + ] + + project.ext.testDependencies = [ + "junit:junit", + "org.mockito:mockito-core", + "org.springframework:spring-test", + "org.assertj:assertj-core" + ] + + project.ext.jstlDependencies = [ + "javax.servlet.jsp.jstl:javax.servlet.jsp.jstl-api", + "org.apache.taglibs:taglibs-standard-jstlel" + ] + + project.ext.apachedsDependencies = [ + "org.apache.directory.server:apacheds-core", + "org.apache.directory.server:apacheds-core-entry", + "org.apache.directory.server:apacheds-protocol-shared", + "org.apache.directory.server:apacheds-protocol-ldap", + "org.apache.directory.server:apacheds-server-jndi", + 'org.apache.directory.shared:shared-ldap' + ] + + project.plugins.withType(JavaPlugin) { + project.dependencies { + testCompile project.testDependencies + } + } + } +} diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/DeployDocsPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/DeployDocsPlugin.groovy new file mode 100644 index 0000000000..bf1add5065 --- /dev/null +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/DeployDocsPlugin.groovy @@ -0,0 +1,82 @@ +/* + * 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.plugins.JavaPlugin +import org.gradle.api.tasks.bundling.Zip +import org.gradle.api.Plugin +import org.gradle.api.Project + +public class DeployDocsPlugin implements Plugin { + + @Override + public void apply(Project project) { + project.getPluginManager().apply('org.hidetake.ssh') + + project.ssh.settings { + knownHosts = allowAnyHosts + } + project.remotes { + docs { + 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) + 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') + } + } + } + + project.task('deployDocs') { + dependsOn 'docsZip' + doFirst { + project.ssh.run { + session(project.remotes.docs) { + def now = System.currentTimeMillis() + def name = project.rootProject.name + def version = project.rootProject.version + def tempPath = "/tmp/${name}-${now}-docs/".replaceAll(' ', '_') + execute "mkdir -p $tempPath" + + project.tasks.docsZip.outputs.each { o -> + put from: o.files, into: tempPath + } + + execute "unzip $tempPath*.zip -d $tempPath" + + def extractPath = "/var/www/domains/spring.io/docs/htdocs/autorepo/docs/${name}/${version}/" + + execute "rm -rf $extractPath" + execute "mkdir -p $extractPath" + execute "mv $tempPath/docs/* $extractPath" + execute "chmod -R g+w $extractPath" + } + } + } + } + } +} \ No newline at end of file diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/DocsPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/DocsPlugin.groovy new file mode 100644 index 0000000000..0eb1ad42a1 --- /dev/null +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/DocsPlugin.groovy @@ -0,0 +1,73 @@ +package io.spring.gradle.convention + +import org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask +import org.gradle.api.Action +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.Task +import org.gradle.api.artifacts.Configuration +import org.gradle.api.artifacts.DependencySet +import org.gradle.api.plugins.PluginManager +import org.gradle.api.tasks.Sync +import org.gradle.api.tasks.bundling.Zip + +/** + * Aggregates asciidoc, javadoc, and deploying of the docs into a single plugin + */ +public class DocsPlugin implements Plugin { + + @Override + public void apply(Project project) { + + PluginManager pluginManager = project.getPluginManager(); + pluginManager.apply("org.asciidoctor.jvm.convert"); + pluginManager.apply("org.asciidoctor.jvm.pdf"); + pluginManager.apply(AsciidoctorConventionPlugin); + pluginManager.apply(DeployDocsPlugin); + pluginManager.apply(JavadocApiPlugin); + + String projectName = Utils.getProjectName(project); + String pdfFilename = projectName + "-reference.pdf"; + + project.tasks.withType(AbstractAsciidoctorTask) { t -> + project.configure(t) { + sources { + include "**/*.adoc" + exclude '_*/**' + } + } + } + + + Task docsZip = project.tasks.create('docsZip', Zip) { + dependsOn 'api', 'asciidoctor' + group = 'Distribution' + baseName = project.rootProject.name + classifier = 'docs' + description = "Builds -${classifier} archive containing all " + + "Docs for deployment at docs.spring.io" + + from(project.tasks.asciidoctor.outputs) { + into 'reference/html5' + include '**' + } + from(project.tasks.asciidoctorPdf.outputs) { + into 'reference/pdf' + include '**' + rename "index.pdf", pdfFilename + } + from(project.tasks.api.outputs) { + into 'api' + } + into 'docs' + duplicatesStrategy 'exclude' + } + + Task docs = project.tasks.create("docs") { + group = 'Documentation' + description 'An aggregator task to generate all the documentation' + dependsOn docsZip + } + project.tasks.assemble.dependsOn docs + } +} diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/IntegrationTestPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/IntegrationTestPlugin.groovy new file mode 100644 index 0000000000..5fda90d74f --- /dev/null +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/IntegrationTestPlugin.groovy @@ -0,0 +1,121 @@ +/* + * Copyright 2016-2018 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.propdeps.PropDepsPlugin +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.Task +import org.gradle.api.plugins.GroovyPlugin +import org.gradle.api.plugins.JavaPlugin +import org.gradle.api.tasks.testing.Test +import org.gradle.plugins.ide.eclipse.EclipsePlugin +import org.gradle.plugins.ide.idea.IdeaPlugin + +/** + * + * Adds support for integration tests to java projects. + * + *
    + *
  • Adds integrationTestCompile and integrationTestRuntime configurations
  • + *
  • A new source test folder of src/integration-test/java has been added
  • + *
  • A task to run integration tests named integrationTest is added
  • + *
  • If Groovy plugin is added a new source test folder src/integration-test/groovy is added
  • + *
+ * + * @author Rob Winch + */ +public class IntegrationTestPlugin implements Plugin { + + @Override + public void apply(Project project) { + project.plugins.withType(JavaPlugin.class) { + applyJava(project) + } + } + + private applyJava(Project project) { + if(!project.file('src/integration-test/').exists()) { + // ensure we don't add if no tests to avoid adding Gretty + return + } + project.configurations { + integrationTestCompile { + extendsFrom testCompile + } + integrationTestRuntime { + extendsFrom integrationTestCompile, testRuntime + } + } + + project.sourceSets { + integrationTest { + java.srcDir project.file('src/integration-test/java') + resources.srcDir project.file('src/integration-test/resources') + compileClasspath = project.sourceSets.main.output + project.sourceSets.test.output + project.configurations.integrationTestCompile + runtimeClasspath = output + compileClasspath + project.configurations.integrationTestRuntime + } + } + + Task integrationTestTask = project.tasks.create("integrationTest", Test) { + group = 'Verification' + description = 'Runs the integration tests.' + dependsOn 'jar' + testClassesDirs = project.sourceSets.integrationTest.output.classesDirs + classpath = project.sourceSets.integrationTest.runtimeClasspath + shouldRunAfter project.tasks.test + } + project.tasks.check.dependsOn integrationTestTask + + project.plugins.withType(IdeaPlugin) { + project.idea { + module { + testSourceDirs += project.file('src/integration-test/java') + scopes.TEST.plus += [ project.configurations.integrationTestCompile ] + } + } + } + + project.plugins.withType(GroovyPlugin) { + project.sourceSets { + integrationTest { + groovy.srcDirs project.file('src/integration-test/groovy') + } + } + project.plugins.withType(IdeaPlugin) { + project.idea { + module { + testSourceDirs += project.file('src/integration-test/groovy') + } + } + } + } + + project.plugins.withType(PropDepsPlugin) { + project.configurations { + integrationTestCompile { + extendsFrom optional, provided + } + } + } + + project.plugins.withType(EclipsePlugin) { + project.eclipse.classpath { + plusConfigurations += [ project.configurations.integrationTestCompile ] + } + } + } +} diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/JacocoPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/JacocoPlugin.groovy new file mode 100644 index 0000000000..900cf9f144 --- /dev/null +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/JacocoPlugin.groovy @@ -0,0 +1,41 @@ +/* + * Copyright 2016-2018 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.JavaPlugin + +/** + * Adds a version of jacoco to use and makes check depend on jacocoTestReport. + * + * @author Rob Winch + */ +class JacocoPlugin implements Plugin { + + @Override + void apply(Project project) { + project.plugins.withType(JavaPlugin) { + project.getPluginManager().apply("jacoco") + project.tasks.check.dependsOn project.tasks.jacocoTestReport + + project.jacoco { + toolVersion = '0.8.2' + } + } + } +} diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/JavadocApiPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/JavadocApiPlugin.groovy new file mode 100644 index 0000000000..fc18e4e7af --- /dev/null +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/JavadocApiPlugin.groovy @@ -0,0 +1,105 @@ +/* + * 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 java.io.File; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; +import java.util.regex.Pattern; + +import org.gradle.api.Action; +import org.gradle.api.Plugin; +import org.gradle.api.Project; +import org.gradle.api.plugins.JavaPluginConvention; +import org.gradle.api.tasks.SourceSet; +import org.gradle.api.tasks.javadoc.Javadoc; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Rob Winch + */ +public class JavadocApiPlugin implements Plugin { + Logger logger = LoggerFactory.getLogger(getClass()); + Set excludes = Collections.singleton(Pattern.compile("test")); + + @Override + public void apply(Project project) { + logger.info("Applied"); + Project rootProject = project.getRootProject(); + + + //Task docs = project.getTasks().findByPath("docs") ?: project.getTasks().create("docs"); + Javadoc api = project.getTasks().create("api", Javadoc); + + api.setGroup("Documentation"); + api.setDescription("Generates aggregated Javadoc API documentation."); + + Set subprojects = rootProject.getSubprojects(); + for (Project subproject : subprojects) { + addProject(api, subproject); + } + + if (subprojects.isEmpty()) { + addProject(api, project); + } + + api.setMaxMemory("1024m"); + api.setDestinationDir(new File(project.getBuildDir(), "api")); + + project.getPluginManager().apply("io.spring.convention.javadoc-options"); + } + + public void setExcludes(String... excludes) { + if(excludes == null) { + this.excludes = Collections.emptySet(); + } + this.excludes = new HashSet(excludes.length); + for(String exclude : excludes) { + this.excludes.add(Pattern.compile(exclude)); + } + } + + private void addProject(final Javadoc api, final Project project) { + for(Pattern exclude : excludes) { + if(exclude.matcher(project.getName()).matches()) { + logger.info("Skipping {} because it is excluded by {}", project, exclude); + return; + } + } + logger.info("Try add sources for {}", project); + project.getPlugins().withType(SpringModulePlugin.class).all(new Action() { + @Override + public void execute(SpringModulePlugin plugin) { + logger.info("Added sources for {}", project); + + JavaPluginConvention java = project.getConvention().getPlugin(JavaPluginConvention.class); + SourceSet mainSourceSet = java.getSourceSets().getByName("main"); + + api.setSource(api.getSource().plus(mainSourceSet.getAllJava())); + project.getTasks().withType(Javadoc.class).all(new Action() { + @Override + public void execute(Javadoc projectJavadoc) { + api.setClasspath(api.getClasspath().plus(projectJavadoc.getClasspath())); + } + }); + } + }); + } +} + diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/JavadocOptionsPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/JavadocOptionsPlugin.groovy new file mode 100644 index 0000000000..e0fef7ecbe --- /dev/null +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/JavadocOptionsPlugin.groovy @@ -0,0 +1,15 @@ +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 { + + @Override + public 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 new file mode 100644 index 0000000000..8631723e3e --- /dev/null +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/ManagementConfigurationPlugin.java @@ -0,0 +1,33 @@ +package io.spring.gradle.convention; + +import org.gradle.api.Action; +import org.gradle.api.Plugin; +import org.gradle.api.Project; +import org.gradle.api.artifacts.Configuration; + +/** + * https://github.com/gradle/gradle/issues/7576#issuecomment-434637595 + * @author Rob Winch + */ +public class ManagementConfigurationPlugin implements Plugin { + @Override + public void apply(Project project) { + Configuration management = project.getConfigurations() + .create("management", new Action() { + @Override + public void execute(Configuration configuration) { + configuration.setCanBeResolved(false); + configuration.setCanBeConsumed(false); + configuration.setDescription("Used for setting Gradle constraints that impact all configurations that can be resolved"); + } + }); + project.getConfigurations().all(new Action() { + @Override + public void execute(Configuration configuration) { + if (configuration.isCanBeResolved()) { + configuration.extendsFrom(management); + } + } + }); + } +} diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/MavenBomPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/MavenBomPlugin.groovy new file mode 100644 index 0000000000..92ce552feb --- /dev/null +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/MavenBomPlugin.groovy @@ -0,0 +1,54 @@ +package io.spring.gradle.convention + +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.plugins.JavaPlugin +import org.gradle.api.plugins.MavenPlugin +import org.gradle.plugins.signing.SigningPlugin +import org.sonarqube.gradle.SonarQubePlugin + +public class MavenBomPlugin implements Plugin { + static String MAVEN_BOM_TASK_NAME = "mavenBom" + + public void apply(Project project) { + project.configurations { + archives + } + project.plugins.apply('io.spring.convention.artifactory') + project.plugins.apply('io.spring.convention.maven') + project.plugins.apply(MavenPlugin) + project.plugins.apply(SigningPlugin) + project.plugins.apply("io.spring.convention.ossrh") + + project.group = project.rootProject.group + project.task(MAVEN_BOM_TASK_NAME, type: MavenBomTask, group: 'Generate', description: 'Configures the pom as a Maven Build of Materials (BOM)') + project.install.dependsOn project.mavenBom + project.tasks.uploadArchives.dependsOn project.mavenBom + project.tasks.artifactoryPublish.dependsOn project.mavenBom + + project.plugins.withType(SonarQubePlugin) { + project.sonarqube.skipProject = true + } + + project.rootProject.allprojects.each { p -> + p.plugins.withType(io.spring.gradle.convention.SpringMavenPlugin) { + if (!project.name.equals(p.name)) { + project.mavenBom.projects.add(p) + } + } + } + + def deployArtifacts = project.task("deployArtifacts") + deployArtifacts.group = 'Deploy tasks' + deployArtifacts.description = "Deploys the artifacts to either Artifactor or Maven Central" + if(Utils.isRelease(project)) { + deployArtifacts.dependsOn project.tasks.uploadArchives + } else { + deployArtifacts.dependsOn project.tasks.artifactoryPublish + } + + project.artifacts { + archives project.mavenBom.bomFile + } + } +} diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/MavenBomTask.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/MavenBomTask.groovy new file mode 100644 index 0000000000..beaf4acfbc --- /dev/null +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/MavenBomTask.groovy @@ -0,0 +1,87 @@ +package io.spring.gradle.convention + +import org.gradle.api.DefaultTask +import org.gradle.api.Project +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.Internal +import org.gradle.api.tasks.OutputFile +import org.gradle.api.tasks.TaskAction + +public class MavenBomTask extends DefaultTask { + + @Internal + Set projects = [] + + @OutputFile + File bomFile + + @Input + Set getProjectNames() { + return projects*.name as Set + } + + public MavenBomTask() { + this.group = "Generate" + this.description = "Generates a Maven Build of Materials (BOM). See https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Importing_Dependencies" + this.projects = project.subprojects + this.bomFile = project.file("${->project.buildDir}/maven-bom/${->project.name}-${->project.version}.txt") + this.outputs.upToDateWhen { false } + } + + @TaskAction + public void configureBom() { +// project.configurations.archives.artifacts.clear() + bomFile.parentFile.mkdirs() + bomFile.write("Maven Build of Materials (BOM). See https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Importing_Dependencies") + project.artifacts { + // work around GRADLE-2406 by attaching text artifact + archives(bomFile) + } + project.install { + repositories.mavenInstaller { + pom.whenConfigured { + packaging = "pom" + withXml { + asNode().children().last() + { + delegate.dependencyManagement { + delegate.dependencies { + projects.sort { dep -> "$dep.group:$dep.name" }.each { p -> + + delegate.dependency { + delegate.groupId(p.group) + delegate.artifactId(p.name) + delegate.version(p.version) + } + } + } + } + } + } + } + } + } + project.uploadArchives { + repositories.mavenDeployer { + pom.whenConfigured { + packaging = "pom" + withXml { + asNode().children().last() + { + delegate.dependencyManagement { + delegate.dependencies { + projects.sort { dep -> "$dep.group:$dep.name" }.each { p -> + + delegate.dependency { + delegate.groupId(p.group) + delegate.artifactId(p.name) + delegate.version(p.version) + } + } + } + } + } + } + } + } + } + } +} diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/MergePlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/MergePlugin.groovy new file mode 100644 index 0000000000..cd7e61c573 --- /dev/null +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/MergePlugin.groovy @@ -0,0 +1,182 @@ +/* + * Copyright 2002-2015 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.* +import org.gradle.api.artifacts.Configuration +import org.gradle.api.artifacts.ProjectDependency; +import org.gradle.api.artifacts.maven.Conf2ScopeMapping +import org.gradle.api.plugins.MavenPlugin +import org.gradle.plugins.ide.eclipse.EclipsePlugin +import org.gradle.plugins.ide.idea.IdeaPlugin +import org.gradle.api.invocation.* + +/** + * Gradle plugin that allows projects to merged together. Primarily developed to + * allow Spring to support multiple incompatible versions of third-party + * dependencies (for example Hibernate v3 and v4). + *

+ * The 'merge' extension should be used to define how projects are merged, for example: + *

+ * configure(subprojects) {
+ *     apply plugin: MergePlugin
+ * }
+ *
+ * project("myproject") {
+ * }
+ *
+ * project("myproject-extra") {
+ *     merge.into = project("myproject")
+ * }
+ * 
+ *

+ * This plugin adds two new configurations: + *