├── .gitignore ├── .travis.yml ├── Jenkinsfile ├── build.gradle ├── gradle.properties ├── gradle ├── artifactory.gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── s101plugin.state ├── settings.gradle └── src ├── main ├── groovy │ └── io │ │ └── spring │ │ └── gradle │ │ └── convention │ │ ├── AbstractSpringJavaPlugin.groovy │ │ ├── ArtifactoryPlugin.groovy │ │ ├── CheckstylePlugin.groovy │ │ ├── DependencyManagementExportTask.groovy │ │ ├── DependencySetPlugin.groovy │ │ ├── DeployDocsPlugin.groovy │ │ ├── DocsPlugin.groovy │ │ ├── IntegrationTestPlugin.groovy │ │ ├── JacocoPlugin.groovy │ │ ├── JavadocApiPlugin.groovy │ │ ├── JavadocOptionsPlugin.groovy │ │ ├── ManagementConfigurationPlugin.java │ │ ├── MavenBomPlugin.groovy │ │ ├── MavenBomTask.groovy │ │ ├── MergePlugin.groovy │ │ ├── OssrhPlugin.groovy │ │ ├── RepositoryConventionPlugin.groovy │ │ ├── RootProjectPlugin.groovy │ │ ├── SchemaDeployPlugin.groovy │ │ ├── SchemaPlugin.groovy │ │ ├── SchemaZipPlugin.groovy │ │ ├── SortedProperties.groovy │ │ ├── SpringDependencyManagementConventionPlugin.groovy │ │ ├── SpringMavenPlugin.groovy │ │ ├── SpringModulePlugin.groovy │ │ ├── SpringPomPlugin.groovy │ │ ├── SpringSampleBootPlugin.groovy │ │ ├── SpringSamplePlugin.groovy │ │ ├── SpringSampleWarPlugin.groovy │ │ ├── SpringTestPlugin.groovy │ │ ├── TestsConfigurationPlugin.groovy │ │ └── Utils.groovy ├── java │ └── io │ │ └── spring │ │ └── gradle │ │ └── convention │ │ └── AsciidoctorConventionPlugin.java └── resources │ └── META-INF │ └── gradle-plugins │ ├── io.spring.convention.artifactory.properties │ ├── io.spring.convention.bom.properties │ ├── io.spring.convention.checkstyle.properties │ ├── io.spring.convention.dependency-set.properties │ ├── io.spring.convention.docs.properties │ ├── io.spring.convention.integration-test.properties │ ├── io.spring.convention.jacoco.properties │ ├── io.spring.convention.javadoc-api.properties │ ├── io.spring.convention.javadoc-options.properties │ ├── io.spring.convention.maven.properties │ ├── io.spring.convention.merge.properties │ ├── io.spring.convention.ossrh.properties │ ├── io.spring.convention.repository.properties │ ├── io.spring.convention.root.properties │ ├── io.spring.convention.spring-module.properties │ ├── io.spring.convention.spring-pom.properties │ ├── io.spring.convention.spring-sample-boot.properties │ ├── io.spring.convention.spring-sample-war.properties │ ├── io.spring.convention.spring-sample.properties │ ├── io.spring.convention.spring-test.properties │ ├── io.spring.convention.springdependencymangement.properties │ └── io.spring.convention.tests-configuration.properties └── test ├── groovy └── io │ └── spring │ └── gradle │ ├── convention │ ├── DependencySetPluginITest.groovy │ ├── DocsPluginITest.groovy │ ├── IntegrationTestPluginITest.groovy │ ├── JacocoPluginITest.groovy │ ├── JavadocApiPluginITest.groovy │ ├── ShowcaseITest.groovy │ ├── SpringMavenPluginITest.groovy │ └── TestsConfigurationPluginITest.groovy │ └── testkit │ └── junit │ └── rules │ └── TestKit.java ├── java └── io │ └── spring │ └── gradle │ └── convention │ ├── IntegrationPluginTest.java │ ├── JavadocApiPluginTest.java │ ├── RepositoryConventionPluginTests.java │ └── UtilsTest.java └── resources ├── samples ├── dependencyset │ ├── build.gradle │ └── gradle │ │ └── dependency-management.gradle ├── docs │ ├── missing-attribute │ │ ├── build.gradle │ │ ├── settings.gradle │ │ └── src │ │ │ └── docs │ │ │ └── asciidoc │ │ │ └── index.adoc │ ├── missing-cross-reference │ │ ├── build.gradle │ │ ├── settings.gradle │ │ └── src │ │ │ └── docs │ │ │ └── asciidoc │ │ │ └── index.adoc │ ├── missing-include │ │ ├── build.gradle │ │ ├── settings.gradle │ │ └── src │ │ │ └── docs │ │ │ └── asciidoc │ │ │ └── index.adoc │ └── simple │ │ ├── build.gradle │ │ ├── settings.gradle │ │ └── src │ │ ├── docs │ │ └── asciidoc │ │ │ ├── docinfo.html │ │ │ ├── images │ │ │ └── sunset.jpg │ │ │ ├── index.adoc │ │ │ └── subdir │ │ │ ├── _b.adoc │ │ │ └── _c.adoc │ │ └── main │ │ └── java │ │ └── example │ │ └── StringUtils.java ├── integrationtest │ ├── withgroovy │ │ ├── build.gradle │ │ └── src │ │ │ └── integration-test │ │ │ └── groovy │ │ │ └── sample │ │ │ └── TheTest.groovy │ ├── withjava │ │ ├── build.gradle │ │ └── src │ │ │ └── integration-test │ │ │ └── java │ │ │ └── sample │ │ │ └── TheTest.java │ └── withpropdeps │ │ ├── build.gradle │ │ └── src │ │ └── integration-test │ │ └── java │ │ └── sample │ │ └── TheTest.java ├── jacoco │ └── java │ │ ├── build.gradle │ │ └── src │ │ ├── main │ │ └── java │ │ │ └── sample │ │ │ └── TheClass.java │ │ └── test │ │ └── java │ │ └── sample │ │ └── TheClassTest.java ├── javadocapi │ └── multimodule │ │ ├── api │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── sample │ │ │ └── Api.java │ │ ├── build.gradle │ │ ├── impl │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── sample │ │ │ └── Impl.java │ │ ├── sample │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── sample │ │ │ └── Sample.java │ │ └── settings.gradle ├── maven │ ├── install-with-springio │ │ ├── build.gradle │ │ └── gradle │ │ │ └── dependency-management.gradle │ ├── install │ │ └── build.gradle │ ├── signing │ │ ├── build.gradle │ │ └── settings.gradle │ └── upload │ │ └── build.gradle ├── showcase │ ├── Jenkinsfile │ ├── bom │ │ └── bom.gradle │ ├── build.gradle │ ├── etc │ │ └── checkstyle │ │ │ └── checkstyle.xml │ ├── gradle │ │ └── dependency-management.gradle │ ├── samples │ │ └── sgbcs-sample-war │ │ │ ├── build.gradle │ │ │ └── src │ │ │ ├── integration-test │ │ │ └── java │ │ │ │ └── sample │ │ │ │ └── HelloServletTest.java │ │ │ └── main │ │ │ └── java │ │ │ └── sample │ │ │ └── HelloServlet.java │ ├── settings.gradle │ ├── sgbcs-api │ │ ├── sgbcs-api.gradle │ │ └── src │ │ │ ├── main │ │ │ └── java │ │ │ │ └── api │ │ │ │ └── Api.java │ │ │ └── test │ │ │ └── java │ │ │ └── api │ │ │ └── ApiTest.java │ ├── sgbcs-core │ │ ├── sgbcs-core.gradle │ │ └── src │ │ │ ├── main │ │ │ ├── java │ │ │ │ └── core │ │ │ │ │ ├── CoreClass.java │ │ │ │ │ └── HasOptional.java │ │ │ └── resources │ │ │ │ ├── META-INF │ │ │ │ ├── spring.handlers │ │ │ │ └── spring.schemas │ │ │ │ └── org │ │ │ │ └── springframework │ │ │ │ └── springgradlebuildsample │ │ │ │ └── config │ │ │ │ ├── spring-springgradlebuildsample-2.0.xsd │ │ │ │ ├── spring-springgradlebuildsample-2.1.xsd │ │ │ │ └── spring-springgradlebuildsample-2.2.xsd │ │ │ └── test │ │ │ └── java │ │ │ └── core │ │ │ ├── CoreClassTest.java │ │ │ └── HasOptionalTest.java │ └── sgbcs-docs │ │ ├── sgbcs-docs.gradle │ │ └── src │ │ ├── docs │ │ └── asciidoc │ │ │ ├── docinfo.html │ │ │ ├── images │ │ │ └── sunset.jpg │ │ │ ├── index.adoc │ │ │ └── subdir │ │ │ ├── _b.adoc │ │ │ └── _c.adoc │ │ └── main │ │ └── java │ │ └── example │ │ └── StringUtils.java └── testsconfiguration │ ├── build.gradle │ ├── core │ ├── build.gradle │ └── src │ │ └── test │ │ └── java │ │ └── sample │ │ └── Dependency.java │ ├── settings.gradle │ └── web │ ├── build.gradle │ └── src │ └── test │ └── java │ └── sample │ └── DependencyTest.java └── test-private.pgp /.gitignore: -------------------------------------------------------------------------------- 1 | .classpath 2 | .settings 3 | .project 4 | *.iml 5 | .idea 6 | bin 7 | target 8 | build 9 | .gradle 10 | out/ -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | 3 | jdk: oraclejdk8 4 | 5 | before_cache: 6 | - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock 7 | - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ 8 | 9 | cache: 10 | directories: 11 | - $HOME/.gradle/caches/ 12 | - $HOME/.gradle/wrapper/ 13 | 14 | install: true 15 | 16 | script: ./gradlew clean build --refresh-dependencies --no-daemon 17 | -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | properties([ 2 | buildDiscarder(logRotator(numToKeepStr: '10')), 3 | pipelineTriggers([ 4 | cron('@daily') 5 | ]), 6 | ]) 7 | 8 | stage('Artifactory Deploy') { 9 | node('linux') { 10 | checkout scm 11 | sh 'git clean -dfx' 12 | withCredentials([usernamePassword(credentialsId: '02bd1690-b54f-4c9f-819d-a77cb7a9822c', usernameVariable: 'ARTIFACTORY_USERNAME', passwordVariable: 'ARTIFACTORY_PASSWORD')]) { 13 | withEnv(["JAVA_HOME=${tool 'jdk8'}"]) { 14 | sh './gradlew check artifactoryPublish --no-daemon --refresh-dependencies --stacktrace -PartifactoryUsername=$ARTIFACTORY_USERNAME -PartifactoryPassword=$ARTIFACTORY_PASSWORD' 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "java-gradle-plugin" 3 | id "com.jfrog.artifactory" version '4.9.10' 4 | id 'com.github.ben-manes.versions' version '0.25.0' 5 | } 6 | 7 | apply plugin: 'java' 8 | apply plugin: 'groovy' 9 | apply plugin: 'maven' 10 | apply from: "$rootDir/gradle/artifactory.gradle" 11 | 12 | group 'io.spring.gradle' 13 | 14 | sourceCompatibility = 1.8 15 | 16 | repositories { 17 | jcenter() 18 | gradlePluginPortal() 19 | mavenCentral() 20 | maven { url 'https://repo.spring.io/plugins-release/' } 21 | } 22 | 23 | configurations { 24 | implementation { 25 | exclude module: 'groovy-all' 26 | } 27 | } 28 | 29 | dependencies { 30 | implementation localGroovy() 31 | 32 | implementation 'com.github.ben-manes:gradle-versions-plugin:0.25.0' 33 | implementation 'gradle.plugin.org.gretty:gretty:3.0.1' 34 | implementation 'io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.21.1' 35 | implementation 'io.spring.gradle:dependency-management-plugin:1.0.9.RELEASE' 36 | implementation 'io.spring.gradle:docbook-reference-plugin:0.3.1' 37 | implementation 'io.spring.gradle:propdeps-plugin:0.0.10.RELEASE' 38 | implementation 'io.spring.javaformat:spring-javaformat-gradle-plugin:0.0.15' 39 | implementation 'io.spring.nohttp:nohttp-gradle:0.0.3.RELEASE' 40 | implementation 'org.asciidoctor:asciidoctor-gradle-jvm:3.1.0' 41 | implementation 'org.asciidoctor:asciidoctor-gradle-jvm-pdf:3.1.0' 42 | implementation 'org.hidetake:gradle-ssh-plugin:2.10.1' 43 | implementation 'org.jfrog.buildinfo:build-info-extractor-gradle:4.9.10' 44 | implementation 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.7.1' 45 | 46 | testImplementation 'junit:junit:4.12' 47 | testImplementation 'org.apache.commons:commons-io:1.3.2' 48 | testImplementation 'org.assertj:assertj-core:3.13.2' 49 | testImplementation 'org.mockito:mockito-core:3.0.0' 50 | testImplementation 'org.spockframework:spock-core:1.3-groovy-2.5' 51 | } 52 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | version=0.0.39-SNAPSHOT 2 | -------------------------------------------------------------------------------- /gradle/artifactory.gradle: -------------------------------------------------------------------------------- 1 | def isSnapshot = version?.matches(/^.*-SNAPSHOT$/) 2 | 3 | artifactory { 4 | contextUrl = 'https://repo.spring.io' 5 | publish { 6 | repository { 7 | repoKey = isSnapshot ? 'plugins-snapshot-local' : 'plugins-release-local' 8 | if(project.hasProperty('artifactoryUsername')) { 9 | username = artifactoryUsername 10 | password = artifactoryPassword 11 | } 12 | } 13 | } 14 | } 15 | 16 | artifactoryPublish { 17 | publishConfigs 'archives' 18 | publishIvy false 19 | properties = [ 20 | 'bintray.package': "${project.group}:spring-build-conventions", 21 | 'bintray.version': "${project.version}" 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-gradle-plugins/spring-build-conventions/1527cecd379b865b8b70a85acea3c8e25068fb77/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | # Determine the Java command to use to start the JVM. 86 | if [ -n "$JAVA_HOME" ] ; then 87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 88 | # IBM's JDK on AIX uses strange locations for the executables 89 | JAVACMD="$JAVA_HOME/jre/sh/java" 90 | else 91 | JAVACMD="$JAVA_HOME/bin/java" 92 | fi 93 | if [ ! -x "$JAVACMD" ] ; then 94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 95 | 96 | Please set the JAVA_HOME variable in your environment to match the 97 | location of your Java installation." 98 | fi 99 | else 100 | JAVACMD="java" 101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 102 | 103 | Please set the JAVA_HOME variable in your environment to match the 104 | location of your Java installation." 105 | fi 106 | 107 | # Increase the maximum file descriptors if we can. 108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 109 | MAX_FD_LIMIT=`ulimit -H -n` 110 | if [ $? -eq 0 ] ; then 111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 112 | MAX_FD="$MAX_FD_LIMIT" 113 | fi 114 | ulimit -n $MAX_FD 115 | if [ $? -ne 0 ] ; then 116 | warn "Could not set maximum file descriptor limit: $MAX_FD" 117 | fi 118 | else 119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 120 | fi 121 | fi 122 | 123 | # For Darwin, add options to specify how the application appears in the dock 124 | if $darwin; then 125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 126 | fi 127 | 128 | # For Cygwin or MSYS, switch paths to Windows format before running java 129 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 132 | JAVACMD=`cygpath --unix "$JAVACMD"` 133 | 134 | # We build the pattern for arguments to be converted via cygpath 135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 136 | SEP="" 137 | for dir in $ROOTDIRSRAW ; do 138 | ROOTDIRS="$ROOTDIRS$SEP$dir" 139 | SEP="|" 140 | done 141 | OURCYGPATTERN="(^($ROOTDIRS))" 142 | # Add a user-defined pattern to the cygpath arguments 143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 145 | fi 146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 147 | i=0 148 | for arg in "$@" ; do 149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 151 | 152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 154 | else 155 | eval `echo args$i`="\"$arg\"" 156 | fi 157 | i=`expr $i + 1` 158 | done 159 | case $i in 160 | 0) set -- ;; 161 | 1) set -- "$args0" ;; 162 | 2) set -- "$args0" "$args1" ;; 163 | 3) set -- "$args0" "$args1" "$args2" ;; 164 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 165 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 166 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 167 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 168 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 169 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 170 | esac 171 | fi 172 | 173 | # Escape application args 174 | save () { 175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 176 | echo " " 177 | } 178 | APP_ARGS=`save "$@"` 179 | 180 | # Collect all arguments for the java command, following the shell quoting and substitution rules 181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 182 | 183 | exec "$JAVACMD" "$@" 184 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 34 | 35 | @rem Find java.exe 36 | if defined JAVA_HOME goto findJavaFromJavaHome 37 | 38 | set JAVA_EXE=java.exe 39 | %JAVA_EXE% -version >NUL 2>&1 40 | if "%ERRORLEVEL%" == "0" goto init 41 | 42 | echo. 43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 44 | echo. 45 | echo Please set the JAVA_HOME variable in your environment to match the 46 | echo location of your Java installation. 47 | 48 | goto fail 49 | 50 | :findJavaFromJavaHome 51 | set JAVA_HOME=%JAVA_HOME:"=% 52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 53 | 54 | if exist "%JAVA_EXE%" goto init 55 | 56 | echo. 57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 58 | echo. 59 | echo Please set the JAVA_HOME variable in your environment to match the 60 | echo location of your Java installation. 61 | 62 | goto fail 63 | 64 | :init 65 | @rem Get command-line arguments, handling Windows variants 66 | 67 | if not "%OS%" == "Windows_NT" goto win9xME_args 68 | 69 | :win9xME_args 70 | @rem Slurp the command line arguments. 71 | set CMD_LINE_ARGS= 72 | set _SKIP=2 73 | 74 | :win9xME_args_slurp 75 | if "x%~1" == "x" goto execute 76 | 77 | set CMD_LINE_ARGS=%* 78 | 79 | :execute 80 | @rem Setup the command line 81 | 82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 83 | 84 | @rem Execute Gradle 85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 86 | 87 | :end 88 | @rem End local scope for the variables with windows NT shell 89 | if "%ERRORLEVEL%"=="0" goto mainEnd 90 | 91 | :fail 92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 93 | rem the _cmd.exe /c_ return code! 94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 95 | exit /b 1 96 | 97 | :mainEnd 98 | if "%OS%"=="Windows_NT" endlocal 99 | 100 | :omega 101 | -------------------------------------------------------------------------------- /s101plugin.state: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'spring-build-conventions' 2 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/AbstractSpringJavaPlugin.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package io.spring.gradle.convention; 18 | 19 | import io.spring.gradle.propdeps.PropDepsMavenPlugin; 20 | import org.gradle.api.Plugin; 21 | import org.gradle.api.Project; 22 | import org.gradle.api.plugins.GroovyPlugin; 23 | import org.gradle.api.plugins.JavaPlugin; 24 | import org.gradle.api.plugins.MavenPlugin; 25 | import org.gradle.api.plugins.PluginManager; 26 | import org.gradle.internal.impldep.org.apache.maven.Maven; 27 | import org.gradle.plugins.ide.eclipse.EclipseWtpPlugin; 28 | import org.gradle.plugins.ide.idea.IdeaPlugin; 29 | import io.spring.gradle.propdeps.PropDepsEclipsePlugin; 30 | import io.spring.gradle.propdeps.PropDepsIdeaPlugin; 31 | import io.spring.gradle.propdeps.PropDepsPlugin; 32 | 33 | /** 34 | * @author Rob Winch 35 | */ 36 | public abstract class AbstractSpringJavaPlugin implements Plugin { 37 | 38 | @Override 39 | public final void apply(Project project) { 40 | PluginManager pluginManager = project.getPluginManager(); 41 | pluginManager.apply(JavaPlugin.class); 42 | pluginManager.apply(ManagementConfigurationPlugin.class); 43 | if (project.file("src/main/groovy").exists() 44 | || project.file("src/test/groovy").exists() 45 | || project.file("src/integration-test/groovy").exists()) { 46 | pluginManager.apply(GroovyPlugin.class); 47 | } 48 | pluginManager.apply("io.spring.convention.repository"); 49 | pluginManager.apply(EclipseWtpPlugin); 50 | pluginManager.apply(IdeaPlugin); 51 | pluginManager.apply(PropDepsPlugin); 52 | pluginManager.apply(PropDepsEclipsePlugin); 53 | pluginManager.apply(PropDepsIdeaPlugin); 54 | project.getPlugins().withType(MavenPlugin) { 55 | pluginManager.apply(PropDepsMavenPlugin); 56 | } 57 | pluginManager.apply("io.spring.convention.tests-configuration"); 58 | pluginManager.apply("io.spring.convention.integration-test"); 59 | pluginManager.apply("io.spring.convention.springdependencymangement"); 60 | pluginManager.apply("io.spring.convention.dependency-set"); 61 | pluginManager.apply("io.spring.convention.javadoc-options"); 62 | pluginManager.apply("io.spring.convention.checkstyle"); 63 | pluginManager.apply('com.github.ben-manes.versions'); 64 | 65 | copyPropertyFromRootProjectTo("group", project); 66 | copyPropertyFromRootProjectTo("version", project); 67 | copyPropertyFromRootProjectTo("description", project); 68 | 69 | project.jar { 70 | manifest.attributes["Created-By"] = 71 | "${System.getProperty("java.version")} (${System.getProperty("java.specification.vendor")})" 72 | manifest.attributes["Implementation-Title"] = project.name 73 | manifest.attributes["Implementation-Version"] = project.version 74 | manifest.attributes["Automatic-Module-Name"] = project.name.replace('-', '.') 75 | } 76 | additionalPlugins(project); 77 | } 78 | 79 | private void copyPropertyFromRootProjectTo(String propertyName, Project project) { 80 | Project rootProject = project.getRootProject(); 81 | Object property = rootProject.findProperty(propertyName); 82 | if(property != null) { 83 | project.setProperty(propertyName, property); 84 | } 85 | } 86 | 87 | protected abstract void additionalPlugins(Project project); 88 | } 89 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/ArtifactoryPlugin.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package io.spring.gradle.convention 17 | 18 | import org.gradle.api.Plugin 19 | import org.gradle.api.Project 20 | 21 | class ArtifactoryPlugin implements Plugin { 22 | 23 | @Override 24 | void apply(Project project) { 25 | project.plugins.apply('com.jfrog.artifactory') 26 | String name = Utils.getProjectName(project); 27 | boolean isSnapshot = Utils.isSnapshot(project); 28 | boolean isMilestone = Utils.isMilestone(project); 29 | project.artifactory { 30 | contextUrl = 'https://repo.spring.io' 31 | publish { 32 | repository { 33 | repoKey = isSnapshot ? 'libs-snapshot-local' : isMilestone ? 'libs-milestone-local' : 'libs-release-local' 34 | if(project.hasProperty('artifactoryUsername')) { 35 | username = artifactoryUsername 36 | password = artifactoryPassword 37 | } 38 | } 39 | } 40 | } 41 | 42 | project.artifactoryPublish { 43 | publishIvy false 44 | properties = [ 45 | 'bintray.package': "${project.group}:${name}", 46 | 'bintray.version': "${project.version}" 47 | ] 48 | } 49 | 50 | project.artifactory { 51 | publish { 52 | defaults { 53 | publishConfigs('archives') 54 | } 55 | } 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/CheckstylePlugin.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package io.spring.gradle.convention 18 | 19 | import org.gradle.api.Plugin 20 | import org.gradle.api.Project 21 | import org.gradle.api.plugins.JavaPlugin 22 | 23 | /** 24 | * Adds and configures Checkstyle plugin. 25 | * 26 | * @author Vedran Pavic 27 | */ 28 | class CheckstylePlugin implements Plugin { 29 | 30 | final CHECKSTYLE_DIR = 'etc/checkstyle' 31 | 32 | @Override 33 | void apply(Project project) { 34 | project.plugins.withType(JavaPlugin) { 35 | def checkstyleDir = project.rootProject.file(CHECKSTYLE_DIR) 36 | if (checkstyleDir.exists() && checkstyleDir.directory) { 37 | project.getPluginManager().apply('checkstyle') 38 | project.dependencies.add('checkstyle', 'io.spring.javaformat:spring-javaformat-checkstyle:0.0.15') 39 | project.dependencies.add('checkstyle', 'io.spring.nohttp:nohttp-checkstyle:0.0.3.RELEASE') 40 | 41 | project.checkstyle { 42 | configDir = checkstyleDir 43 | toolVersion = '8.21' 44 | } 45 | } 46 | } 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/DependencyManagementExportTask.groovy: -------------------------------------------------------------------------------- 1 | package io.spring.gradle.convention 2 | 3 | import org.gradle.api.Project 4 | import org.gradle.api.artifacts.component.ModuleComponentSelector 5 | import org.gradle.api.tasks.Input 6 | import org.gradle.api.tasks.Internal; 7 | 8 | import java.io.File; 9 | import java.io.FileOutputStream; 10 | import java.io.IOException; 11 | import java.io.OutputStream; 12 | import java.util.Map; 13 | import java.util.Properties; 14 | 15 | import org.gradle.api.DefaultTask; 16 | import org.gradle.api.artifacts.Configuration; 17 | import org.gradle.api.tasks.TaskAction; 18 | 19 | import io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension; 20 | 21 | public class DependencyManagementExportTask extends DefaultTask { 22 | @Internal 23 | def projects; 24 | 25 | @Input 26 | String getProjectNames() { 27 | return projects*.name 28 | } 29 | 30 | @TaskAction 31 | public void dependencyManagementExport() throws IOException { 32 | def projects = this.projects ?: project.subprojects + project 33 | def configurations = projects*.configurations*.findAll { ['testRuntime','integrationTestRuntime','grettyRunnerTomcat8','ajtools'].contains(it.name) } 34 | def dependencyResults = configurations*.incoming*.resolutionResult*.allDependencies.flatten() 35 | def moduleVersionVersions = dependencyResults.findAll { r -> r.requested instanceof ModuleComponentSelector }.collect { r-> r.selected.moduleVersion } 36 | 37 | def projectDependencies = projects.collect { p-> "${p.group}:${p.name}:${p.version}".toString() } as Set 38 | def dependencies = moduleVersionVersions.collect { d -> 39 | "${d.group}:${d.name}:${d.version}".toString() 40 | }.sort() as Set 41 | 42 | println '' 43 | println '' 44 | println 'dependencyManagement {' 45 | println '\tdependencies {' 46 | dependencies.findAll { d-> !projectDependencies.contains(d)}.each { 47 | println "\t\tdependency '$it'" 48 | } 49 | println '\t}' 50 | println '}' 51 | println '' 52 | println '' 53 | println 'TIP Use this to find duplicates:\n$ sort gradle/dependency-management.gradle| uniq -c | grep -v \'^\\s*1\'' 54 | println '' 55 | println '' 56 | } 57 | 58 | void setOutputFile(File file) throws IOException { 59 | this.output = new FileOutputStream(file); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/DependencySetPlugin.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package io.spring.gradle.convention; 17 | 18 | import org.gradle.api.Plugin 19 | import org.gradle.api.Project 20 | import org.gradle.api.plugins.JavaPlugin 21 | 22 | /** 23 | * Adds sets of dependencies to make it easy to add a grouping of dependencies. The 24 | * dependencies added are: 25 | * 26 | * 27 | * sockDependencies 28 | * seleniumDependencies 29 | * gebDependencies 30 | * powerMockDependencies 31 | * slf4jDependencies 32 | * jstlDependencies 33 | * apachedsDependencies 34 | * 35 | * 36 | * @author Rob Winch 37 | */ 38 | public class DependencySetPlugin implements Plugin { 39 | @Override 40 | public void apply(Project project) { 41 | 42 | project.ext.spockDependencies = [ 43 | project.dependencies.create("org.spockframework:spock-spring") { 44 | exclude group: 'junit', module: 'junit-dep' 45 | }, 46 | project.dependencies.create("org.spockframework:spock-core") { 47 | exclude group: 'junit', module: 'junit-dep' 48 | } 49 | ] 50 | 51 | project.ext.seleniumDependencies = [ 52 | "org.seleniumhq.selenium:htmlunit-driver", 53 | "org.seleniumhq.selenium:selenium-support" 54 | ] 55 | 56 | project.ext.gebDependencies = project.spockDependencies + 57 | project.seleniumDependencies + [ 58 | "org.gebish:geb-spock", 59 | 'commons-httpclient:commons-httpclient', 60 | "org.codehaus.groovy:groovy", 61 | "org.codehaus.groovy:groovy-all" 62 | ] 63 | 64 | project.ext.powerMockDependencies = [ 65 | "org.powermock:powermock-core", 66 | "org.powermock:powermock-api-support", 67 | "org.powermock:powermock-module-junit4-common", 68 | "org.powermock:powermock-module-junit4", 69 | project.dependencies.create("org.powermock:powermock-api-mockito") { 70 | exclude group: 'org.mockito', module: 'mockito-all' 71 | }, 72 | "org.powermock:powermock-reflect" 73 | ] 74 | 75 | project.ext.powerMock2Dependencies = [ 76 | "org.powermock:powermock-core", 77 | "org.powermock:powermock-api-support", 78 | "org.powermock:powermock-module-junit4-common", 79 | "org.powermock:powermock-module-junit4", 80 | project.dependencies.create("org.powermock:powermock-api-mockito2") { 81 | exclude group: 'org.mockito', module: 'mockito-all' 82 | }, 83 | "org.powermock:powermock-reflect" 84 | ] 85 | 86 | project.ext.slf4jDependencies = [ 87 | "org.slf4j:slf4j-api", 88 | "org.slf4j:jcl-over-slf4j", 89 | "org.slf4j:log4j-over-slf4j", 90 | "ch.qos.logback:logback-classic" 91 | ] 92 | 93 | project.ext.springCoreDependency = [ 94 | project.dependencies.create("org.springframework:spring-core") { 95 | exclude(group: 'commons-logging', module: 'commons-logging') 96 | } 97 | ] 98 | 99 | project.ext.testDependencies = [ 100 | "junit:junit", 101 | "org.mockito:mockito-core", 102 | "org.springframework:spring-test", 103 | "org.assertj:assertj-core" 104 | ] 105 | 106 | project.ext.jstlDependencies = [ 107 | "javax.servlet.jsp.jstl:javax.servlet.jsp.jstl-api", 108 | "org.apache.taglibs:taglibs-standard-jstlel" 109 | ] 110 | 111 | project.ext.apachedsDependencies = [ 112 | "org.apache.directory.server:apacheds-core", 113 | "org.apache.directory.server:apacheds-core-entry", 114 | "org.apache.directory.server:apacheds-protocol-shared", 115 | "org.apache.directory.server:apacheds-protocol-ldap", 116 | "org.apache.directory.server:apacheds-server-jndi", 117 | 'org.apache.directory.shared:shared-ldap' 118 | ] 119 | 120 | project.plugins.withType(JavaPlugin) { 121 | project.dependencies { 122 | testCompile project.testDependencies 123 | } 124 | } 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/DeployDocsPlugin.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package io.spring.gradle.convention 17 | 18 | import org.gradle.api.plugins.JavaPlugin 19 | import org.gradle.api.tasks.bundling.Zip 20 | import org.gradle.api.Plugin 21 | import org.gradle.api.Project 22 | 23 | public class DeployDocsPlugin implements Plugin { 24 | 25 | @Override 26 | public void apply(Project project) { 27 | project.getPluginManager().apply('org.hidetake.ssh') 28 | 29 | project.ssh.settings { 30 | knownHosts = allowAnyHosts 31 | } 32 | project.remotes { 33 | docs { 34 | role 'docs' 35 | if (project.hasProperty('deployDocsHost')) { 36 | host = project.findProperty('deployDocsHost') 37 | } else { 38 | host = 'docs-ip.spring.io' 39 | } 40 | retryCount = 5 // retry 5 times (default is 0) 41 | retryWaitSec = 10 // wait 10 seconds between retries (default is 0) 42 | user = project.findProperty('deployDocsSshUsername') 43 | if (project.hasProperty('deployDocsSshKeyPath')) { 44 | identity = project.file(project.findProperty('deployDocsSshKeyPath')) 45 | } else if (project.hasProperty('deployDocsSshKey')) { 46 | identity = project.findProperty('deployDocsSshKey') 47 | } 48 | if(project.hasProperty('deployDocsSshPassphrase')) { 49 | passphrase = project.findProperty('deployDocsSshPassphrase') 50 | } 51 | } 52 | } 53 | 54 | project.task('deployDocs') { 55 | dependsOn 'docsZip' 56 | doFirst { 57 | project.ssh.run { 58 | session(project.remotes.docs) { 59 | def now = System.currentTimeMillis() 60 | def name = project.rootProject.name 61 | def version = project.rootProject.version 62 | def tempPath = "/tmp/${name}-${now}-docs/".replaceAll(' ', '_') 63 | execute "mkdir -p $tempPath" 64 | 65 | project.tasks.docsZip.outputs.each { o -> 66 | put from: o.files, into: tempPath 67 | } 68 | 69 | execute "unzip $tempPath*.zip -d $tempPath" 70 | 71 | def extractPath = "/var/www/domains/spring.io/docs/htdocs/autorepo/docs/${name}/${version}/" 72 | 73 | execute "rm -rf $extractPath" 74 | execute "mkdir -p $extractPath" 75 | execute "mv $tempPath/docs/* $extractPath" 76 | execute "chmod -R g+w $extractPath" 77 | } 78 | } 79 | } 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/DocsPlugin.groovy: -------------------------------------------------------------------------------- 1 | package io.spring.gradle.convention 2 | 3 | import org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask 4 | import org.gradle.api.Action 5 | import org.gradle.api.Plugin 6 | import org.gradle.api.Project 7 | import org.gradle.api.Task 8 | import org.gradle.api.artifacts.Configuration 9 | import org.gradle.api.artifacts.DependencySet 10 | import org.gradle.api.plugins.PluginManager 11 | import org.gradle.api.tasks.Sync 12 | import org.gradle.api.tasks.bundling.Zip 13 | 14 | /** 15 | * Aggregates asciidoc, javadoc, and deploying of the docs into a single plugin 16 | */ 17 | public class DocsPlugin implements Plugin { 18 | 19 | @Override 20 | public void apply(Project project) { 21 | 22 | PluginManager pluginManager = project.getPluginManager(); 23 | pluginManager.apply("org.asciidoctor.jvm.convert"); 24 | pluginManager.apply("org.asciidoctor.jvm.pdf"); 25 | pluginManager.apply(AsciidoctorConventionPlugin); 26 | pluginManager.apply(DeployDocsPlugin); 27 | pluginManager.apply(JavadocApiPlugin); 28 | 29 | String projectName = Utils.getProjectName(project); 30 | String pdfFilename = projectName + "-reference.pdf"; 31 | 32 | project.tasks.withType(AbstractAsciidoctorTask) { t -> 33 | project.configure(t) { 34 | sources { 35 | include "**/*.adoc" 36 | exclude '_*/**' 37 | } 38 | } 39 | } 40 | 41 | 42 | Task docsZip = project.tasks.create('docsZip', Zip) { 43 | dependsOn 'api', 'asciidoctor' 44 | group = 'Distribution' 45 | baseName = project.rootProject.name 46 | classifier = 'docs' 47 | description = "Builds -${classifier} archive containing all " + 48 | "Docs for deployment at docs.spring.io" 49 | 50 | from(project.tasks.asciidoctor.outputs) { 51 | into 'reference/html5' 52 | include '**' 53 | } 54 | from(project.tasks.asciidoctorPdf.outputs) { 55 | into 'reference/pdf' 56 | include '**' 57 | rename "index.pdf", pdfFilename 58 | } 59 | from(project.tasks.api.outputs) { 60 | into 'api' 61 | } 62 | into 'docs' 63 | duplicatesStrategy 'exclude' 64 | } 65 | 66 | Task docs = project.tasks.create("docs") { 67 | group = 'Documentation' 68 | description 'An aggregator task to generate all the documentation' 69 | dependsOn docsZip 70 | } 71 | project.tasks.assemble.dependsOn docs 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/IntegrationTestPlugin.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package io.spring.gradle.convention 17 | 18 | import io.spring.gradle.propdeps.PropDepsPlugin 19 | import org.gradle.api.Plugin 20 | import org.gradle.api.Project 21 | import org.gradle.api.Task 22 | import org.gradle.api.plugins.GroovyPlugin 23 | import org.gradle.api.plugins.JavaPlugin 24 | import org.gradle.api.tasks.testing.Test 25 | import org.gradle.plugins.ide.eclipse.EclipsePlugin 26 | import org.gradle.plugins.ide.idea.IdeaPlugin 27 | 28 | /** 29 | * 30 | * Adds support for integration tests to java projects. 31 | * 32 | * 33 | * Adds integrationTestCompile and integrationTestRuntime configurations 34 | * A new source test folder of src/integration-test/java has been added 35 | * A task to run integration tests named integrationTest is added 36 | * If Groovy plugin is added a new source test folder src/integration-test/groovy is added 37 | * 38 | * 39 | * @author Rob Winch 40 | */ 41 | public class IntegrationTestPlugin implements Plugin { 42 | 43 | @Override 44 | public void apply(Project project) { 45 | project.plugins.withType(JavaPlugin.class) { 46 | applyJava(project) 47 | } 48 | } 49 | 50 | private applyJava(Project project) { 51 | if(!project.file('src/integration-test/').exists()) { 52 | // ensure we don't add if no tests to avoid adding Gretty 53 | return 54 | } 55 | project.configurations { 56 | integrationTestCompile { 57 | extendsFrom testCompile 58 | } 59 | integrationTestRuntime { 60 | extendsFrom integrationTestCompile, testRuntime 61 | } 62 | } 63 | 64 | project.sourceSets { 65 | integrationTest { 66 | java.srcDir project.file('src/integration-test/java') 67 | resources.srcDir project.file('src/integration-test/resources') 68 | compileClasspath = project.sourceSets.main.output + project.sourceSets.test.output + project.configurations.integrationTestCompile 69 | runtimeClasspath = output + compileClasspath + project.configurations.integrationTestRuntime 70 | } 71 | } 72 | 73 | Task integrationTestTask = project.tasks.create("integrationTest", Test) { 74 | group = 'Verification' 75 | description = 'Runs the integration tests.' 76 | dependsOn 'jar' 77 | testClassesDirs = project.sourceSets.integrationTest.output.classesDirs 78 | classpath = project.sourceSets.integrationTest.runtimeClasspath 79 | shouldRunAfter project.tasks.test 80 | } 81 | project.tasks.check.dependsOn integrationTestTask 82 | 83 | project.plugins.withType(IdeaPlugin) { 84 | project.idea { 85 | module { 86 | testSourceDirs += project.file('src/integration-test/java') 87 | scopes.TEST.plus += [ project.configurations.integrationTestCompile ] 88 | } 89 | } 90 | } 91 | 92 | project.plugins.withType(GroovyPlugin) { 93 | project.sourceSets { 94 | integrationTest { 95 | groovy.srcDirs project.file('src/integration-test/groovy') 96 | } 97 | } 98 | project.plugins.withType(IdeaPlugin) { 99 | project.idea { 100 | module { 101 | testSourceDirs += project.file('src/integration-test/groovy') 102 | } 103 | } 104 | } 105 | } 106 | 107 | project.plugins.withType(PropDepsPlugin) { 108 | project.configurations { 109 | integrationTestCompile { 110 | extendsFrom optional, provided 111 | } 112 | } 113 | } 114 | 115 | project.plugins.withType(EclipsePlugin) { 116 | project.eclipse.classpath { 117 | plusConfigurations += [ project.configurations.integrationTestCompile ] 118 | } 119 | } 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/JacocoPlugin.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package io.spring.gradle.convention 18 | 19 | import org.gradle.api.Plugin 20 | import org.gradle.api.Project 21 | import org.gradle.api.plugins.JavaPlugin 22 | 23 | /** 24 | * Adds a version of jacoco to use and makes check depend on jacocoTestReport. 25 | * 26 | * @author Rob Winch 27 | */ 28 | class JacocoPlugin implements Plugin { 29 | 30 | @Override 31 | void apply(Project project) { 32 | project.plugins.withType(JavaPlugin) { 33 | project.getPluginManager().apply("jacoco") 34 | project.tasks.check.dependsOn project.tasks.jacocoTestReport 35 | 36 | project.jacoco { 37 | toolVersion = '0.8.2' 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/JavadocApiPlugin.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package io.spring.gradle.convention; 18 | 19 | import java.io.File; 20 | import java.util.Collections; 21 | import java.util.HashSet; 22 | import java.util.Set; 23 | import java.util.regex.Pattern; 24 | 25 | import org.gradle.api.Action; 26 | import org.gradle.api.Plugin; 27 | import org.gradle.api.Project; 28 | import org.gradle.api.plugins.JavaPluginConvention; 29 | import org.gradle.api.tasks.SourceSet; 30 | import org.gradle.api.tasks.javadoc.Javadoc; 31 | import org.slf4j.Logger; 32 | import org.slf4j.LoggerFactory; 33 | 34 | /** 35 | * @author Rob Winch 36 | */ 37 | public class JavadocApiPlugin implements Plugin { 38 | Logger logger = LoggerFactory.getLogger(getClass()); 39 | Set excludes = Collections.singleton(Pattern.compile("test")); 40 | 41 | @Override 42 | public void apply(Project project) { 43 | logger.info("Applied"); 44 | Project rootProject = project.getRootProject(); 45 | 46 | 47 | //Task docs = project.getTasks().findByPath("docs") ?: project.getTasks().create("docs"); 48 | Javadoc api = project.getTasks().create("api", Javadoc); 49 | 50 | api.setGroup("Documentation"); 51 | api.setDescription("Generates aggregated Javadoc API documentation."); 52 | 53 | Set subprojects = rootProject.getSubprojects(); 54 | for (Project subproject : subprojects) { 55 | addProject(api, subproject); 56 | } 57 | 58 | if (subprojects.isEmpty()) { 59 | addProject(api, project); 60 | } 61 | 62 | api.setMaxMemory("1024m"); 63 | api.setDestinationDir(new File(project.getBuildDir(), "api")); 64 | 65 | project.getPluginManager().apply("io.spring.convention.javadoc-options"); 66 | } 67 | 68 | public void setExcludes(String... excludes) { 69 | if(excludes == null) { 70 | this.excludes = Collections.emptySet(); 71 | } 72 | this.excludes = new HashSet(excludes.length); 73 | for(String exclude : excludes) { 74 | this.excludes.add(Pattern.compile(exclude)); 75 | } 76 | } 77 | 78 | private void addProject(final Javadoc api, final Project project) { 79 | for(Pattern exclude : excludes) { 80 | if(exclude.matcher(project.getName()).matches()) { 81 | logger.info("Skipping {} because it is excluded by {}", project, exclude); 82 | return; 83 | } 84 | } 85 | logger.info("Try add sources for {}", project); 86 | project.getPlugins().withType(SpringModulePlugin.class).all(new Action() { 87 | @Override 88 | public void execute(SpringModulePlugin plugin) { 89 | logger.info("Added sources for {}", project); 90 | 91 | JavaPluginConvention java = project.getConvention().getPlugin(JavaPluginConvention.class); 92 | SourceSet mainSourceSet = java.getSourceSets().getByName("main"); 93 | 94 | api.setSource(api.getSource().plus(mainSourceSet.getAllJava())); 95 | project.getTasks().withType(Javadoc.class).all(new Action() { 96 | @Override 97 | public void execute(Javadoc projectJavadoc) { 98 | api.setClasspath(api.getClasspath().plus(projectJavadoc.getClasspath())); 99 | } 100 | }); 101 | } 102 | }); 103 | } 104 | } 105 | 106 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/JavadocOptionsPlugin.groovy: -------------------------------------------------------------------------------- 1 | package io.spring.gradle.convention 2 | 3 | import org.gradle.api.Plugin 4 | import org.gradle.api.Project 5 | import org.gradle.api.tasks.javadoc.Javadoc 6 | 7 | public class JavadocOptionsPlugin implements Plugin { 8 | 9 | @Override 10 | public void apply(Project project) { 11 | project.getTasks().withType(Javadoc).all { t-> 12 | t.options.addStringOption('Xdoclint:none', '-quiet') 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/ManagementConfigurationPlugin.java: -------------------------------------------------------------------------------- 1 | package io.spring.gradle.convention; 2 | 3 | import org.gradle.api.Action; 4 | import org.gradle.api.Plugin; 5 | import org.gradle.api.Project; 6 | import org.gradle.api.artifacts.Configuration; 7 | 8 | /** 9 | * https://github.com/gradle/gradle/issues/7576#issuecomment-434637595 10 | * @author Rob Winch 11 | */ 12 | public class ManagementConfigurationPlugin implements Plugin { 13 | @Override 14 | public void apply(Project project) { 15 | Configuration management = project.getConfigurations() 16 | .create("management", new Action() { 17 | @Override 18 | public void execute(Configuration configuration) { 19 | configuration.setCanBeResolved(false); 20 | configuration.setCanBeConsumed(false); 21 | configuration.setDescription("Used for setting Gradle constraints that impact all configurations that can be resolved"); 22 | } 23 | }); 24 | project.getConfigurations().all(new Action() { 25 | @Override 26 | public void execute(Configuration configuration) { 27 | if (configuration.isCanBeResolved()) { 28 | configuration.extendsFrom(management); 29 | } 30 | } 31 | }); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/MavenBomPlugin.groovy: -------------------------------------------------------------------------------- 1 | package io.spring.gradle.convention 2 | 3 | import org.gradle.api.Plugin 4 | import org.gradle.api.Project 5 | import org.gradle.api.plugins.JavaPlugin 6 | import org.gradle.api.plugins.MavenPlugin 7 | import org.gradle.plugins.signing.SigningPlugin 8 | import org.sonarqube.gradle.SonarQubePlugin 9 | 10 | public class MavenBomPlugin implements Plugin { 11 | static String MAVEN_BOM_TASK_NAME = "mavenBom" 12 | 13 | public void apply(Project project) { 14 | project.configurations { 15 | archives 16 | } 17 | project.plugins.apply('io.spring.convention.artifactory') 18 | project.plugins.apply('io.spring.convention.maven') 19 | project.plugins.apply(MavenPlugin) 20 | project.plugins.apply(SigningPlugin) 21 | project.plugins.apply("io.spring.convention.ossrh") 22 | 23 | project.group = project.rootProject.group 24 | project.task(MAVEN_BOM_TASK_NAME, type: MavenBomTask, group: 'Generate', description: 'Configures the pom as a Maven Build of Materials (BOM)') 25 | project.install.dependsOn project.mavenBom 26 | project.tasks.uploadArchives.dependsOn project.mavenBom 27 | project.tasks.artifactoryPublish.dependsOn project.mavenBom 28 | 29 | project.plugins.withType(SonarQubePlugin) { 30 | project.sonarqube.skipProject = true 31 | } 32 | 33 | project.rootProject.allprojects.each { p -> 34 | p.plugins.withType(io.spring.gradle.convention.SpringMavenPlugin) { 35 | if (!project.name.equals(p.name)) { 36 | project.mavenBom.projects.add(p) 37 | } 38 | } 39 | } 40 | 41 | def deployArtifacts = project.task("deployArtifacts") 42 | deployArtifacts.group = 'Deploy tasks' 43 | deployArtifacts.description = "Deploys the artifacts to either Artifactor or Maven Central" 44 | if(Utils.isRelease(project)) { 45 | deployArtifacts.dependsOn project.tasks.uploadArchives 46 | } else { 47 | deployArtifacts.dependsOn project.tasks.artifactoryPublish 48 | } 49 | 50 | project.artifacts { 51 | archives project.mavenBom.bomFile 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/MavenBomTask.groovy: -------------------------------------------------------------------------------- 1 | package io.spring.gradle.convention 2 | 3 | import org.gradle.api.DefaultTask 4 | import org.gradle.api.Project 5 | import org.gradle.api.tasks.Input 6 | import org.gradle.api.tasks.Internal 7 | import org.gradle.api.tasks.OutputFile 8 | import org.gradle.api.tasks.TaskAction 9 | 10 | public class MavenBomTask extends DefaultTask { 11 | 12 | @Internal 13 | Set projects = [] 14 | 15 | @OutputFile 16 | File bomFile 17 | 18 | @Input 19 | Set getProjectNames() { 20 | return projects*.name as Set 21 | } 22 | 23 | public MavenBomTask() { 24 | this.group = "Generate" 25 | this.description = "Generates a Maven Build of Materials (BOM). See https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Importing_Dependencies" 26 | this.projects = project.subprojects 27 | this.bomFile = project.file("${->project.buildDir}/maven-bom/${->project.name}-${->project.version}.txt") 28 | this.outputs.upToDateWhen { false } 29 | } 30 | 31 | @TaskAction 32 | public void configureBom() { 33 | // project.configurations.archives.artifacts.clear() 34 | bomFile.parentFile.mkdirs() 35 | bomFile.write("Maven Build of Materials (BOM). See https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Importing_Dependencies") 36 | project.artifacts { 37 | // work around GRADLE-2406 by attaching text artifact 38 | archives(bomFile) 39 | } 40 | project.install { 41 | repositories.mavenInstaller { 42 | pom.whenConfigured { 43 | packaging = "pom" 44 | withXml { 45 | asNode().children().last() + { 46 | delegate.dependencyManagement { 47 | delegate.dependencies { 48 | projects.sort { dep -> "$dep.group:$dep.name" }.each { p -> 49 | 50 | delegate.dependency { 51 | delegate.groupId(p.group) 52 | delegate.artifactId(p.name) 53 | delegate.version(p.version) 54 | } 55 | } 56 | } 57 | } 58 | } 59 | } 60 | } 61 | } 62 | } 63 | project.uploadArchives { 64 | repositories.mavenDeployer { 65 | pom.whenConfigured { 66 | packaging = "pom" 67 | withXml { 68 | asNode().children().last() + { 69 | delegate.dependencyManagement { 70 | delegate.dependencies { 71 | projects.sort { dep -> "$dep.group:$dep.name" }.each { p -> 72 | 73 | delegate.dependency { 74 | delegate.groupId(p.group) 75 | delegate.artifactId(p.name) 76 | delegate.version(p.version) 77 | } 78 | } 79 | } 80 | } 81 | } 82 | } 83 | } 84 | } 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/MergePlugin.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.gradle.convention 18 | 19 | import org.gradle.api.* 20 | import org.gradle.api.artifacts.Configuration 21 | import org.gradle.api.artifacts.ProjectDependency; 22 | import org.gradle.api.artifacts.maven.Conf2ScopeMapping 23 | import org.gradle.api.plugins.MavenPlugin 24 | import org.gradle.plugins.ide.eclipse.EclipsePlugin 25 | import org.gradle.plugins.ide.idea.IdeaPlugin 26 | import org.gradle.api.invocation.* 27 | 28 | /** 29 | * Gradle plugin that allows projects to merged together. Primarily developed to 30 | * allow Spring to support multiple incompatible versions of third-party 31 | * dependencies (for example Hibernate v3 and v4). 32 | * 33 | * The 'merge' extension should be used to define how projects are merged, for example: 34 | * 35 | * configure(subprojects) { 36 | * apply plugin: MergePlugin 37 | * } 38 | * 39 | * project("myproject") { 40 | * } 41 | * 42 | * project("myproject-extra") { 43 | * merge.into = project("myproject") 44 | * } 45 | * 46 | * 47 | * This plugin adds two new configurations: 48 | * 49 | * merging - Contains the projects being merged into this project 50 | * runtimeMerge - Contains all dependencies that are merge projects. These are used 51 | * to allow an IDE to reference merge projects. 52 | * 53 | * 54 | * @author Rob Winch 55 | * @author Phillip Webb 56 | */ 57 | class MergePlugin implements Plugin { 58 | 59 | private static boolean attachedProjectsEvaluated; 60 | 61 | public void apply(Project project) { 62 | project.plugins.apply(MavenPlugin) 63 | project.plugins.apply(EclipsePlugin) 64 | project.plugins.apply(IdeaPlugin) 65 | 66 | MergeModel model = project.extensions.create("merge", MergeModel) 67 | model.project = project 68 | project.configurations.create("merging") 69 | Configuration runtimeMerge = project.configurations.create("runtimeMerge") 70 | 71 | // Ensure the IDE can reference merged projects 72 | project.eclipse.classpath.plusConfigurations += [ runtimeMerge ] 73 | project.idea.module.scopes.PROVIDED.plus += [ runtimeMerge ] 74 | 75 | // Hook to perform the actual merge logic 76 | project.afterEvaluate{ 77 | if (it.merge.into != null) { 78 | setup(it) 79 | } 80 | setupIdeDependencies(it) 81 | } 82 | 83 | // Hook to build runtimeMerge dependencies 84 | if (!attachedProjectsEvaluated) { 85 | project.gradle.projectsEvaluated{ 86 | postProcessProjects(it) 87 | } 88 | attachedProjectsEvaluated = true; 89 | } 90 | } 91 | 92 | private void setup(Project project) { 93 | project.merge.into.dependencies.add("merging", project) 94 | project.dependencies.add("provided", project.merge.into.sourceSets.main.output) 95 | project.dependencies.add("runtimeMerge", project.merge.into) 96 | setupTaskDependencies(project) 97 | setupMaven(project) 98 | } 99 | 100 | private void setupTaskDependencies(Project project) { 101 | // invoking a task will invoke the task with the same name on 'into' project 102 | ["sourcesJar", "jar", "javadocJar", "javadoc", "install", "artifactoryPublish", "signArchives", "uploadArchives"].each { 103 | def task = project.tasks.findByPath(it) 104 | if (task) { 105 | task.enabled = false 106 | task.dependsOn(project.merge.into.tasks.findByPath(it)) 107 | } 108 | } 109 | 110 | // update 'into' project artifacts to contain the source artifact contents 111 | project.merge.into.sourcesJar.from(project.sourcesJar.source) 112 | project.merge.into.jar.from(project.sourceSets.main.output) 113 | project.merge.into.javadoc { 114 | source += project.javadoc.source 115 | classpath += project.javadoc.classpath 116 | } 117 | } 118 | 119 | private void setupIdeDependencies(Project project) { 120 | project.configurations.each { c -> 121 | c.dependencies.findAll( { it instanceof org.gradle.api.artifacts.ProjectDependency } ).each { d -> 122 | if(d.dependencyProject.hasProperty("merge")) { 123 | d.dependencyProject.merge.from.each { from -> 124 | project.dependencies.add("runtimeMerge", from) 125 | } 126 | } 127 | } 128 | } 129 | } 130 | 131 | private void setupMaven(Project project) { 132 | project.configurations.each { configuration -> 133 | Conf2ScopeMapping mapping = project.conf2ScopeMappings.getMapping([configuration]) 134 | if (mapping.scope) { 135 | Configuration intoConfiguration = project.merge.into.configurations.create( 136 | project.name + "-" + configuration.name) 137 | configuration.excludeRules.each { 138 | configuration.exclude([ 139 | (ExcludeRule.GROUP_KEY) : it.group, 140 | (ExcludeRule.MODULE_KEY) : it.module]) 141 | } 142 | configuration.dependencies.each { 143 | def intoCompile = project.merge.into.configurations.getByName("compile") 144 | // Protect against changing a compile scope dependency (SPR-10218) 145 | if (!intoCompile.dependencies.contains(it)) { 146 | intoConfiguration.dependencies.add(it) 147 | } 148 | } 149 | def index = project.parent.childProjects.findIndexOf {p -> p.getValue() == project} 150 | project.merge.into.install.repositories.mavenInstaller.pom.scopeMappings.addMapping( 151 | mapping.priority + 100 + index, intoConfiguration, mapping.scope) 152 | } 153 | } 154 | } 155 | 156 | private postProcessProjects(Gradle gradle) { 157 | gradle.allprojects(new Action() { 158 | public void execute(Project project) { 159 | if(!project.hasProperty("merge")) { 160 | return 161 | } 162 | project.configurations.getByName("runtime")?.allDependencies?.withType(ProjectDependency)?.each{ 163 | Configuration dependsOnMergedFrom = it.dependencyProject.configurations.getByName("merging"); 164 | dependsOnMergedFrom.dependencies.each{ dep -> 165 | project.dependencies.add("runtimeMerge", dep.dependencyProject) 166 | } 167 | } 168 | } 169 | }); 170 | } 171 | } 172 | 173 | class MergeModel { 174 | Project project; 175 | Project into; 176 | List from = []; 177 | 178 | public void setInto(Project into) { 179 | this.into = into; 180 | into.merge.from.add(project); 181 | } 182 | } 183 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/OssrhPlugin.groovy: -------------------------------------------------------------------------------- 1 | package io.spring.gradle.convention 2 | 3 | import org.gradle.api.Plugin 4 | import org.gradle.api.Project 5 | 6 | public class OssrhPlugin implements Plugin { 7 | 8 | @Override 9 | public void apply(Project project) { 10 | if(project.hasProperty('ossrhUsername')) { 11 | project.uploadArchives { 12 | repositories { 13 | mavenDeployer { 14 | repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { 15 | authentication(userName: project.ossrhUsername, password: project.ossrhPassword) 16 | } 17 | 18 | snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { 19 | authentication(userName: project.ossrhUsername, password: project.ossrhPassword) 20 | } 21 | } 22 | } 23 | } 24 | } 25 | if(project.hasProperty('ossrhTokenUsername')) { 26 | project.uploadArchives { 27 | repositories { 28 | mavenDeployer { 29 | repository(url: "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") { 30 | authentication(userName: project.ossrhTokenUsername, password: project.ossrhTokenPassword) 31 | } 32 | 33 | snapshotRepository(url: "https://s01.oss.sonatype.org/content/repositories/snapshots/") { 34 | authentication(userName: project.ossrhTokenUsername, password: project.ossrhTokenPassword) 35 | } 36 | } 37 | } 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/RepositoryConventionPlugin.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package io.spring.gradle.convention; 18 | 19 | import org.gradle.api.Plugin 20 | import org.gradle.api.Project 21 | 22 | class RepositoryConventionPlugin implements Plugin { 23 | 24 | @Override 25 | void apply(Project project) { 26 | String[] forceMavenRepositories = ((String) project.findProperty("forceMavenRepositories"))?.split(',') 27 | boolean isImplicitSnapshotRepository = forceMavenRepositories == null && Utils.isSnapshot(project) 28 | boolean isImplicitMilestoneRepository = forceMavenRepositories == null && Utils.isMilestone(project) 29 | 30 | boolean isSnapshot = isImplicitSnapshotRepository || forceMavenRepositories?.contains('snapshot') 31 | boolean isMilestone = isImplicitMilestoneRepository || forceMavenRepositories?.contains('milestone') 32 | 33 | project.repositories { 34 | if (forceMavenRepositories?.contains('local')) { 35 | mavenLocal() 36 | } 37 | mavenCentral() 38 | jcenter() { 39 | content { 40 | includeGroup "org.gretty" 41 | } 42 | } 43 | if (isSnapshot) { 44 | maven { 45 | name = 'artifactory-snapshot' 46 | if (project.hasProperty('artifactoryUsername')) { 47 | credentials { 48 | username project.artifactoryUsername 49 | password project.artifactoryPassword 50 | } 51 | } 52 | url = 'https://repo.spring.io/snapshot/' 53 | } 54 | } 55 | if (isSnapshot || isMilestone) { 56 | maven { 57 | name = 'artifactory-milestone' 58 | if (project.hasProperty('artifactoryUsername')) { 59 | credentials { 60 | username project.artifactoryUsername 61 | password project.artifactoryPassword 62 | } 63 | } 64 | url = 'https://repo.spring.io/milestone/' 65 | } 66 | } 67 | maven { 68 | name = 'artifactory-release' 69 | if (project.hasProperty('artifactoryUsername')) { 70 | credentials { 71 | username project.artifactoryUsername 72 | password project.artifactoryPassword 73 | } 74 | } 75 | url = 'https://repo.spring.io/release/' 76 | } 77 | } 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/RootProjectPlugin.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package io.spring.gradle.convention 18 | 19 | import io.spring.nohttp.gradle.NoHttpPlugin 20 | import org.gradle.api.Plugin 21 | import org.gradle.api.Project 22 | import org.gradle.api.plugins.BasePlugin 23 | import org.gradle.api.plugins.PluginManager 24 | 25 | class RootProjectPlugin implements Plugin { 26 | 27 | @Override 28 | void apply(Project project) { 29 | PluginManager pluginManager = project.getPluginManager() 30 | pluginManager.apply(BasePlugin) 31 | pluginManager.apply(SchemaPlugin) 32 | pluginManager.apply(NoHttpPlugin) 33 | pluginManager.apply("org.sonarqube") 34 | 35 | project.repositories.mavenCentral() 36 | 37 | project.allprojects { 38 | configurations.all { 39 | resolutionStrategy { 40 | cacheChangingModulesFor 0, "seconds" 41 | cacheDynamicVersionsFor 0, "seconds" 42 | } 43 | } 44 | } 45 | 46 | String projectName = Utils.getProjectName(project) 47 | project.sonarqube { 48 | properties { 49 | property "sonar.java.coveragePlugin", "jacoco" 50 | property "sonar.projectName", projectName 51 | property "sonar.jacoco.reportPath", "${project.buildDir.name}/jacoco.exec" 52 | property "sonar.links.homepage", "https://spring.io/${projectName}" 53 | property "sonar.links.ci", "https://jenkins.spring.io/job/${projectName}/" 54 | property "sonar.links.issue", "https://github.com/spring-projects/${projectName}/issues" 55 | property "sonar.links.scm", "https://github.com/spring-projects/${projectName}" 56 | property "sonar.links.scm_dev", "https://github.com/spring-projects/${projectName}.git" 57 | } 58 | } 59 | 60 | project.tasks.create("dependencyManagementExport", DependencyManagementExportTask) 61 | 62 | def finalizeDeployArtifacts = project.task("finalizeDeployArtifacts") 63 | if (Utils.isRelease(project) && project.hasProperty("ossrhUsername")) { 64 | project.ext.nexusUsername = project.ossrhUsername 65 | project.ext.nexusPassword = project.ossrhPassword 66 | project.getPluginManager().apply("io.codearte.nexus-staging") 67 | finalizeDeployArtifacts.dependsOn project.tasks.closeAndReleaseRepository 68 | project.nexusStaging { 69 | packageGroup = 'org.springframework' 70 | 71 | // try for 5 minutes total 72 | numberOfRetries = 60 // default is 20 73 | delayBetweenRetriesInMillis = 5000 // default is 2000 74 | } 75 | } 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/SchemaDeployPlugin.groovy: -------------------------------------------------------------------------------- 1 | package io.spring.gradle.convention 2 | 3 | import org.gradle.api.plugins.JavaPlugin 4 | import org.gradle.api.tasks.bundling.Zip 5 | import org.gradle.api.Plugin 6 | import org.gradle.api.Project 7 | 8 | public class SchemaDeployPlugin implements Plugin { 9 | 10 | @Override 11 | public void apply(Project project) { 12 | project.getPluginManager().apply('org.hidetake.ssh') 13 | 14 | project.ssh.settings { 15 | knownHosts = allowAnyHosts 16 | } 17 | project.remotes { 18 | docs { 19 | role 'docs' 20 | if (project.hasProperty('deployDocsHost')) { 21 | host = project.findProperty('deployDocsHost') 22 | } else { 23 | host = 'docs.af.pivotal.io' 24 | } 25 | retryCount = 5 // retry 5 times (default is 0) 26 | retryWaitSec = 10 // wait 10 seconds between retries (default is 0) 27 | user = project.findProperty('deployDocsSshUsername') 28 | if(project.hasProperty('deployDocsSshKeyPath')) { 29 | identity = project.file(project.findProperty('deployDocsSshKeyPath')) 30 | } else if (project.hasProperty('deployDocsSshKey')) { 31 | identity = project.findProperty('deployDocsSshKey') 32 | } 33 | if(project.hasProperty('deployDocsSshPassphrase')) { 34 | passphrase = project.findProperty('deployDocsSshPassphrase') 35 | } 36 | } 37 | } 38 | 39 | project.task('deploySchema') { 40 | dependsOn 'schemaZip' 41 | doFirst { 42 | project.ssh.run { 43 | session(project.remotes.docs) { 44 | def now = System.currentTimeMillis() 45 | def name = project.rootProject.name 46 | def version = project.rootProject.version 47 | def tempPath = "/tmp/${name}-${now}-schema/".replaceAll(' ', '_') 48 | 49 | execute "mkdir -p $tempPath" 50 | 51 | project.tasks.schemaZip.outputs.each { o -> 52 | println "Putting $o.files" 53 | put from: o.files, into: tempPath 54 | } 55 | 56 | execute "unzip $tempPath*.zip -d $tempPath" 57 | 58 | def extractPath = "/var/www/domains/spring.io/docs/htdocs/autorepo/schema/${name}/${version}/" 59 | 60 | execute "rm -rf $extractPath" 61 | execute "mkdir -p $extractPath" 62 | execute "rm -f $tempPath*.zip" 63 | execute "rm -rf $extractPath*" 64 | execute "mv $tempPath/* $extractPath" 65 | execute "chmod -R g+w $extractPath" 66 | } 67 | } 68 | } 69 | } 70 | } 71 | } -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/SchemaPlugin.groovy: -------------------------------------------------------------------------------- 1 | package io.spring.gradle.convention 2 | 3 | import org.gradle.api.plugins.JavaPlugin 4 | import org.gradle.api.tasks.bundling.Zip 5 | import org.gradle.api.Plugin 6 | import org.gradle.api.Project 7 | 8 | public class SchemaPlugin implements Plugin { 9 | 10 | @Override 11 | public void apply(Project project) { 12 | project.getPluginManager().apply(SchemaZipPlugin) 13 | project.getPluginManager().apply(SchemaDeployPlugin) 14 | } 15 | } -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/SchemaZipPlugin.groovy: -------------------------------------------------------------------------------- 1 | package io.spring.gradle.convention 2 | 3 | import org.gradle.api.plugins.JavaPlugin 4 | import org.gradle.api.tasks.bundling.Zip 5 | import org.gradle.api.Plugin 6 | import org.gradle.api.Project 7 | 8 | public class SchemaZipPlugin implements Plugin { 9 | 10 | @Override 11 | public void apply(Project project) { 12 | Zip schemaZip = project.tasks.create('schemaZip', Zip) 13 | schemaZip.group = 'Distribution' 14 | schemaZip.baseName = project.rootProject.name 15 | schemaZip.classifier = 'schema' 16 | schemaZip.description = "Builds -${schemaZip.classifier} archive containing all " + 17 | "XSDs for deployment at static.springframework.org/schema." 18 | 19 | project.rootProject.subprojects.each { module -> 20 | 21 | module.getPlugins().withType(JavaPlugin.class).all { 22 | def Properties schemas = new Properties(); 23 | 24 | module.sourceSets.main.resources.find { 25 | it.path.endsWith('META-INF/spring.schemas') 26 | }?.withInputStream { schemas.load(it) } 27 | 28 | for (def key : schemas.keySet()) { 29 | def shortName = key.replaceAll(/http.*schema.(.*).spring-.*/, '$1') 30 | assert shortName != key 31 | File xsdFile = module.sourceSets.main.resources.find { 32 | it.path.endsWith(schemas.get(key)) 33 | } 34 | assert xsdFile != null 35 | schemaZip.into (shortName) { 36 | duplicatesStrategy 'exclude' 37 | from xsdFile.path 38 | } 39 | } 40 | } 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/SortedProperties.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package io.spring.gradle.convention; 17 | 18 | import java.util.ArrayList; 19 | import java.util.Collections; 20 | import java.util.Comparator; 21 | import java.util.Enumeration; 22 | import java.util.List; 23 | import java.util.Properties; 24 | 25 | /** 26 | * A Properties which sorts they keys so that they can be written to a File with 27 | * the keys sorted. 28 | * 29 | * @author Rob Winch 30 | * 31 | */ 32 | class SortedProperties extends Properties { 33 | private static final long serialVersionUID = -6199017589626540836L; 34 | 35 | public Enumeration keys() { 36 | Enumeration keysEnum = super.keys(); 37 | List keyList = new ArrayList(); 38 | 39 | while (keysEnum.hasMoreElements()) { 40 | keyList.add(keysEnum.nextElement()); 41 | } 42 | 43 | Collections.sort(keyList, new Comparator() { 44 | @Override 45 | public int compare(Object o1, Object o2) { 46 | return o1.toString().compareTo(o2.toString()); 47 | } 48 | }); 49 | 50 | return Collections.enumeration(keyList); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/SpringDependencyManagementConventionPlugin.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package io.spring.gradle.convention 18 | 19 | import io.spring.gradle.dependencymanagement.DependencyManagementPlugin 20 | import org.gradle.api.Plugin 21 | import org.gradle.api.Project 22 | 23 | /** 24 | * Adds and configures {@link DependencyManagementPlugin}. 25 | * 26 | * Additionally, if 'gradle/dependency-management.gradle' file is present it will be 27 | * automatically applied file for configuring the dependencies. 28 | */ 29 | class SpringDependencyManagementConventionPlugin implements Plugin { 30 | 31 | static final String DEPENDENCY_MANAGEMENT_RESOURCE = "gradle/dependency-management.gradle" 32 | 33 | @Override 34 | void apply(Project project) { 35 | project.getPluginManager().apply(ManagementConfigurationPlugin) 36 | project.getPluginManager().apply(DependencyManagementPlugin) 37 | project.dependencyManagement { 38 | resolutionStrategy { 39 | cacheChangingModulesFor 0, "seconds" 40 | } 41 | } 42 | File rootDir = project.rootDir 43 | List dependencyManagementFiles = [project.rootProject.file(DEPENDENCY_MANAGEMENT_RESOURCE)] 44 | for (File dir = project.projectDir; dir != rootDir; dir = dir.parentFile) { 45 | dependencyManagementFiles.add(new File(dir, DEPENDENCY_MANAGEMENT_RESOURCE)) 46 | } 47 | dependencyManagementFiles.each { f -> 48 | if (f.exists()) { 49 | project.apply from: f.absolutePath 50 | } 51 | } 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/SpringMavenPlugin.groovy: -------------------------------------------------------------------------------- 1 | package io.spring.gradle.convention 2 | 3 | import io.spring.gradle.dependencymanagement.DependencyManagementPlugin 4 | import io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension 5 | import io.spring.gradle.dependencymanagement.dsl.GeneratedPomCustomizationHandler 6 | import org.gradle.api.Action 7 | import org.gradle.api.Plugin 8 | import org.gradle.api.Project 9 | import org.gradle.api.XmlProvider 10 | import org.gradle.api.artifacts.component.ModuleComponentSelector 11 | import org.gradle.api.artifacts.maven.MavenDeployment 12 | import org.gradle.api.artifacts.maven.MavenPom 13 | import org.gradle.api.artifacts.result.ResolvedDependencyResult 14 | import org.gradle.api.plugins.JavaBasePlugin 15 | import org.gradle.api.plugins.JavaPlugin 16 | import org.gradle.api.plugins.JavaPluginConvention 17 | import org.gradle.api.plugins.MavenPlugin 18 | import org.gradle.api.tasks.SourceSet 19 | import org.gradle.api.tasks.bundling.Jar 20 | import org.gradle.api.tasks.javadoc.Javadoc 21 | import org.gradle.plugins.signing.SigningPlugin 22 | import org.slf4j.Logger 23 | import org.slf4j.LoggerFactory 24 | 25 | public class SpringMavenPlugin implements Plugin { 26 | private static final String ARCHIVES = "archives"; 27 | Logger logger = LoggerFactory.getLogger(getClass()); 28 | 29 | @Override 30 | public void apply(Project project) { 31 | project.getPluginManager().apply(JavaPlugin.class); 32 | project.getPluginManager().apply(MavenPlugin.class); 33 | project.getPluginManager().apply(SigningPlugin.class); 34 | 35 | Javadoc javadoc = (Javadoc) project.getTasks().findByPath("javadoc"); 36 | Jar javadocJar = project.getTasks().create("javadocJar", Jar.class); 37 | javadocJar.setClassifier("javadoc"); 38 | javadocJar.from(javadoc); 39 | 40 | JavaPluginConvention java = project.getConvention().getPlugin(JavaPluginConvention.class); 41 | SourceSet mainSourceSet = java.getSourceSets().getByName("main"); 42 | Jar sourcesJar = project.getTasks().create("sourcesJar", Jar.class); 43 | sourcesJar.setClassifier("sources"); 44 | sourcesJar.from(mainSourceSet.getAllSource()); 45 | 46 | project.getArtifacts().add(ARCHIVES, javadocJar); 47 | project.getArtifacts().add(ARCHIVES, sourcesJar); 48 | 49 | project.install { 50 | repositories.mavenInstaller { 51 | configurePom(project, pom) 52 | } 53 | } 54 | project.uploadArchives { 55 | repositories.mavenDeployer { 56 | configurePom(project, pom) 57 | } 58 | } 59 | 60 | project.plugins.withType(DependencyManagementPlugin) { 61 | inlineDependencyManagement(project); 62 | } 63 | 64 | def hasSigningKey = project.hasProperty("signing.keyId") || project.findProperty("signingKey") 65 | if(hasSigningKey && Utils.isRelease(project)) { 66 | sign(project) 67 | } 68 | 69 | project.getPluginManager().apply("io.spring.convention.ossrh"); 70 | } 71 | 72 | private void inlineDependencyManagement(Project project) { 73 | final DependencyManagementExtension dependencyManagement = project.getExtensions().findByType(DependencyManagementExtension.class); 74 | dependencyManagement.generatedPomCustomization( { handler -> handler.setEnabled(false) }); 75 | 76 | project.install { 77 | repositories.mavenInstaller { 78 | configurePomForInlineDependencies(project, pom) 79 | } 80 | } 81 | project.uploadArchives { 82 | repositories.mavenDeployer { 83 | configurePomForInlineDependencies(project, pom) 84 | } 85 | } 86 | } 87 | 88 | private void configurePomForInlineDependencies(Project project, MavenPom pom) { 89 | pom.withXml { XmlProvider xml -> 90 | project.plugins.withType(JavaBasePlugin) { 91 | def dependencies = xml.asNode()?.dependencies?.dependency 92 | def configuredDependencies = project.configurations.findAll{ it.canBeResolved }*.incoming*.resolutionResult*.allDependencies.flatten() 93 | dependencies?.each { Node dep -> 94 | def group = dep.groupId.text() 95 | def name = dep.artifactId.text() 96 | 97 | ResolvedDependencyResult resolved = configuredDependencies.find { r -> 98 | (r.requested instanceof ModuleComponentSelector) && 99 | (r.requested.group == group) && 100 | (r.requested.module == name) 101 | } 102 | 103 | if (!resolved) { 104 | return 105 | } 106 | 107 | def versionNode = dep.version 108 | if (!versionNode) { 109 | dep.appendNode('version') 110 | } 111 | def moduleVersion = resolved.selected.moduleVersion 112 | dep.groupId[0].value = moduleVersion.group 113 | dep.artifactId[0].value = moduleVersion.name 114 | dep.version[0].value = moduleVersion.version 115 | } 116 | } 117 | } 118 | } 119 | 120 | private void sign(Project project) { 121 | project.install { 122 | repositories { 123 | mavenDeployer { 124 | beforeDeployment { MavenDeployment deployment -> project.signing.signPom(deployment) } 125 | } 126 | } 127 | } 128 | 129 | project.uploadArchives { 130 | repositories { 131 | mavenDeployer { 132 | beforeDeployment { MavenDeployment deployment -> project.signing.signPom(deployment) } 133 | } 134 | } 135 | } 136 | 137 | project.signing { 138 | required { project.gradle.taskGraph.hasTask("uploadArchives") } 139 | def signingKeyId = project.findProperty("signingKeyId") 140 | def signingKey = project.findProperty("signingKey") 141 | def signingPassword = project.findProperty("signingPassword") 142 | if (signingKeyId) { 143 | useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword) 144 | } else if (signingKey) { 145 | useInMemoryPgpKeys(signingKey, signingPassword) 146 | } 147 | sign project.configurations.archives 148 | } 149 | } 150 | 151 | private static void configurePom(Project project, MavenPom pom) { 152 | pom.whenConfigured { p -> 153 | p.dependencies = p.dependencies.sort { dep -> 154 | "$dep.scope:$dep.optional:$dep.groupId:$dep.artifactId" 155 | } 156 | } 157 | 158 | pom.project { 159 | boolean isWar = project.hasProperty("war"); 160 | String projectVersion = String.valueOf(project.getVersion()); 161 | String projectName = Utils.getProjectName(project); 162 | 163 | if(isWar) { 164 | packaging = "war" 165 | } 166 | name = project.name 167 | description = project.name 168 | url = 'https://spring.io/spring-security' 169 | organization { 170 | name = 'spring.io' 171 | url = 'https://spring.io/' 172 | } 173 | licenses { 174 | license { 175 | name 'The Apache Software License, Version 2.0' 176 | url 'https://www.apache.org/licenses/LICENSE-2.0.txt' 177 | distribution 'repo' 178 | } 179 | } 180 | scm { 181 | url = 'https://github.com/spring-projects/spring-security' 182 | connection = 'scm:git:git://github.com/spring-projects/spring-security' 183 | developerConnection = 'scm:git:git://github.com/spring-projects/spring-security' 184 | } 185 | developers { 186 | developer { 187 | id = 'rwinch' 188 | name = 'Rob Winch' 189 | email = 'rwinch@pivotal.io' 190 | } 191 | developer { 192 | id = 'jgrandja' 193 | name = 'Joe Grandja' 194 | email = 'jgrandja@pivotal.io' 195 | } 196 | } 197 | 198 | if(isWar) { 199 | properties { 200 | 'm2eclipse.wtp.contextRoot' '/' 201 | } 202 | } 203 | if (Utils.isSnapshot(project)) { 204 | repositories { 205 | repository { 206 | id 'spring-snapshot' 207 | url 'https://repo.spring.io/snapshot' 208 | } 209 | } 210 | } 211 | else if (Utils.isMilestone(project)) { 212 | repositories { 213 | repository { 214 | id 'spring-milestone' 215 | url 'https://repo.spring.io/milestone' 216 | } 217 | } 218 | } 219 | } 220 | } 221 | } 222 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/SpringModulePlugin.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package io.spring.gradle.convention; 18 | 19 | import org.gradle.api.Project 20 | import org.gradle.api.plugins.JavaLibraryPlugin; 21 | import org.gradle.api.plugins.MavenPlugin; 22 | import org.gradle.api.plugins.PluginManager; 23 | 24 | /** 25 | * @author Rob Winch 26 | */ 27 | class SpringModulePlugin extends AbstractSpringJavaPlugin { 28 | 29 | @Override 30 | void additionalPlugins(Project project) { 31 | PluginManager pluginManager = project.getPluginManager(); 32 | pluginManager.apply(JavaLibraryPlugin.class) 33 | pluginManager.apply(MavenPlugin.class); 34 | pluginManager.apply("io.spring.convention.maven"); 35 | pluginManager.apply("io.spring.convention.artifactory"); 36 | pluginManager.apply("io.spring.convention.jacoco"); 37 | pluginManager.apply("io.spring.convention.merge"); 38 | 39 | def deployArtifacts = project.task("deployArtifacts") 40 | deployArtifacts.group = 'Deploy tasks' 41 | deployArtifacts.description = "Deploys the artifacts to either Artifactory or Maven Central" 42 | if (Utils.isRelease(project)) { 43 | deployArtifacts.dependsOn project.tasks.uploadArchives 44 | } 45 | else { 46 | deployArtifacts.dependsOn project.tasks.artifactoryPublish 47 | } 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/SpringPomPlugin.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package io.spring.gradle.convention; 18 | 19 | /** 20 | * @author Rob Winch 21 | */ 22 | public class SpringPomPlugin extends SpringModulePlugin { 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/SpringSampleBootPlugin.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package io.spring.gradle.convention; 18 | 19 | import org.gradle.api.Project; 20 | import org.gradle.api.plugins.PluginManager; 21 | import org.gradle.api.plugins.WarPlugin 22 | import org.gradle.api.plugins.JavaPlugin; 23 | import org.gradle.api.tasks.testing.Test 24 | 25 | /** 26 | * @author Rob Winch 27 | */ 28 | public class SpringSampleBootPlugin extends SpringSamplePlugin { 29 | 30 | @Override 31 | public void additionalPlugins(Project project) { 32 | super.additionalPlugins(project); 33 | 34 | PluginManager pluginManager = project.getPluginManager(); 35 | 36 | pluginManager.apply("org.springframework.boot"); 37 | 38 | project.repositories { 39 | maven { url 'https://repo.spring.io/snapshot' } 40 | maven { url 'https://repo.spring.io/milestone' } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/SpringSamplePlugin.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package io.spring.gradle.convention; 18 | 19 | import org.gradle.api.Project 20 | import org.sonarqube.gradle.SonarQubePlugin; 21 | 22 | /** 23 | * @author Rob Winch 24 | */ 25 | public class SpringSamplePlugin extends AbstractSpringJavaPlugin { 26 | 27 | @Override 28 | public void additionalPlugins(Project project) { 29 | project.plugins.withType(SonarQubePlugin) { 30 | project.sonarqube.skipProject = true 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/SpringSampleWarPlugin.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package io.spring.gradle.convention 18 | 19 | import org.gradle.api.Project 20 | import org.gradle.api.Task 21 | import org.gradle.api.plugins.PluginManager 22 | import org.gradle.api.tasks.testing.Test 23 | 24 | /** 25 | * @author Rob Winch 26 | */ 27 | public class SpringSampleWarPlugin extends SpringSamplePlugin { 28 | 29 | @Override 30 | public void additionalPlugins(Project project) { 31 | super.additionalPlugins(project); 32 | 33 | PluginManager pluginManager = project.getPluginManager(); 34 | 35 | pluginManager.apply("war"); 36 | pluginManager.apply("org.gretty"); 37 | 38 | project.gretty { 39 | servletContainer = 'tomcat85' 40 | contextPath = '/' 41 | fileLogEnabled = false 42 | } 43 | 44 | Task prepareAppServerForIntegrationTests = project.tasks.create('prepareAppServerForIntegrationTests') { 45 | group = 'Verification' 46 | description = 'Prepares the app server for integration tests' 47 | doFirst { 48 | project.gretty { 49 | httpPort = getRandomFreePort() 50 | httpsPort = getRandomPort() 51 | } 52 | } 53 | } 54 | project.tasks.withType(org.akhikhl.gretty.AppBeforeIntegrationTestTask).all { task -> 55 | task.dependsOn prepareAppServerForIntegrationTests 56 | } 57 | 58 | project.tasks.withType(Test).all { task -> 59 | if("integrationTest".equals(task.name)) { 60 | applyForIntegrationTest(project, task) 61 | } 62 | } 63 | } 64 | 65 | def applyForIntegrationTest(Project project, Task integrationTest) { 66 | project.gretty.integrationTestTask = integrationTest.name 67 | 68 | integrationTest.doFirst { 69 | def gretty = project.gretty 70 | String host = project.gretty.host ?: 'localhost' 71 | boolean isHttps = gretty.httpsEnabled 72 | Integer httpPort = integrationTest.systemProperties['gretty.httpPort'] 73 | Integer httpsPort = integrationTest.systemProperties['gretty.httpsPort'] 74 | int port = isHttps ? httpsPort : httpPort 75 | String contextPath = project.gretty.contextPath 76 | String httpBaseUrl = "http://${host}:${httpPort}${contextPath}" 77 | String httpsBaseUrl = "https://${host}:${httpsPort}${contextPath}" 78 | String baseUrl = isHttps ? httpsBaseUrl : httpBaseUrl 79 | integrationTest.systemProperty 'app.port', port 80 | integrationTest.systemProperty 'app.httpPort', httpPort 81 | integrationTest.systemProperty 'app.httpsPort', httpsPort 82 | integrationTest.systemProperty 'app.baseURI', baseUrl 83 | integrationTest.systemProperty 'app.httpBaseURI', httpBaseUrl 84 | integrationTest.systemProperty 'app.httpsBaseURI', httpsBaseUrl 85 | 86 | integrationTest.systemProperty 'geb.build.baseUrl', baseUrl 87 | integrationTest.systemProperty 'geb.build.reportsDir', 'build/geb-reports' 88 | } 89 | } 90 | 91 | def getRandomPort() { 92 | ServerSocket ss = new ServerSocket(0) 93 | int port = ss.localPort 94 | ss.close() 95 | return port 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/SpringTestPlugin.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package io.spring.gradle.convention; 18 | 19 | import org.gradle.api.Project; 20 | 21 | /** 22 | * @author Rob Winch 23 | */ 24 | public class SpringTestPlugin extends AbstractSpringJavaPlugin { 25 | 26 | @Override 27 | public void additionalPlugins(Project project) { 28 | project.sonarqube.skipProject = true 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/TestsConfigurationPlugin.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package io.spring.gradle.convention; 17 | 18 | import org.gradle.api.Plugin 19 | import org.gradle.api.Project 20 | import org.gradle.api.plugins.JavaPlugin 21 | import org.gradle.jvm.tasks.Jar 22 | 23 | /** 24 | * Adds the ability to depends on the test jar within other projects using: 25 | * 26 | * 27 | * testCompile project(path: ':foo', configuration: 'tests') 28 | * 29 | * 30 | * @author Rob Winch 31 | */ 32 | public class TestsConfigurationPlugin implements Plugin { 33 | @Override 34 | public void apply(Project project) { 35 | project.plugins.withType(JavaPlugin) { 36 | applyJavaProject(project) 37 | } 38 | } 39 | 40 | private void applyJavaProject(Project project) { 41 | project.configurations { 42 | tests.extendsFrom testRuntime 43 | } 44 | 45 | project.tasks.create('testJar', Jar) { 46 | classifier = 'test' 47 | from project.sourceSets.test.output 48 | } 49 | 50 | project.artifacts { 51 | tests project.testJar 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/Utils.groovy: -------------------------------------------------------------------------------- 1 | package io.spring.gradle.convention; 2 | 3 | import org.gradle.api.Project; 4 | 5 | public class Utils { 6 | 7 | static String getProjectName(Project project) { 8 | String projectName = project.getRootProject().getName(); 9 | if(projectName.endsWith("-build")) { 10 | projectName = projectName.substring(0, projectName.length() - "-build".length()); 11 | } 12 | return projectName; 13 | } 14 | 15 | static boolean isSnapshot(Project project) { 16 | String projectVersion = projectVersion(project) 17 | return projectVersion.matches('^.*([.-]BUILD)?-SNAPSHOT$') 18 | } 19 | 20 | static boolean isMilestone(Project project) { 21 | String projectVersion = projectVersion(project) 22 | return projectVersion.matches('^.*[.-]M\\d+$') || projectVersion.matches('^.*[.-]RC\\d+$') 23 | } 24 | 25 | static boolean isRelease(Project project) { 26 | return !(isSnapshot(project) || isMilestone(project)) 27 | } 28 | 29 | private static String projectVersion(Project project) { 30 | return String.valueOf(project.getVersion()); 31 | } 32 | 33 | private Utils() {} 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/spring/gradle/convention/AsciidoctorConventionPlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-2020 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.gradle.convention; 18 | 19 | import org.asciidoctor.gradle.base.AsciidoctorAttributeProvider; 20 | import org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask; 21 | import org.asciidoctor.gradle.jvm.AsciidoctorJExtension; 22 | import org.asciidoctor.gradle.jvm.AsciidoctorJPlugin; 23 | import org.asciidoctor.gradle.jvm.AsciidoctorTask; 24 | import org.gradle.api.Action; 25 | import org.gradle.api.Plugin; 26 | import org.gradle.api.Project; 27 | import org.gradle.api.artifacts.Configuration; 28 | import org.gradle.api.artifacts.DependencySet; 29 | import org.gradle.api.artifacts.dsl.RepositoryHandler; 30 | import org.gradle.api.file.CopySpec; 31 | import org.gradle.api.file.FileTree; 32 | import org.gradle.api.tasks.Sync; 33 | 34 | import java.io.File; 35 | import java.net.URI; 36 | import java.time.LocalDate; 37 | import java.util.ArrayList; 38 | import java.util.Collections; 39 | import java.util.HashMap; 40 | import java.util.List; 41 | import java.util.Map; 42 | import java.util.concurrent.Callable; 43 | import java.util.function.Consumer; 44 | 45 | /** 46 | * Conventions that are applied in the presence of the {@link AsciidoctorJPlugin}. When 47 | * the plugin is applied: 48 | * 49 | * 50 | * All warnings are made fatal. 51 | * A task is created to resolve and unzip our documentation resources (CSS and 52 | * Javascript). 53 | * For each {@link AsciidoctorTask} (HTML only): 54 | * 55 | * A configuration named asciidoctorExtensions is ued to add the 56 | * block 57 | * switch extension 58 | * {@code doctype} {@link AsciidoctorTask#options(Map) option} is configured. 59 | * {@link AsciidoctorTask#attributes(Map) Attributes} are configured for syntax 60 | * highlighting, CSS styling, docinfo, etc. 61 | * 62 | * For each {@link AbstractAsciidoctorTask} (HTML and PDF): 63 | * 64 | * {@link AsciidoctorTask#attributes(Map) Attributes} are configured to enable 65 | * warnings for references to missing attributes, the year is added as @{code today-year}, 66 | * etc 67 | * {@link AbstractAsciidoctorTask#baseDirFollowsSourceDir() baseDirFollowsSourceDir()} 68 | * is enabled. 69 | * 70 | * 71 | * 72 | * @author Andy Wilkinson 73 | * @author Rob Winch 74 | */ 75 | public class AsciidoctorConventionPlugin implements Plugin { 76 | 77 | public void apply(Project project) { 78 | project.getPlugins().withType(AsciidoctorJPlugin.class, (asciidoctorPlugin) -> { 79 | createDefaultAsciidoctorRepository(project); 80 | makeAllWarningsFatal(project); 81 | Sync unzipResources = createUnzipDocumentationResourcesTask(project); 82 | project.getTasks().withType(AbstractAsciidoctorTask.class, (asciidoctorTask) -> { 83 | asciidoctorTask.dependsOn(unzipResources); 84 | configureExtensions(project, asciidoctorTask); 85 | configureCommonAttributes(project, asciidoctorTask); 86 | configureOptions(asciidoctorTask); 87 | asciidoctorTask.baseDirFollowsSourceDir(); 88 | asciidoctorTask.useIntermediateWorkDir(); 89 | asciidoctorTask.resources(new Action() { 90 | @Override 91 | public void execute(CopySpec resourcesSpec) { 92 | resourcesSpec.from(unzipResources); 93 | resourcesSpec.from(asciidoctorTask.getSourceDir(), new Action() { 94 | @Override 95 | public void execute(CopySpec resourcesSrcDirSpec) { 96 | // https://github.com/asciidoctor/asciidoctor-gradle-plugin/issues/523 97 | // For now copy the entire sourceDir over so that include files are 98 | // available in the intermediateWorkDir 99 | // resourcesSrcDirSpec.include("images/**"); 100 | } 101 | }); 102 | } 103 | }); 104 | if (asciidoctorTask instanceof AsciidoctorTask) { 105 | configureHtmlOnlyAttributes(project, asciidoctorTask); 106 | } 107 | }); 108 | }); 109 | } 110 | 111 | private void createDefaultAsciidoctorRepository(Project project) { 112 | project.getGradle().afterProject(new Action() { 113 | @Override 114 | public void execute(Project project) { 115 | RepositoryHandler repositories = project.getRepositories(); 116 | if (repositories.isEmpty()) { 117 | repositories.mavenCentral(); 118 | repositories.maven(repo -> { 119 | repo.setUrl(URI.create("https://repo.spring.io/release")); 120 | }); 121 | } 122 | } 123 | }); 124 | } 125 | 126 | private void makeAllWarningsFatal(Project project) { 127 | project.getExtensions().getByType(AsciidoctorJExtension.class).fatalWarnings(".*"); 128 | } 129 | 130 | private void configureExtensions(Project project, AbstractAsciidoctorTask asciidoctorTask) { 131 | Configuration extensionsConfiguration = project.getConfigurations().maybeCreate("asciidoctorExtensions"); 132 | extensionsConfiguration.defaultDependencies(new Action() { 133 | @Override 134 | public void execute(DependencySet dependencies) { 135 | dependencies.add(project.getDependencies().create("io.spring.asciidoctor:spring-asciidoctor-extensions-block-switch:0.4.2.RELEASE")); 136 | } 137 | }); 138 | asciidoctorTask.configurations(extensionsConfiguration); 139 | } 140 | 141 | private Sync createUnzipDocumentationResourcesTask(Project project) { 142 | Configuration documentationResources = project.getConfigurations().maybeCreate("documentationResources"); 143 | documentationResources.getDependencies() 144 | .add(project.getDependencies().create("io.spring.docresources:spring-doc-resources:0.2.5")); 145 | Sync unzipResources = project.getTasks().create("unzipDocumentationResources", 146 | Sync.class, new Action() { 147 | @Override 148 | public void execute(Sync sync) { 149 | sync.dependsOn(documentationResources); 150 | sync.from(new Callable>() { 151 | @Override 152 | public List call() throws Exception { 153 | List result = new ArrayList<>(); 154 | documentationResources.getAsFileTree().forEach(new Consumer() { 155 | @Override 156 | public void accept(File file) { 157 | result.add(project.zipTree(file)); 158 | } 159 | }); 160 | return result; 161 | } 162 | }); 163 | File destination = new File(project.getBuildDir(), "docs/resources"); 164 | sync.into(project.relativePath(destination)); 165 | } 166 | }); 167 | return unzipResources; 168 | } 169 | 170 | private void configureOptions(AbstractAsciidoctorTask asciidoctorTask) { 171 | asciidoctorTask.options(Collections.singletonMap("doctype", "book")); 172 | } 173 | 174 | private void configureHtmlOnlyAttributes(Project project, AbstractAsciidoctorTask asciidoctorTask) { 175 | Map attributes = new HashMap<>(); 176 | attributes.put("source-highlighter", "highlight.js"); 177 | attributes.put("highlightjsdir", "js/highlight"); 178 | attributes.put("highlightjs-theme", "github"); 179 | attributes.put("linkcss", true); 180 | attributes.put("icons", "font"); 181 | attributes.put("stylesheet", "css/spring.css"); 182 | asciidoctorTask.getAttributeProviders().add(new AsciidoctorAttributeProvider() { 183 | @Override 184 | public Map getAttributes() { 185 | Object version = project.getVersion(); 186 | Map attrs = new HashMap<>(); 187 | if (version != null && version.toString() != Project.DEFAULT_VERSION) { 188 | attrs.put("revnumber", version); 189 | } 190 | return attrs; 191 | } 192 | }); 193 | asciidoctorTask.attributes(attributes); 194 | } 195 | 196 | private void configureCommonAttributes(Project project, AbstractAsciidoctorTask asciidoctorTask) { 197 | Map attributes = new HashMap<>(); 198 | attributes.put("attribute-missing", "warn"); 199 | attributes.put("icons", "font"); 200 | attributes.put("idprefix", ""); 201 | attributes.put("idseparator", "-"); 202 | attributes.put("docinfo", "shared"); 203 | attributes.put("sectanchors", ""); 204 | attributes.put("sectnums", ""); 205 | attributes.put("today-year", LocalDate.now().getYear()); 206 | asciidoctorTask.attributes(attributes); 207 | } 208 | } 209 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.artifactory.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.ArtifactoryPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.bom.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.MavenBomPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.checkstyle.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.CheckstylePlugin 2 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.dependency-set.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.DependencySetPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.docs.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.DocsPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.integration-test.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.IntegrationTestPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.jacoco.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.JacocoPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.javadoc-api.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.JavadocApiPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.javadoc-options.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.JavadocOptionsPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.maven.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.SpringMavenPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.merge.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.MergePlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.ossrh.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.OssrhPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.repository.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.RepositoryConventionPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.root.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.RootProjectPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.spring-module.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.SpringModulePlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.spring-pom.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.SpringPomPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.spring-sample-boot.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.SpringSampleBootPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.spring-sample-war.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.SpringSampleWarPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.spring-sample.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.SpringSamplePlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.spring-test.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.SpringTestPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.springdependencymangement.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.SpringDependencyManagementConventionPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.tests-configuration.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.TestsConfigurationPlugin -------------------------------------------------------------------------------- /src/test/groovy/io/spring/gradle/convention/DependencySetPluginITest.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package io.spring.gradle.convention 17 | 18 | import io.spring.gradle.testkit.junit.rules.TestKit 19 | import org.gradle.testkit.runner.BuildResult 20 | import org.junit.Rule 21 | import spock.lang.Specification 22 | 23 | import static org.gradle.testkit.runner.TaskOutcome.SUCCESS 24 | 25 | class DependencySetPluginITest extends Specification { 26 | @Rule final TestKit testKit = new TestKit() 27 | 28 | def "dependencies"() { 29 | when: 30 | BuildResult result = testKit.withProjectResource("samples/dependencyset") 31 | .withArguments('dependencies') 32 | .build(); 33 | then: 34 | result.task(":dependencies").outcome == SUCCESS 35 | !result.output.contains("FAILED") 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/test/groovy/io/spring/gradle/convention/DocsPluginITest.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package io.spring.gradle.convention 17 | 18 | import io.spring.gradle.testkit.junit.rules.TestKit 19 | import org.gradle.testkit.runner.BuildResult 20 | import org.junit.Rule 21 | import spock.lang.Specification 22 | 23 | import java.util.zip.ZipFile 24 | 25 | import static org.gradle.testkit.runner.TaskOutcome.FAILED 26 | import static org.gradle.testkit.runner.TaskOutcome.SUCCESS 27 | 28 | class DocsPluginITest extends Specification { 29 | @Rule final TestKit testKit = new TestKit() 30 | 31 | def "build triggers docs"() { 32 | when: 33 | BuildResult result = testKit.withProjectResource("samples/docs/simple/") 34 | .withArguments('build') 35 | .build(); 36 | then: 37 | result.task(":build").outcome == SUCCESS 38 | and: 39 | result.task(":docs").outcome == SUCCESS 40 | and: 41 | result.task(":docsZip").outcome == SUCCESS 42 | and: 43 | def zip = new File(testKit.getRootDir(), 'build/distributions/simple-1.0.0.BUILD-SNAPSHOT-docs.zip') 44 | def names = new ZipFile(zip).entries()*.name 45 | names.contains("docs/reference/html5/index.html") 46 | names.contains("docs/reference/pdf/simple-reference.pdf") 47 | } 48 | 49 | def "asciidoc copies images"() { 50 | when: 51 | BuildResult result = testKit.withProjectResource("samples/docs/simple/") 52 | .withArguments('asciidoctor') 53 | .build(); 54 | then: 55 | result.task(":asciidoctor").outcome == SUCCESS 56 | new File(testKit.getRootDir(), "build/docs/asciidoc/images").exists() 57 | } 58 | 59 | def "asciidoc docinfo from resources used"() { 60 | when: 61 | BuildResult result = testKit.withProjectResource("samples/docs/simple/") 62 | .withArguments('asciidoctor') 63 | .build(); 64 | then: 65 | result.task(":asciidoctor").outcome == SUCCESS 66 | new File(testKit.getRootDir(), "build/docs/asciidoc/index.html").getText().contains("""""") 67 | } 68 | 69 | def "missing attribute fails"() { 70 | when: 71 | BuildResult result = testKit.withProjectResource("samples/docs/missing-attribute/") 72 | .withArguments(':asciidoctor') 73 | .buildAndFail(); 74 | then: 75 | result.task(":asciidoctor").outcome == FAILED 76 | } 77 | 78 | def "missing include"() { 79 | when: 80 | BuildResult result = testKit.withProjectResource("samples/docs/missing-include/") 81 | .withArguments(':asciidoctor') 82 | .buildAndFail(); 83 | then: 84 | result.task(":asciidoctor").outcome == FAILED 85 | } 86 | 87 | def "missing cross reference"() { 88 | when: 89 | BuildResult result = testKit.withProjectResource("samples/docs/missing-cross-reference/") 90 | .withArguments(':asciidoctor') 91 | .buildAndFail(); 92 | then: 93 | result.task(":asciidoctor").outcome == FAILED 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/test/groovy/io/spring/gradle/convention/IntegrationTestPluginITest.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package io.spring.gradle.convention 17 | 18 | import io.spring.gradle.testkit.junit.rules.TestKit 19 | import org.gradle.testkit.runner.BuildResult 20 | import org.junit.Rule 21 | import spock.lang.Specification 22 | 23 | import static org.gradle.testkit.runner.TaskOutcome.SUCCESS 24 | 25 | class IntegrationTestPluginITest extends Specification { 26 | @Rule final TestKit testKit = new TestKit() 27 | 28 | def "check with java plugin"() { 29 | when: 30 | BuildResult result = testKit.withProjectResource("samples/integrationtest/withjava/") 31 | .withArguments('check') 32 | .build(); 33 | then: 34 | result.task(":check").outcome == SUCCESS 35 | and: 36 | new File(testKit.getRootDir(), 'build/test-results/integrationTest/').exists() 37 | new File(testKit.getRootDir(), 'build/reports/tests/integrationTest/').exists() 38 | } 39 | 40 | def "check with propdeps"() { 41 | when: 42 | BuildResult result = testKit.withProjectResource("samples/integrationtest/withpropdeps/") 43 | .withArguments('check') 44 | .build(); 45 | then: 46 | result.task(":check").outcome == SUCCESS 47 | and: 48 | new File(testKit.getRootDir(), 'build/test-results/integrationTest/').exists() 49 | new File(testKit.getRootDir(), 'build/reports/tests/integrationTest/').exists() 50 | } 51 | 52 | def "check with groovy plugin"() { 53 | when: 54 | BuildResult result = testKit.withProjectResource("samples/integrationtest/withgroovy/") 55 | .withArguments('check') 56 | .build(); 57 | then: 58 | result.task(":check").outcome == SUCCESS 59 | and: 60 | new File(testKit.getRootDir(), 'build/test-results/integrationTest/').exists() 61 | new File(testKit.getRootDir(), 'build/reports/tests/integrationTest/').exists() 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/test/groovy/io/spring/gradle/convention/JacocoPluginITest.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package io.spring.gradle.convention 17 | 18 | import io.spring.gradle.testkit.junit.rules.TestKit 19 | import org.gradle.testkit.runner.BuildResult 20 | import org.junit.Rule 21 | import spock.lang.Specification 22 | 23 | import static org.gradle.testkit.runner.TaskOutcome.SUCCESS 24 | 25 | class JacocoPluginITest extends Specification { 26 | @Rule final TestKit testKit = new TestKit() 27 | 28 | def "check with java plugin"() { 29 | when: 30 | BuildResult result = testKit.withProjectResource("samples/jacoco/java/") 31 | .withArguments('check') 32 | .build(); 33 | then: 34 | result.task(":check").outcome == SUCCESS 35 | and: 36 | new File(testKit.getRootDir(), 'build/jacoco').exists() 37 | new File(testKit.getRootDir(), 'build/reports/jacoco/test/html/').exists() 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/groovy/io/spring/gradle/convention/JavadocApiPluginITest.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package io.spring.gradle.convention 17 | 18 | import org.gradle.testkit.runner.BuildResult 19 | import org.gradle.testkit.runner.GradleRunner 20 | import org.junit.Rule 21 | import org.junit.rules.TemporaryFolder 22 | import spock.lang.Specification 23 | 24 | import static org.gradle.testkit.runner.TaskOutcome.*; 25 | 26 | import io.spring.gradle.testkit.junit.rules.TestKit 27 | import org.apache.commons.io.FileUtils 28 | 29 | class JavadocApiPluginITest extends Specification { 30 | @Rule final TestKit testKit = new TestKit() 31 | 32 | def "multimodule api"() { 33 | when: 34 | BuildResult result = testKit.withProjectResource("samples/javadocapi/multimodule/") 35 | .withArguments('api') 36 | .build(); 37 | then: 38 | result.task(":api").outcome == SUCCESS 39 | and: 40 | File allClasses = new File(testKit.getRootDir(), 'build/api/allclasses-noframe.html'); 41 | allClasses.text.contains('sample/Api.html') 42 | allClasses.text.contains('sample/Impl.html') 43 | !allClasses.text.contains('sample/Sample.html') 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/test/groovy/io/spring/gradle/convention/ShowcaseITest.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package io.spring.gradle.convention 18 | 19 | import io.spring.gradle.testkit.junit.rules.TestKit 20 | import org.gradle.testkit.runner.BuildResult 21 | import org.gradle.testkit.runner.TaskOutcome 22 | import org.junit.Rule 23 | import spock.lang.Specification 24 | 25 | class ShowcaseITest extends Specification { 26 | 27 | @Rule final TestKit testKit = new TestKit() 28 | 29 | def "build"() { 30 | when: 31 | BuildResult result = testKit.withProjectResource("samples/showcase/") 32 | .withArguments('build','--stacktrace') 33 | .forwardOutput() 34 | .build(); 35 | then: 'entire build passes' 36 | result.output.contains("BUILD SUCCESSFUL") 37 | 38 | and: 'javadoc api works' 39 | 40 | and: 'integration tests run' 41 | new File(testKit.getRootDir(), 'samples/sgbcs-sample-war/build/test-results/integrationTest/').exists() 42 | new File(testKit.getRootDir(), 'samples/sgbcs-sample-war/build/reports/tests/integrationTest/').exists() 43 | } 44 | 45 | def "install"() { 46 | when: 47 | BuildResult result = testKit.withProjectResource("samples/showcase/") 48 | .withArguments('install','--stacktrace') 49 | .build(); 50 | then: 51 | result.output.contains("SUCCESS") 52 | 53 | and: 'pom exists' 54 | File pom = new File(testKit.getRootDir(), 'sgbcs-core/build/poms/pom-default.xml') 55 | pom.exists() 56 | String pomText = pom.getText() 57 | 58 | and: 'pom does not contain ' 59 | !pomText.contains('') 60 | 61 | and: 'creates optional dependencies correctly' 62 | pomText.replaceAll('\\s','').contains(""" 63 | org.springframework 64 | spring-test 65 | test 66 | 4.3.6.RELEASE 67 | """.replaceAll('\\s','')) 68 | 69 | and: 'adds author' 70 | pomText.replaceAll('\\s','').contains(""" 71 | 72 | rwinch 73 | Rob Winch 74 | rwinch@pivotal.io 75 | 76 | 77 | jgrandja 78 | Joe Grandja 79 | jgrandja@pivotal.io 80 | 81 | """.replaceAll('\\s','')) 82 | 83 | and: 'adds repositories' 84 | pomText.replaceAll('\\s','').contains(""" 85 | scm:git:git://github.com/spring-projects/spring-security 86 | scm:git:git://github.com/spring-projects/spring-security 87 | https://github.com/spring-projects/spring-security 88 | """.replaceAll('\\s','')) 89 | 90 | and: 'adds description & url' 91 | pomText.contains('sgbcs-core') 92 | pomText.contains('https://spring.io/spring-security') 93 | 94 | and: 'adds organization' 95 | pomText.replaceAll('\\s','').contains(''' 96 | spring.io 97 | https://spring.io/ 98 | '''.replaceAll('\\s','')) 99 | 100 | and: 'adds licenses' 101 | pomText.replaceAll('\\s','').contains(''' 102 | 103 | The Apache Software License, Version 2.0 104 | https://www.apache.org/licenses/LICENSE-2.0.txt 105 | repo 106 | 107 | '''.replaceAll('\\s','')) 108 | 109 | and: 'adds scm' 110 | pomText.replaceAll('\\s','').replaceAll('\\s','').contains(""" 111 | scm:git:git://github.com/spring-projects/spring-security 112 | scm:git:git://github.com/spring-projects/spring-security 113 | https://github.com/spring-projects/spring-security 114 | """.replaceAll('\\s','')) 115 | 116 | and: 'bom created' 117 | File bom = new File(testKit.getRootDir(), 'bom/build/poms/pom-default.xml') 118 | bom.exists() 119 | String bomText = bom.getText() 120 | bomText.contains("""sgbcs-core""") 121 | 122 | when: 'mavenBom ran again' 123 | result = testKit.withProjectResource("samples/showcase/") 124 | .withArguments('mavenBom','--stacktrace') 125 | .build(); 126 | then: 'mavenBom is not up to date since install is never up to date' 127 | result.task(':bom:mavenBom').getOutcome() == TaskOutcome.SUCCESS 128 | } 129 | 130 | } 131 | -------------------------------------------------------------------------------- /src/test/groovy/io/spring/gradle/convention/SpringMavenPluginITest.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package io.spring.gradle.convention 18 | 19 | import io.spring.gradle.testkit.junit.rules.TestKit 20 | import org.gradle.testkit.runner.BuildResult 21 | import org.junit.Rule 22 | import spock.lang.Specification 23 | 24 | import static org.gradle.testkit.runner.TaskOutcome.SUCCESS 25 | 26 | class SpringMavenPluginITest extends Specification { 27 | 28 | @Rule final TestKit testKit = new TestKit() 29 | 30 | def "install"() { 31 | when: 32 | BuildResult result = testKit.withProjectResource("samples/maven/install") 33 | .withArguments('install') 34 | .build(); 35 | then: 'pom contains optional' 36 | result.output.contains("SUCCESS") 37 | File pom = new File(testKit.getRootDir(), 'build/poms/pom-default.xml') 38 | pom.exists() 39 | String pomText = pom.getText() 40 | pomText.replaceAll('\\s','').contains(""" 41 | aopalliance 42 | aopalliance 43 | 1.0 44 | compile 45 | true 46 | """.replaceAll('\\s','')) 47 | } 48 | 49 | def "signArchives when in memory"() { 50 | when: 51 | BuildResult result = testKit.withProjectResource("samples/maven/signing") 52 | .withArguments('signArchives') 53 | .withEnvironment(["ORG_GRADLE_PROJECT_signingKey" : signingKey, 54 | "ORG_GRADLE_PROJECT_signingPassword" : "password"]) 55 | .forwardOutput() 56 | .build(); 57 | then: 58 | result.output.contains("SUCCESS") 59 | File jar = new File(testKit.getRootDir(), 'build/libs/signing-1.0.0.RELEASE.jar') 60 | jar.exists() 61 | File signature = new File("${jar.absolutePath}.asc") 62 | signature.exists() 63 | } 64 | 65 | def "upload"() { 66 | when: 67 | BuildResult result = testKit.withProjectResource("samples/maven/upload") 68 | .withArguments('uploadArchives') 69 | .forwardOutput() 70 | .build(); 71 | then: 'pom contains optional' 72 | result.output.contains("SUCCESS") 73 | File pom = new File(testKit.getRootDir(), 'build/poms/pom-default.xml') 74 | pom.exists() 75 | String pomText = pom.getText() 76 | pomText.replaceAll('\\s','').contains(""" 77 | aopalliance 78 | aopalliance 79 | 1.0 80 | compile 81 | true 82 | """.replaceAll('\\s','')) 83 | } 84 | 85 | def getSigningKey() { 86 | getClass().getResource("/test-private.pgp").text 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/test/groovy/io/spring/gradle/convention/TestsConfigurationPluginITest.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package io.spring.gradle.convention 17 | 18 | import io.spring.gradle.testkit.junit.rules.TestKit 19 | import org.gradle.testkit.runner.BuildResult 20 | import org.junit.Rule 21 | import spock.lang.Specification 22 | 23 | import static org.gradle.testkit.runner.TaskOutcome.SUCCESS 24 | 25 | class TestsConfigurationPluginITest extends Specification { 26 | @Rule final TestKit testKit = new TestKit() 27 | 28 | def "can find dependency"() { 29 | when: 30 | BuildResult result = testKit.withProjectResource("samples/testsconfiguration") 31 | .withArguments('check') 32 | .build(); 33 | then: 34 | result.task(":web:check").outcome == SUCCESS 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/test/groovy/io/spring/gradle/testkit/junit/rules/TestKit.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package io.spring.gradle.testkit.junit.rules; 17 | 18 | import java.io.File; 19 | import java.io.IOException; 20 | import java.io.InputStream; 21 | import java.net.URISyntaxException; 22 | import java.net.URL; 23 | import java.nio.file.Paths; 24 | import java.util.Enumeration; 25 | 26 | import org.apache.commons.io.FileUtils; 27 | import org.gradle.testkit.runner.GradleRunner; 28 | import org.junit.rules.TemporaryFolder; 29 | import org.junit.rules.TestRule; 30 | import org.junit.runner.Description; 31 | import org.junit.runners.model.Statement; 32 | 33 | public class TestKit implements TestRule { 34 | final TemporaryFolder testProjectDir = new TemporaryFolder(); 35 | File buildDir; 36 | 37 | @Override 38 | public Statement apply(Statement base, Description description) { 39 | Statement wrapped = new Statement() { 40 | 41 | @Override 42 | public void evaluate() throws Throwable { 43 | try { 44 | buildDir = testProjectDir.newFolder(); 45 | } catch(IOException e) { 46 | throw new RuntimeException(e); 47 | } 48 | base.evaluate(); 49 | } 50 | }; 51 | return testProjectDir.apply(wrapped, description); 52 | } 53 | 54 | public File getRootDir() { 55 | return buildDir; 56 | } 57 | 58 | public GradleRunner withProjectDir(File projectDir) throws IOException { 59 | FileUtils.copyDirectory(projectDir, buildDir); 60 | return GradleRunner.create() 61 | .withProjectDir(buildDir) 62 | .withPluginClasspath(); 63 | } 64 | 65 | public GradleRunner withProjectResource(String projectResourceName) throws IOException, URISyntaxException { 66 | ClassLoader classLoader = getClass().getClassLoader(); 67 | Enumeration resources = classLoader.getResources(projectResourceName); 68 | if(!resources.hasMoreElements()) { 69 | throw new IOException("Cannot find resource " + projectResourceName + " with " + classLoader); 70 | } 71 | URL resourceUrl = resources.nextElement(); 72 | File projectDir = Paths.get(resourceUrl.toURI()).toFile(); 73 | return withProjectDir(projectDir); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/test/java/io/spring/gradle/convention/IntegrationPluginTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package io.spring.gradle.convention; 18 | 19 | import org.apache.commons.io.FileUtils; 20 | import org.gradle.api.Project; 21 | import org.gradle.api.plugins.JavaPlugin; 22 | import org.gradle.api.tasks.javadoc.Javadoc; 23 | import org.gradle.testfixtures.ProjectBuilder; 24 | import org.junit.After; 25 | import org.junit.Test; 26 | 27 | import java.io.File; 28 | 29 | import static org.assertj.core.api.Assertions.assertThat; 30 | 31 | /** 32 | * @author Rob Winch 33 | */ 34 | public class IntegrationPluginTest { 35 | Project rootProject; 36 | 37 | @After 38 | public void cleanup() throws Exception { 39 | if (rootProject != null) { 40 | FileUtils.deleteDirectory(rootProject.getProjectDir()); 41 | } 42 | } 43 | 44 | @Test 45 | public void applyWhenNoSourceThenIntegrationTestTaskNull() { 46 | rootProject = ProjectBuilder.builder().build(); 47 | rootProject.getPlugins().apply(JavaPlugin.class); 48 | rootProject.getPlugins().apply(IntegrationTestPlugin.class); 49 | 50 | assertThat(rootProject.getTasks().findByPath("integrationTest")).isNull(); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/test/java/io/spring/gradle/convention/JavadocApiPluginTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package io.spring.gradle.convention; 18 | 19 | import java.io.File; 20 | 21 | import org.apache.commons.io.FileUtils; 22 | import static org.assertj.core.api.Assertions.assertThat; 23 | import org.gradle.api.Project; 24 | import org.gradle.api.tasks.javadoc.Javadoc; 25 | import org.gradle.testfixtures.ProjectBuilder; 26 | import org.junit.After; 27 | import org.junit.Test; 28 | 29 | /** 30 | * @author Rob Winch 31 | */ 32 | public class JavadocApiPluginTest { 33 | Project rootProject; 34 | 35 | @After 36 | public void cleanup() throws Exception { 37 | if (rootProject != null) { 38 | FileUtils.deleteDirectory(rootProject.getProjectDir()); 39 | } 40 | } 41 | 42 | @Test 43 | public void applyWhenNotOverrideThenPropertiesDefaulted() { 44 | rootProject = ProjectBuilder.builder().build(); 45 | rootProject.getPlugins().apply(JavadocApiPlugin.class); 46 | 47 | Javadoc apiTask = (Javadoc) rootProject.getTasks().getByPath("api"); 48 | 49 | assertThat(apiTask).isNotNull(); 50 | assertThat(apiTask.getGroup()).isEqualTo("Documentation"); 51 | assertThat(apiTask.getDescription()).isEqualTo("Generates aggregated Javadoc API documentation."); 52 | assertThat(apiTask.getMaxMemory()).isEqualTo("1024m"); 53 | assertThat(apiTask.getDestinationDir()).isEqualTo(new File(rootProject.getBuildDir(), "api")); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/test/java/io/spring/gradle/convention/RepositoryConventionPluginTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package io.spring.gradle.convention; 18 | 19 | import org.gradle.api.Project; 20 | import org.gradle.api.artifacts.dsl.RepositoryHandler; 21 | import org.gradle.api.artifacts.repositories.ArtifactRepository; 22 | import org.gradle.api.artifacts.repositories.MavenArtifactRepository; 23 | import org.gradle.api.plugins.ExtraPropertiesExtension; 24 | import org.gradle.testfixtures.ProjectBuilder; 25 | import org.junit.Before; 26 | import org.junit.Test; 27 | 28 | import static org.assertj.core.api.Assertions.assertThat; 29 | 30 | /** 31 | * Tests for {@link RepositoryConventionPlugin}. 32 | */ 33 | public class RepositoryConventionPluginTests { 34 | 35 | private Project project = ProjectBuilder.builder().build(); 36 | 37 | @Before 38 | public void setUp() { 39 | this.project.getProperties().clear(); 40 | } 41 | 42 | @Test 43 | public void applyWhenIsReleaseThenShouldIncludeReleaseRepo() { 44 | this.project.setVersion("1.0.0.RELEASE"); 45 | this.project.getPluginManager().apply(RepositoryConventionPlugin.class); 46 | 47 | RepositoryHandler repositories = this.project.getRepositories(); 48 | assertReleaseRepository(repositories); 49 | } 50 | 51 | @Test 52 | public void applyWhenIsMilestoneThenShouldIncludeMilestoneRepo() { 53 | this.project.setVersion("1.0.0.M1"); 54 | this.project.getPluginManager().apply(RepositoryConventionPlugin.class); 55 | 56 | RepositoryHandler repositories = this.project.getRepositories(); 57 | assertMilestoneRepository(repositories); // milestone 58 | } 59 | 60 | @Test 61 | public void applyWhenIsSnapshotThenShouldIncludeSnapshotRepo() { 62 | this.project.setVersion("1.0.0.BUILD-SNAPSHOT"); 63 | this.project.getPluginManager().apply(RepositoryConventionPlugin.class); 64 | 65 | RepositoryHandler repositories = this.project.getRepositories(); 66 | assertSnapshotRepository(repositories); 67 | } 68 | 69 | @Test 70 | public void applyWhenIsSnapshotWithForceReleaseThenShouldOnlyIncludeReleaseRepo() { 71 | this.project.getExtensions().getByType(ExtraPropertiesExtension.class) 72 | .set("forceMavenRepositories", "release"); 73 | this.project.setVersion("1.0.0.RELEASE"); 74 | this.project.getPluginManager().apply(RepositoryConventionPlugin.class); 75 | 76 | RepositoryHandler repositories = this.project.getRepositories(); 77 | assertReleaseRepository(repositories); 78 | } 79 | 80 | @Test 81 | public void applyWhenIsReleaseWithForceMilestoneThenShouldIncludeMilestoneRepo() { 82 | this.project.getExtensions().getByType(ExtraPropertiesExtension.class) 83 | .set("forceMavenRepositories", "milestone"); 84 | this.project.setVersion("1.0.0.RELEASE"); 85 | this.project.getPluginManager().apply(RepositoryConventionPlugin.class); 86 | 87 | RepositoryHandler repositories = this.project.getRepositories(); 88 | assertMilestoneRepository(repositories); 89 | } 90 | 91 | @Test 92 | public void applyWhenIsReleaseWithForceSnapshotThenShouldIncludeSnapshotRepo() { 93 | this.project.getExtensions().getByType(ExtraPropertiesExtension.class) 94 | .set("forceMavenRepositories", "snapshot"); 95 | this.project.setVersion("1.0.0.RELEASE"); 96 | this.project.getPluginManager().apply(RepositoryConventionPlugin.class); 97 | 98 | RepositoryHandler repositories = this.project.getRepositories(); 99 | assertSnapshotRepository(repositories); 100 | } 101 | 102 | @Test 103 | public void applyWhenIsReleaseWithForceLocalThenShouldIncludeReleaseAndLocalRepos() { 104 | this.project.getExtensions().getByType(ExtraPropertiesExtension.class) 105 | .set("forceMavenRepositories", "local"); 106 | this.project.setVersion("1.0.0.RELEASE"); 107 | this.project.getPluginManager().apply(RepositoryConventionPlugin.class); 108 | 109 | RepositoryHandler repositories = this.project.getRepositories(); 110 | assertThat(repositories).hasSize(4); 111 | assertThat((repositories.get(0)).getName()).isEqualTo("MavenLocal"); 112 | } 113 | 114 | @Test 115 | public void applyWhenIsReleaseWithForceMilestoneAndLocalThenShouldIncludeMilestoneAndLocalRepos() { 116 | this.project.getExtensions().getByType(ExtraPropertiesExtension.class) 117 | .set("forceMavenRepositories", "milestone,local"); 118 | this.project.setVersion("1.0.0.RELEASE"); 119 | this.project.getPluginManager().apply(RepositoryConventionPlugin.class); 120 | 121 | RepositoryHandler repositories = this.project.getRepositories(); 122 | assertThat(repositories).hasSize(5); 123 | assertThat((repositories.get(0)).getName()).isEqualTo("MavenLocal"); 124 | } 125 | 126 | private void assertSnapshotRepository(RepositoryHandler repositories) { 127 | assertThat(repositories).extracting(ArtifactRepository::getName).hasSize(5); 128 | assertThat(((MavenArtifactRepository) repositories.get(0)).getUrl().toString()) 129 | .isEqualTo("https://repo.maven.apache.org/maven2/"); 130 | assertThat(((MavenArtifactRepository) repositories.get(1)).getUrl().toString()) 131 | .isEqualTo("https://jcenter.bintray.com/"); 132 | assertThat(((MavenArtifactRepository) repositories.get(2)).getUrl().toString()) 133 | .isEqualTo("https://repo.spring.io/snapshot/"); 134 | assertThat(((MavenArtifactRepository) repositories.get(3)).getUrl().toString()) 135 | .isEqualTo("https://repo.spring.io/milestone/"); 136 | } 137 | 138 | private void assertMilestoneRepository(RepositoryHandler repositories) { 139 | assertThat(repositories).extracting(ArtifactRepository::getName).hasSize(4); 140 | assertThat(((MavenArtifactRepository) repositories.get(0)).getUrl().toString()) 141 | .isEqualTo("https://repo.maven.apache.org/maven2/"); 142 | assertThat(((MavenArtifactRepository) repositories.get(1)).getUrl().toString()) 143 | .isEqualTo("https://jcenter.bintray.com/"); 144 | assertThat(((MavenArtifactRepository) repositories.get(2)).getUrl().toString()) 145 | .isEqualTo("https://repo.spring.io/milestone/"); 146 | } 147 | 148 | private void assertReleaseRepository(RepositoryHandler repositories) { 149 | assertThat(repositories).extracting(ArtifactRepository::getName).hasSize(3); 150 | assertThat(((MavenArtifactRepository) repositories.get(0)).getUrl().toString()) 151 | .isEqualTo("https://repo.maven.apache.org/maven2/"); 152 | assertThat(((MavenArtifactRepository) repositories.get(1)).getUrl().toString()) 153 | .isEqualTo("https://jcenter.bintray.com/"); 154 | assertThat(((MavenArtifactRepository) repositories.get(2)).getUrl().toString()) 155 | .isEqualTo("https://repo.spring.io/release/"); 156 | } 157 | 158 | } 159 | -------------------------------------------------------------------------------- /src/test/java/io/spring/gradle/convention/UtilsTest.java: -------------------------------------------------------------------------------- 1 | package io.spring.gradle.convention; 2 | 3 | 4 | import static org.assertj.core.api.Assertions.assertThat; 5 | import static org.mockito.Mockito.when; 6 | 7 | import org.gradle.api.Project; 8 | import org.junit.Before; 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | import org.mockito.Mock; 12 | import org.mockito.junit.MockitoJUnitRunner; 13 | 14 | @RunWith(MockitoJUnitRunner.class) 15 | public class UtilsTest { 16 | @Mock 17 | Project project; 18 | @Mock 19 | Project rootProject; 20 | 21 | @Before 22 | public void setup() { 23 | when(project.getRootProject()).thenReturn(rootProject); 24 | } 25 | 26 | @Test 27 | public void getProjectName() { 28 | when(rootProject.getName()).thenReturn("spring-security"); 29 | 30 | assertThat(Utils.getProjectName(project)).isEqualTo("spring-security"); 31 | } 32 | 33 | @Test 34 | public void getProjectNameWhenEndsWithBuildThenStrippedOut() { 35 | when(rootProject.getName()).thenReturn("spring-security-build"); 36 | 37 | assertThat(Utils.getProjectName(project)).isEqualTo("spring-security"); 38 | } 39 | 40 | @Test 41 | public void isSnapshotValidWithDot() { 42 | when(project.getVersion()).thenReturn("1.0.0.BUILD-SNAPSHOT"); 43 | 44 | assertThat(Utils.isSnapshot(project)).isTrue(); 45 | } 46 | 47 | @Test 48 | public void isSnapshotValidWithNoBuild() { 49 | when(project.getVersion()).thenReturn("1.0.0-SNAPSHOT"); 50 | 51 | assertThat(Utils.isSnapshot(project)).isTrue(); 52 | } 53 | 54 | @Test 55 | public void isSnapshotValidWithDash() { 56 | when(project.getVersion()).thenReturn("Theme-BUILD-SNAPSHOT"); 57 | 58 | assertThat(Utils.isSnapshot(project)).isTrue(); 59 | } 60 | 61 | @Test 62 | public void isSnapshotInvalid() { 63 | when(project.getVersion()).thenReturn("1.0.0.SNAPSHOT"); 64 | 65 | assertThat(Utils.isSnapshot(project)).isFalse(); 66 | } 67 | 68 | @Test 69 | public void isMilestoneValidWithDot() { 70 | when(project.getVersion()).thenReturn("1.0.0.M1"); 71 | 72 | assertThat(Utils.isMilestone(project)).isTrue(); 73 | } 74 | 75 | @Test 76 | public void isMilestoneValidWithDash() { 77 | when(project.getVersion()).thenReturn("Theme-M1"); 78 | 79 | assertThat(Utils.isMilestone(project)).isTrue(); 80 | } 81 | 82 | @Test 83 | public void isMilestoneValidWithNumberDash() { 84 | when(project.getVersion()).thenReturn("1.0.0-M1"); 85 | 86 | assertThat(Utils.isMilestone(project)).isTrue(); 87 | } 88 | 89 | @Test 90 | public void isMilestoneInvalid() { 91 | when(project.getVersion()).thenReturn("1.0.0.M"); 92 | 93 | assertThat(Utils.isMilestone(project)).isFalse(); 94 | } 95 | 96 | @Test 97 | public void isReleaseCandidateValidWithDot() { 98 | when(project.getVersion()).thenReturn("1.0.0.RC1"); 99 | 100 | assertThat(Utils.isMilestone(project)).isTrue(); 101 | } 102 | 103 | @Test 104 | public void isReleaseCandidateValidWithNumberDash() { 105 | when(project.getVersion()).thenReturn("1.0.0-RC1"); 106 | 107 | assertThat(Utils.isMilestone(project)).isTrue(); 108 | } 109 | 110 | @Test 111 | public void isReleaseCandidateValidWithDash() { 112 | when(project.getVersion()).thenReturn("Theme-RC1"); 113 | 114 | assertThat(Utils.isMilestone(project)).isTrue(); 115 | } 116 | 117 | @Test 118 | public void isReleaseCandidateInvalid() { 119 | when(project.getVersion()).thenReturn("1.0.0.RC"); 120 | 121 | assertThat(Utils.isMilestone(project)).isFalse(); 122 | } 123 | 124 | @Test 125 | public void isReleaseValidWithDot() { 126 | when(project.getVersion()).thenReturn("1.0.0.RELEASE"); 127 | 128 | assertThat(Utils.isRelease(project)).isTrue(); 129 | } 130 | 131 | @Test 132 | public void isReleaseValidWithNoRelease() { 133 | when(project.getVersion()).thenReturn("1.0.0"); 134 | 135 | assertThat(Utils.isRelease(project)).isTrue(); 136 | } 137 | 138 | @Test 139 | public void isReleaseValidWithDash() { 140 | when(project.getVersion()).thenReturn("Theme-RELEASE"); 141 | 142 | assertThat(Utils.isRelease(project)).isTrue(); 143 | } 144 | 145 | @Test 146 | public void isServiceReleaseValid() { 147 | when(project.getVersion()).thenReturn("Theme-SR1"); 148 | 149 | assertThat(Utils.isRelease(project)).isTrue(); 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /src/test/resources/samples/dependencyset/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.dependency-set' 3 | } 4 | 5 | apply plugin: 'java' 6 | apply from: "$rootDir/gradle/dependency-management.gradle" 7 | 8 | repositories { 9 | mavenCentral() 10 | } 11 | 12 | dependencies { 13 | testCompile spockDependencies 14 | testCompile gebDependencies 15 | testCompile powerMockDependencies 16 | testCompile seleniumDependencies 17 | testCompile slf4jDependencies 18 | testCompile springCoreDependency 19 | testCompile jstlDependencies 20 | testCompile apachedsDependencies 21 | } -------------------------------------------------------------------------------- /src/test/resources/samples/docs/missing-attribute/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.docs' 3 | id 'java' 4 | } 5 | 6 | version = '1.0.0.BUILD-SNAPSHOT' -------------------------------------------------------------------------------- /src/test/resources/samples/docs/missing-attribute/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'simple' -------------------------------------------------------------------------------- /src/test/resources/samples/docs/missing-attribute/src/docs/asciidoc/index.adoc: -------------------------------------------------------------------------------- 1 | = Example Manual 2 | 3 | This will fail due to {missing} attribute -------------------------------------------------------------------------------- /src/test/resources/samples/docs/missing-cross-reference/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.docs' 3 | id 'java' 4 | } 5 | 6 | version = '1.0.0.BUILD-SNAPSHOT' -------------------------------------------------------------------------------- /src/test/resources/samples/docs/missing-cross-reference/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'missing-include' -------------------------------------------------------------------------------- /src/test/resources/samples/docs/missing-cross-reference/src/docs/asciidoc/index.adoc: -------------------------------------------------------------------------------- 1 | = Example Manual 2 | 3 | This will fail due to <> cross reference -------------------------------------------------------------------------------- /src/test/resources/samples/docs/missing-include/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.docs' 3 | id 'java' 4 | } 5 | 6 | version = '1.0.0.BUILD-SNAPSHOT' -------------------------------------------------------------------------------- /src/test/resources/samples/docs/missing-include/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'missing-include' -------------------------------------------------------------------------------- /src/test/resources/samples/docs/missing-include/src/docs/asciidoc/index.adoc: -------------------------------------------------------------------------------- 1 | = Example Manual 2 | 3 | This will fail due to missing include 4 | 5 | include::missing.adoc[] -------------------------------------------------------------------------------- /src/test/resources/samples/docs/simple/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.docs' 3 | id 'java' 4 | } 5 | 6 | version = '1.0.0.BUILD-SNAPSHOT' 7 | 8 | asciidoctorj { 9 | attributes \ 10 | 'build-gradle': project.buildFile, 11 | 'sourcedir': project.sourceSets.main.java.srcDirs[0], 12 | 'endpoint-url': 'https://example.org' 13 | } -------------------------------------------------------------------------------- /src/test/resources/samples/docs/simple/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'simple' -------------------------------------------------------------------------------- /src/test/resources/samples/docs/simple/src/docs/asciidoc/docinfo.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/test/resources/samples/docs/simple/src/docs/asciidoc/images/sunset.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-gradle-plugins/spring-build-conventions/1527cecd379b865b8b70a85acea3c8e25068fb77/src/test/resources/samples/docs/simple/src/docs/asciidoc/images/sunset.jpg -------------------------------------------------------------------------------- /src/test/resources/samples/docs/simple/src/docs/asciidoc/index.adoc: -------------------------------------------------------------------------------- 1 | = Example Manual 2 | Doc Writer 3 | 2014-09-09 4 | :example-caption!: 5 | ifndef::imagesdir[:imagesdir: images] 6 | ifndef::sourcedir[:sourcedir: ../java] 7 | 8 | This is a user manual for an example project. 9 | 10 | == Introduction 11 | 12 | This project does something. 13 | We just haven't decided what that is yet. 14 | 15 | == Source Code 16 | 17 | [source,java] 18 | .Java code from project 19 | ---- 20 | include::{sourcedir}/example/StringUtils.java[tags=contains,indent=0] 21 | ---- 22 | 23 | This page was built by the following command: 24 | 25 | $ ./gradlew asciidoctor 26 | 27 | == Images 28 | 29 | [.thumb] 30 | image::sunset.jpg[scaledwidth=75%] 31 | 32 | == Attributes 33 | 34 | .Built-in 35 | asciidoctor-version:: {asciidoctor-version} 36 | safe-mode-name:: {safe-mode-name} 37 | docdir:: {docdir} 38 | docfile:: {docfile} 39 | imagesdir:: {imagesdir} 40 | revnumber:: {revnumber} 41 | 42 | .Custom 43 | sourcedir:: {sourcedir} 44 | endpoint-url:: {endpoint-url} 45 | 46 | == Includes 47 | 48 | .include::subdir/_b.adoc[] 49 | ==== 50 | include::subdir/_b.adoc[] 51 | ==== 52 | 53 | WARNING: Includes can be tricky! 54 | 55 | == build.gradle 56 | 57 | [source,groovy] 58 | ---- 59 | include::{build-gradle}[] 60 | ---- 61 | -------------------------------------------------------------------------------- /src/test/resources/samples/docs/simple/src/docs/asciidoc/subdir/_b.adoc: -------------------------------------------------------------------------------- 1 | content from _src/docs/asciidoc/subdir/_b.adoc_. 2 | 3 | .include::_c.adoc[] 4 | [example] 5 | -- 6 | include::_c.adoc[] 7 | -- 8 | -------------------------------------------------------------------------------- /src/test/resources/samples/docs/simple/src/docs/asciidoc/subdir/_c.adoc: -------------------------------------------------------------------------------- 1 | content from _src/docs/asciidoc/subdir/c.adoc_. 2 | -------------------------------------------------------------------------------- /src/test/resources/samples/docs/simple/src/main/java/example/StringUtils.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | public class StringUtils { 4 | // tag::contains[] 5 | public boolean contains(String haystack, String needle) { 6 | return haystack.contains(needle); 7 | } 8 | // end::contains[] 9 | } 10 | -------------------------------------------------------------------------------- /src/test/resources/samples/integrationtest/withgroovy/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.integration-test' 3 | } 4 | 5 | apply plugin: 'java' 6 | apply plugin: 'groovy' 7 | 8 | repositories { 9 | mavenCentral() 10 | } 11 | 12 | dependencies { 13 | testCompile 'junit:junit:4.12' 14 | testCompile 'org.spockframework:spock-core:1.0-groovy-2.4' 15 | integrationTestCompile 'org.springframework:spring-core:4.3.7.RELEASE' 16 | } -------------------------------------------------------------------------------- /src/test/resources/samples/integrationtest/withgroovy/src/integration-test/groovy/sample/TheTest.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package sample; 17 | 18 | import org.springframework.core.Ordered; 19 | import spock.lang.Specification; 20 | 21 | class TheTest extends Specification { 22 | def "has Ordered"() { 23 | expect: 'Loads Ordered fine' 24 | Ordered ordered = new Ordered() { 25 | @Override 26 | int getOrder() { 27 | return 0 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /src/test/resources/samples/integrationtest/withjava/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.integration-test' 3 | } 4 | 5 | apply plugin: 'java' 6 | 7 | repositories { 8 | mavenCentral() 9 | } 10 | 11 | dependencies { 12 | testCompile 'junit:junit:4.12' 13 | integrationTestCompile 'org.springframework:spring-core:4.3.7.RELEASE' 14 | } -------------------------------------------------------------------------------- /src/test/resources/samples/integrationtest/withjava/src/integration-test/java/sample/TheTest.java: -------------------------------------------------------------------------------- 1 | package sample; 2 | 3 | import org.junit.Test; 4 | import org.springframework.core.Ordered; 5 | 6 | public class TheTest { 7 | @Test 8 | public void compilesAndRuns() { 9 | Ordered ordered = new Ordered() { 10 | @Override 11 | public int getOrder() { 12 | return 0; 13 | } 14 | }; 15 | } 16 | } -------------------------------------------------------------------------------- /src/test/resources/samples/integrationtest/withpropdeps/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.integration-test' 3 | } 4 | 5 | apply plugin: 'java' 6 | apply plugin: 'propdeps' 7 | 8 | repositories { 9 | mavenCentral() 10 | } 11 | 12 | dependencies { 13 | optional 'javax.servlet:javax.servlet-api:3.1.0' 14 | testCompile 'junit:junit:4.12' 15 | } -------------------------------------------------------------------------------- /src/test/resources/samples/integrationtest/withpropdeps/src/integration-test/java/sample/TheTest.java: -------------------------------------------------------------------------------- 1 | package sample; 2 | 3 | import org.junit.Test; 4 | import javax.servlet.http.HttpServletRequest; 5 | 6 | public class TheTest { 7 | @Test 8 | public void compilesAndRuns() { 9 | HttpServletRequest request = null; 10 | } 11 | } -------------------------------------------------------------------------------- /src/test/resources/samples/jacoco/java/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.jacoco' 3 | } 4 | 5 | apply plugin: 'java' 6 | 7 | repositories { 8 | mavenCentral() 9 | } 10 | 11 | dependencies { 12 | testCompile 'junit:junit:4.12' 13 | } -------------------------------------------------------------------------------- /src/test/resources/samples/jacoco/java/src/main/java/sample/TheClass.java: -------------------------------------------------------------------------------- 1 | package sample; 2 | 3 | public class TheClass { 4 | public boolean doStuff(boolean b) { 5 | if(b) { 6 | return true; 7 | } else { 8 | return false; 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /src/test/resources/samples/jacoco/java/src/test/java/sample/TheClassTest.java: -------------------------------------------------------------------------------- 1 | package sample; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import org.junit.Test; 6 | 7 | public class TheClassTest { 8 | TheClass theClass = new TheClass(); 9 | 10 | @Test 11 | public void doStuffWhenTrueThenTrue() { 12 | assertTrue(theClass.doStuff(true)); 13 | } 14 | 15 | @Test 16 | public void doStuffWhenTrueThenFalse() { 17 | assertFalse(theClass.doStuff(false)); 18 | } 19 | } -------------------------------------------------------------------------------- /src/test/resources/samples/javadocapi/multimodule/api/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'io.spring.convention.spring-module' -------------------------------------------------------------------------------- /src/test/resources/samples/javadocapi/multimodule/api/src/main/java/sample/Api.java: -------------------------------------------------------------------------------- 1 | package sample; 2 | 3 | /** 4 | * Testing this 5 | * @author Rob Winch 6 | * 7 | */ 8 | public class Api { 9 | 10 | /** 11 | * This does stuff 12 | */ 13 | public void doStuff() {} 14 | } 15 | -------------------------------------------------------------------------------- /src/test/resources/samples/javadocapi/multimodule/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.javadoc-api' 3 | id 'io.spring.convention.spring-module' apply false 4 | id 'io.spring.convention.spring-sample' apply false 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/samples/javadocapi/multimodule/impl/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'io.spring.convention.spring-module' -------------------------------------------------------------------------------- /src/test/resources/samples/javadocapi/multimodule/impl/src/main/java/sample/Impl.java: -------------------------------------------------------------------------------- 1 | package sample; 2 | 3 | /** 4 | * Testing this 5 | * @author Rob Winch 6 | * 7 | */ 8 | public class Impl { 9 | 10 | /** 11 | * This does stuff 12 | */ 13 | public void otherThings() {} 14 | } 15 | -------------------------------------------------------------------------------- /src/test/resources/samples/javadocapi/multimodule/sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'io.spring.convention.spring-sample' -------------------------------------------------------------------------------- /src/test/resources/samples/javadocapi/multimodule/sample/src/main/java/sample/Sample.java: -------------------------------------------------------------------------------- 1 | package sample; 2 | 3 | /** 4 | * Testing this 5 | * @author Rob Winch 6 | * 7 | */ 8 | public class Sample { 9 | 10 | /** 11 | * This does stuff 12 | */ 13 | public void doSample() {} 14 | } 15 | -------------------------------------------------------------------------------- /src/test/resources/samples/javadocapi/multimodule/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':api' 2 | include ':impl' 3 | include ':sample' -------------------------------------------------------------------------------- /src/test/resources/samples/maven/install-with-springio/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.spring-module' 3 | } 4 | 5 | repositories { 6 | mavenCentral() 7 | } 8 | 9 | dependencies { 10 | testCompile 'junit:junit:4.12' 11 | compile 'org.springframework:spring-core' 12 | } -------------------------------------------------------------------------------- /src/test/resources/samples/maven/install-with-springio/gradle/dependency-management.gradle: -------------------------------------------------------------------------------- 1 | dependencyManagement { 2 | dependencies { 3 | dependency 'org.springframework:spring-core:3.0.0.RELEASE' 4 | } 5 | } -------------------------------------------------------------------------------- /src/test/resources/samples/maven/install/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.root' 3 | } 4 | 5 | apply plugin: 'propdeps-maven' 6 | apply plugin: 'io.spring.convention.maven' 7 | 8 | repositories { 9 | mavenCentral() 10 | } 11 | 12 | dependencies { 13 | testCompile 'junit:junit:4.12' 14 | optional 'aopalliance:aopalliance:1.0' 15 | } -------------------------------------------------------------------------------- /src/test/resources/samples/maven/signing/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.root' 3 | } 4 | 5 | version = "1.0.0.RELEASE" 6 | 7 | apply plugin: 'propdeps-maven' 8 | apply plugin: 'io.spring.convention.maven' 9 | 10 | repositories { 11 | mavenCentral() 12 | } 13 | 14 | dependencies { 15 | testCompile 'junit:junit:4.12' 16 | optional 'aopalliance:aopalliance:1.0' 17 | } -------------------------------------------------------------------------------- /src/test/resources/samples/maven/signing/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'signing' -------------------------------------------------------------------------------- /src/test/resources/samples/maven/upload/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.root' 3 | } 4 | 5 | apply plugin: 'propdeps-maven' 6 | 7 | repositories { 8 | mavenCentral() 9 | } 10 | 11 | dependencies { 12 | testCompile 'junit:junit:4.12' 13 | optional 'aopalliance:aopalliance:1.0' 14 | } 15 | 16 | uploadArchives { 17 | repositories { 18 | mavenDeployer { 19 | repository(url: "file:$buildDir/repo") 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/Jenkinsfile: -------------------------------------------------------------------------------- 1 | parallel check: { 2 | stage('Check') { 3 | node { 4 | checkout scm 5 | sh "./gradlew check --refresh-dependencies --no-daemon" 6 | } 7 | } 8 | }, 9 | sonar: { 10 | stage('Sonar') { 11 | node { 12 | checkout scm 13 | withCredentials([string(credentialsId: 'spring-sonar.login', variable: 'SONAR_LOGIN')]) { 14 | sh "./gradlew sonarqube -Dsonar.host.url=$SPRING_SONAR_HOST_URL -Dsonar.login=$SONAR_LOGIN --refresh-dependencies --no-daemon" 15 | } 16 | } 17 | } 18 | }, 19 | ossrh: { 20 | stage('OSSRH Deploy') { 21 | node { 22 | checkout scm 23 | withCredentials([file(credentialsId: 'spring-signing-secring.gpg', variable: 'SIGNING_KEYRING_FILE')]) { 24 | withCredentials([string(credentialsId: 'spring-gpg-passphrase', variable: 'SIGNING_PASSWORD')]) { 25 | withCredentials([usernamePassword(credentialsId: 'oss-token', passwordVariable: 'OSSRH_PASSWORD', usernameVariable: 'OSSRH_USERNAME')]) { 26 | sh "./gradlew uploadArchives -Psigning.secretKeyRingFile=$SIGNING_KEYRING_FILE -Psigning.keyId=$SPRING_SIGNING_KEYID -Psigning.password=$SIGNING_PASSWORD -PossrhUsername=$OSSRH_USERNAME -PossrhPassword=$OSSRH_PASSWORD --refresh-dependencies --no-daemon" 27 | } 28 | } 29 | } 30 | } 31 | } 32 | }, 33 | docs: { 34 | stage('Deploy Docs') { 35 | node { 36 | checkout scm 37 | withCredentials([file(credentialsId: 'docs.spring.io-jenkins_private_ssh_key', variable: 'DEPLOY_SSH_KEY')]) { 38 | sh "./gradlew deployDocs -PdeployDocsSshKeyPath=$DEPLOY_SSH_KEY -PdeployDocsSshUsername=$SPRING_DOCS_USERNAME --refresh-dependencies --no-daemon --stacktrace" 39 | } 40 | } 41 | } 42 | }, 43 | schema: { 44 | stage('Deploy Schema') { 45 | node { 46 | checkout scm 47 | withCredentials([file(credentialsId: 'docs.spring.io-jenkins_private_ssh_key', variable: 'DEPLOY_SSH_KEY')]) { 48 | sh "./gradlew deploySchema -PdeployDocsSshKeyPath=$DEPLOY_SSH_KEY -PdeployDocsSshUsername=$SPRING_DOCS_USERNAME --refresh-dependencies --no-daemon --stacktrace" 49 | } 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/bom/bom.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'io.spring.convention.bom' 2 | 3 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.root' 3 | } 4 | 5 | group = "org.springframework.build.test" 6 | version = "1.0.0.BUILD-SNAPSHOT" 7 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/etc/checkstyle/checkstyle.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/gradle/dependency-management.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | management platform('io.spring.platform:platform-bom:Brussels-RELEASE') 3 | } -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/samples/sgbcs-sample-war/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'io.spring.convention.spring-sample-war' 2 | 3 | dependencies { 4 | provided 'javax.servlet:javax.servlet-api' 5 | testCompile 'commons-io:commons-io' 6 | testCompile 'junit:junit' 7 | } -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/samples/sgbcs-sample-war/src/integration-test/java/sample/HelloServletTest.java: -------------------------------------------------------------------------------- 1 | package sample; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import java.io.InputStream; 6 | import java.net.URL; 7 | import java.nio.charset.Charset; 8 | 9 | import org.apache.commons.io.IOUtils; 10 | import org.junit.Test; 11 | 12 | public class HelloServletTest { 13 | 14 | @Test 15 | public void hello() throws Exception { 16 | String url = System.getProperty("app.baseURI"); 17 | try(InputStream get = new URL(url).openConnection().getInputStream()) { 18 | String hello = IOUtils.toString(get, Charset.defaultCharset()); 19 | assertEquals("Hello", hello); 20 | } 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/samples/sgbcs-sample-war/src/main/java/sample/HelloServlet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package sample; 17 | 18 | import java.io.IOException; 19 | 20 | import javax.servlet.ServletException; 21 | import javax.servlet.annotation.WebServlet; 22 | import javax.servlet.http.HttpServlet; 23 | import javax.servlet.http.HttpServletRequest; 24 | import javax.servlet.http.HttpServletResponse; 25 | 26 | @WebServlet("/") 27 | public class HelloServlet extends HttpServlet { 28 | 29 | @Override 30 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 31 | resp.getWriter().write("Hello"); 32 | } 33 | 34 | private static final long serialVersionUID = -166535360229360350L; 35 | } 36 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'spring-gradle-build-conventions-sample' 2 | 3 | 4 | FileTree projects = fileTree(rootDir) { 5 | include '**/*.gradle' 6 | exclude '**/gradle', 'settings.gradle', 'buildSrc', '/build.gradle', '.*' 7 | } 8 | 9 | String rootDirPath = rootDir.absolutePath + File.separator 10 | projects.each { File buildFile -> 11 | String buildFilePath = buildFile.parentFile.absolutePath 12 | 13 | String projectPath = buildFilePath.replace(rootDirPath, '').replaceAll(File.separator, ':') 14 | 15 | include projectPath 16 | 17 | def project = findProject(":${projectPath}") 18 | if(!'build.gradle'.equals(buildFile.name)) { 19 | project.name = buildFile.name.replace('.gradle','') 20 | project.buildFileName = buildFile.name 21 | } 22 | project.projectDir = buildFile.parentFile 23 | } -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-api/sgbcs-api.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'io.spring.convention.spring-module' 2 | 3 | dependencies { 4 | compile 'org.springframework:spring-web' 5 | compile 'org.springframework:spring-core' 6 | testCompile 'junit:junit' 7 | } 8 | 9 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-api/src/main/java/api/Api.java: -------------------------------------------------------------------------------- 1 | package api; 2 | 3 | /** 4 | * 5 | * @author Rob Winch 6 | * 7 | */ 8 | public class Api { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-api/src/test/java/api/ApiTest.java: -------------------------------------------------------------------------------- 1 | package api; 2 | 3 | import org.junit.Test; 4 | 5 | public class ApiTest { 6 | 7 | @Test 8 | public void api() {} 9 | } 10 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-core/sgbcs-core.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'io.spring.convention.spring-module' 2 | 3 | dependencies { 4 | optional 'ch.qos.logback:logback-classic' 5 | testCompile 'junit:junit' 6 | } -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-core/src/main/java/core/CoreClass.java: -------------------------------------------------------------------------------- 1 | package core; 2 | 3 | /** 4 | * 5 | * @author Rob Winch 6 | * 7 | */ 8 | public class CoreClass { 9 | 10 | public void run() { 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-core/src/main/java/core/HasOptional.java: -------------------------------------------------------------------------------- 1 | package core; 2 | 3 | 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | 8 | public class HasOptional { 9 | 10 | public static void doStuffWithOptionalDependency() { 11 | Logger logger = LoggerFactory.getLogger(HasOptional.class); 12 | logger.debug("This is optional"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-core/src/main/resources/META-INF/spring.handlers: -------------------------------------------------------------------------------- 1 | http\://www.springframework.org/schema/springgradlebuildsample=org.springframework.ldap.config.LdapNamespaceHandler -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-core/src/main/resources/META-INF/spring.schemas: -------------------------------------------------------------------------------- 1 | http\://www.springframework.org/schema/springgradlebuildsample/spring-springgradlebuildsample.xsd=org/springframework/springgradlebuildsample/config/spring-springgradlebuildsample-2.2.xsd 2 | http\://www.springframework.org/schema/springgradlebuildsample/spring-springgradlebuildsample-2.0.xsd=org/springframework/springgradlebuildsample/config/spring-springgradlebuildsample-2.0.xsd 3 | http\://www.springframework.org/schema/springgradlebuildsample/spring-springgradlebuildsample-2.1.xsd=org/springframework/springgradlebuildsample/config/spring-springgradlebuildsample-2.1.xsd 4 | http\://www.springframework.org/schema/springgradlebuildsample/spring-springgradlebuildsample-2.2.xsd=org/springframework/springgradlebuildsample/config/spring-springgradlebuildsample-2.2.xsd -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-core/src/main/resources/org/springframework/springgradlebuildsample/config/spring-springgradlebuildsample-2.0.xsd: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | A bean identifier, used for referring to the bean elsewhere in the context. 16 | "contextSource". 17 | 18 | 19 | 20 | 21 | 22 | 23 | Defines whether read-only operations will be performed using an anonymous (unauthenticated) context. 24 | 25 | 26 | 27 | 28 | 29 | 30 | Id of the AuthenticationSource instance to use. If not specified, a SimpleAuthenticationSource will 31 | be used. 32 | 33 | 34 | 35 | 36 | 37 | 38 | Id of the DirContextAuthenticationStrategy instance to use. If not specified, a SimpleDirContextAuthenticationStrategy 39 | will be used. 40 | 41 | 42 | 43 | 44 | 45 | 46 | The base DN. If configured, all LDAP operations on contexts retrieved from this ContextSource will 47 | be relative to this DN. Default is an empty distinguished name (i.e. all operations will be 48 | relative to the directory root). 49 | 50 | 51 | 52 | 53 | 54 | 55 | The password to use for authentication. 56 | 57 | 58 | 59 | 60 | 61 | 62 | Specify whether native Java LDAP connection pooling should be used. Default is false. 63 | 64 | 65 | 66 | 67 | 68 | 69 | Defines the strategy to handle referrals, as described on https://docs.oracle.com/javase/jndi/tutorial/ldap/referral/jndi.html. 70 | Default is null. 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | URL of the LDAP server to use. If fail-over functionality is desired, more than one URL can 85 | be specified, separated using comma (,). 86 | 87 | 88 | 89 | 90 | 91 | 92 | The username (principal) to use for authentication. This will normally be the distinguished name 93 | of an admin user. 94 | 95 | 96 | 97 | 98 | 99 | 100 | Reference to a Map of custom environment properties that should supplied with the environment 101 | sent to the DirContext on construction. 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | The maximum number of active connections of each type (read-only|read-write) 112 | that can be allocated from the pool at the same time, or non-positive for no limit. 113 | Default is 8. 114 | 115 | 116 | 117 | 118 | 119 | 120 | The overall maximum number of active connections (for all types) that can be allocated from 121 | this pool at the same time, or non-positive for no limit. Default is -1 (no limit). 122 | 123 | 124 | 125 | 126 | 127 | 128 | The maximum number of active connections of each type (read-only|read-write) that can remain idle in the pool, 129 | without extra ones being released, or non-positive for no limit. Default is 8. 130 | 131 | 132 | 133 | 134 | 135 | 136 | The minimum number of active connections of each type (read-only|read-write) that can remain 137 | idle in the pool, without extra ones being created, or zero to create none. Default is 0. 138 | 139 | 140 | 141 | 142 | 143 | 144 | The maximum number of milliseconds that the pool will wait (when there are no available connections) 145 | for a connection to be returned before throwing an exception, or non-positive to wait indefinitely. 146 | Default is -1. 147 | 148 | 149 | 150 | 151 | 152 | 153 | Specifies the behaviour when the pool is exhausted. 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | Throw a NoSuchElementException when the pool is exhausted 162 | 163 | 164 | 165 | 166 | 167 | 168 | Wait until a new object is available. If max-wait is positive a NoSuchElementException 169 | is thrown if no new object is available after the maxWait time expires. 170 | 171 | 172 | 173 | 174 | 175 | 176 | Create and return a new object (essentially making maxActive meaningless). 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | The indication of whether objects will be validated before being borrowed from the pool. 187 | If the object fails to validate, it will be dropped from the pool, and an attempt to borrow another will be made. 188 | Default is false. 189 | 190 | 191 | 192 | 193 | 194 | 195 | The indication of whether objects will be validated before being returned to the pool. 196 | Default is false. 197 | 198 | 199 | 200 | 201 | 202 | 203 | The indication of whether objects will be validated by the idle object evictor (if any). 204 | If an object fails to validate, it will be dropped from the pool. 205 | Default is false. 206 | 207 | 208 | 209 | 210 | 211 | 212 | The number of milliseconds to sleep between runs of the idle object evictor thread. When non-positive, 213 | no idle object evictor thread will be run. Default is -1. 214 | 215 | 216 | 217 | 218 | 219 | 220 | The number of objects to examine during each run of the idle object evictor thread (if any). 221 | Default is 3. 222 | 223 | 224 | 225 | 226 | 227 | 228 | The minimum amount of time an object may sit idle in the pool before it is eligible 229 | for eviction by the idle object evictor (if any). Default is 1000 * 60 * 30. 230 | 231 | 232 | 233 | 234 | 235 | 236 | The base dn to use for validation searches. Default is LdapUtils.emptyPath(). 237 | 238 | 239 | 240 | 241 | 242 | 243 | The filter to use for validation queries. Default is (objectclass=*). 244 | 245 | 246 | 247 | 248 | 249 | 250 | Id of the SearchControls instance to use for searches. Default is searchScope=OBJECT_SCOPE; 251 | countLimit: 1; timeLimit: 500; returningAttributes: [objectclass]. 252 | 253 | 254 | 255 | 256 | 257 | 258 | Id of the SearchControls instance to use for searches. Default is searchScope=OBJECT_SCOPE; 259 | countLimit: 1; timeLimit: 500; returningAttributes: [objectclass]. 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | Creates a ContextSource instance to be used to get LdapContexts for communicating with an LDAP server. 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | Defines the settings to use for the Spring LDAP connection pooling support. 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | A bean identifier, used for referring to the bean elsewhere in the context. 293 | Default is "ldapTemplate". 294 | 295 | 296 | 297 | 298 | 299 | 300 | Id of the ContextSource instance to use. Default is "contextSource". 301 | 302 | 303 | 304 | 305 | 306 | 307 | The default count limit for searches. Default is 0 (no limit). 308 | 309 | 310 | 311 | 312 | 313 | 314 | The default time limit for searches. Default is 0 (no limit). 315 | 316 | 317 | 318 | 319 | 320 | 321 | The default search scope for searches. Default is SUBTREE. 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | Specifies whether NameNotFoundException should be ignored in searches. Setting this 336 | attribute to true will cause errors caused by invalid search base to be silently swallowed. 337 | Default is false. 338 | 339 | 340 | 341 | 342 | 343 | 344 | Specifies whether PartialResultException should be ignored in searches. Some LDAP servers 345 | have problems with referrals; these should normally be followed automatically, but if this 346 | doesn't work it will manifest itself with a PartialResultException. Setting this attribute 347 | to true presents a work-around to this problem. Default is false. 348 | 349 | 350 | 351 | 352 | 353 | 354 | Id of the ObjectDirectoryMapper instance to use. Default is a default-configured DefaultObjectDirectoryMapper. 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | Creates an LdapTemplate instance. 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | Id of this instance. Default is "transactionManager". 376 | 377 | 378 | 379 | 380 | 381 | 382 | Id of the ContextSource instance to use. "contextSource". 383 | 384 | 385 | 386 | 387 | 388 | 389 | Id of the DataSource instance to use. 390 | 391 | 392 | 393 | 394 | 395 | 396 | Id of the Hibernate SessionFactory instance to use. 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | Creates an ContextSourceTransactionManager. If data-source-ref or session-factory-ref is specified, 406 | a DataSourceAndContextSourceTransactionManager/HibernateAndContextSourceTransactionManager will be 407 | created. 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | The default (simplistic) TempEntryRenamingStrategy. Please note that this 416 | strategy will not work for more advanced scenarios. See reference documentation 417 | for details. 418 | 419 | 420 | 421 | 422 | 423 | 424 | The default suffix that will be added to modified entries. 425 | Default is "_temp". 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | TempEntryRenamingStrategy that moves the entry to a different subtree than 435 | the original entry. 436 | 437 | 438 | 439 | 440 | 441 | 442 | The subtree base where changed entries should be moved. 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | The reference to an LdapTemplate. Will default to 'ldapTemplate'. 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-core/src/test/java/core/CoreClassTest.java: -------------------------------------------------------------------------------- 1 | package core; 2 | 3 | import org.junit.Test; 4 | 5 | public class CoreClassTest { 6 | 7 | @Test 8 | public void test() { 9 | new CoreClass().run(); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-core/src/test/java/core/HasOptionalTest.java: -------------------------------------------------------------------------------- 1 | package core; 2 | 3 | import org.junit.Test; 4 | 5 | public class HasOptionalTest { 6 | 7 | @Test 8 | public void test() { 9 | HasOptional.doStuffWithOptionalDependency(); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-docs/sgbcs-docs.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'io.spring.convention.docs' 3 | 4 | version = "1.0.0.BUILD-SNAPSHOT" 5 | 6 | asciidoctorj { 7 | attributes \ 8 | 'build-gradle': project.buildFile, 9 | 'sourcedir': project.sourceSets.main.java.srcDirs[0], 10 | 'endpoint-url': 'https://example.org' 11 | } -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-docs/src/docs/asciidoc/docinfo.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-docs/src/docs/asciidoc/images/sunset.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-gradle-plugins/spring-build-conventions/1527cecd379b865b8b70a85acea3c8e25068fb77/src/test/resources/samples/showcase/sgbcs-docs/src/docs/asciidoc/images/sunset.jpg -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-docs/src/docs/asciidoc/index.adoc: -------------------------------------------------------------------------------- 1 | = Example Manual 2 | Doc Writer 3 | 2014-09-09 4 | :example-caption!: 5 | ifndef::imagesdir[:imagesdir: images] 6 | ifndef::sourcedir[:sourcedir: ../java] 7 | 8 | This is a user manual for an example project. 9 | 10 | == Introduction 11 | 12 | This project does something. 13 | We just haven't decided what that is yet. 14 | 15 | == Source Code 16 | 17 | [source,java] 18 | .Java code from project 19 | ---- 20 | include::{sourcedir}/example/StringUtils.java[tags=contains,indent=0] 21 | ---- 22 | 23 | This page was built by the following command: 24 | 25 | $ ./gradlew asciidoctor 26 | 27 | == Images 28 | 29 | [.thumb] 30 | image::sunset.jpg[scaledwidth=75%] 31 | 32 | == Attributes 33 | 34 | .Built-in 35 | asciidoctor-version:: {asciidoctor-version} 36 | safe-mode-name:: {safe-mode-name} 37 | docdir:: {docdir} 38 | docfile:: {docfile} 39 | imagesdir:: {imagesdir} 40 | revnumber:: {revnumber} 41 | 42 | .Custom 43 | sourcedir:: {sourcedir} 44 | endpoint-url:: {endpoint-url} 45 | 46 | == Includes 47 | 48 | .include::subdir/_b.adoc[] 49 | ==== 50 | include::subdir/_b.adoc[] 51 | ==== 52 | 53 | WARNING: Includes can be tricky! 54 | 55 | == build.gradle 56 | 57 | [source,groovy] 58 | ---- 59 | include::{build-gradle}[] 60 | ---- 61 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-docs/src/docs/asciidoc/subdir/_b.adoc: -------------------------------------------------------------------------------- 1 | content from _src/docs/asciidoc/subdir/_b.adoc_. 2 | 3 | .include::_c.adoc[] 4 | [example] 5 | -- 6 | include::_c.adoc[] 7 | -- 8 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-docs/src/docs/asciidoc/subdir/_c.adoc: -------------------------------------------------------------------------------- 1 | content from _src/docs/asciidoc/subdir/c.adoc_. 2 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-docs/src/main/java/example/StringUtils.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | public class StringUtils { 4 | // tag::contains[] 5 | public boolean contains(String haystack, String needle) { 6 | return haystack.contains(needle); 7 | } 8 | // end::contains[] 9 | } 10 | -------------------------------------------------------------------------------- /src/test/resources/samples/testsconfiguration/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.tests-configuration' 3 | id 'java' 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/samples/testsconfiguration/core/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'io.spring.convention.tests-configuration' 2 | apply plugin: 'java' // second to test ordering 3 | -------------------------------------------------------------------------------- /src/test/resources/samples/testsconfiguration/core/src/test/java/sample/Dependency.java: -------------------------------------------------------------------------------- 1 | package sample; 2 | 3 | public class Dependency {} -------------------------------------------------------------------------------- /src/test/resources/samples/testsconfiguration/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':core' 2 | include ':web' -------------------------------------------------------------------------------- /src/test/resources/samples/testsconfiguration/web/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | 3 | repositories { 4 | mavenCentral() 5 | } 6 | 7 | dependencies { 8 | testCompile project(path: ':core', configuration: 'tests') 9 | testCompile 'junit:junit:4.12' 10 | } -------------------------------------------------------------------------------- /src/test/resources/samples/testsconfiguration/web/src/test/java/sample/DependencyTest.java: -------------------------------------------------------------------------------- 1 | package sample; 2 | 3 | import org.junit.*; 4 | 5 | public class DependencyTest { 6 | @Test 7 | public void findsDependencyOnClasspath() { 8 | new Dependency(); 9 | } 10 | } -------------------------------------------------------------------------------- /src/test/resources/test-private.pgp: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP PRIVATE KEY BLOCK----- 2 | 3 | lQWGBF7sxWEBDADekNzn2KDfbb8QGPTHZLzqvNgfYVGXIWLFfEWsA0wTPn3YQh78 4 | vhsK+nq598R5Rjt2s4lm/L8y5eQ4GWpok9wu5gna4s+nHbdwDjJKoXA/GVN8Y/oi 5 | g37CafIqWACdzGpN5fjvblsfrNjVmwLdgq2kYoYqduOtiFeeQDivRJdZp3417e3C 6 | xAdarksMkWOuDKD7JQU46ofxoMX5+WsvZ0DYuKybXAiVhNTpn3rl/4MIvu6XlMBS 7 | EdLCdQkrdiSs6dBt8iQWkSDmwl4qaFyOmtlwjtzpJ+mPYpTWWWN3ukBRCM/AJRqm 8 | IgLXnYnrvTmEmuZwfcZrLGwPDa30aaCK5Jjq4WLD1lwpFBuZMT46saLA+y8CvcSW 9 | 8vPAvQFzSrbBaEGu4ZIpU2aWBRW4JYpN+l90RFoWfdPyxrQ4rmPp4BIoEG25+zxI 10 | 8XMJNwr4T/t8C4I6YQfCKqnyeeR94ZF8JjGJh3Ts6nLHDN84IZbeJRypvYpcTPAD 11 | HZiWnk4QREuSyhEAEQEAAf4HAwLsRiB8Oo4Nef+LrgBEtQ86fdfs5mTbxPv+XNGb 12 | Wugl7HtIbgjhcmDw1zaWt9B7PKhSn2FQwJQduijE/Ae7OmNkFBQoeUeN0QADlarA 13 | Xb5dlANIbfEJk/9KR769YL9HTy6y25LxrfgH3mrV2848dA/ilgv/WGmAz0SGER1t 14 | OKvgOfGrmQECKbw7+U9EyEPl7nWRgJrkRK8/zgMnAA1TuXG3Rr3FvuUlw51MnBxx 15 | sYOj6A7Xk0ijvh1szMwcUwVtZWDAiRFVhMcgopf7jCKs1UlrWJ98sa7WNXje25Mo 16 | WXZ8VRA1/FbM/ifzuICOmKc7C+rNff7H3U7PBwRCGJrG6m0EJ/Cwrko5uHVq+fG5 17 | s2Vl7817ztM3/rkmNkC9jmE/sKHlkPlVc9hZGPTbqBC6BThpbBzNLUoTPmAgzbqU 18 | hgW2ES938D7ipt7IzhRxTitQN8a1JRk8v710g/D2skLhTx9T3SkJyJkXbmOVJJXc 19 | IN/mtlzRykR/c/TGOsMQR6v+nz42jZ1AY406AKMjd1R15wamscg4d457qVxn89T0 20 | wne+eShON8vPNpu1bAaN8soHxC5a4eVnLNVguxs+Abc0x/qwpwvd0VOMd86Aukte 21 | YsS+fzGSSpX9PqHVNThK9Z1dU13J7RONeO+2xZnThhiMyGvpqL5PQ3lE3P4zkccB 22 | jlQuuHW/6jD0/W1tlPPcsTcWDS4Ku7xxXg+ZSR3LfC4ukBWQLGiYNBWA2Zi1zW0A 23 | xXB9kdP9MJcxdBlsUa+xVrI71LcWaREGA/O5KGMmTXQaJJNvp/2bCauAIE8AJEN9 24 | MrGLe+SBu3n0PJxpCB3iqLXNe9nebf0I4E8uisKB6zcQMFMEWxI5R3oRweVKYIBo 25 | 8Le5tlJ9DSwvwTI0tyDMW7Y9KCrAcIpz7tx0cIn4RzMGzCtDaLpwDk973jUQcFeE 26 | OQBLCWPm2pIuoKO4RkIHaqhYXc9SYG3E+qQ481DohAoB/Gr3Vf80wQyIGAorg4wM 27 | OhYmFp5pl8XDDpa7Sth8w/0flA08IRA466IYaBAhuP0ug+rhMjNfLwy+anurUd9f 28 | M3UD21WqIUEscN5SkPI2OhGCXf5rbAQ+PkyrbgHXZpW29fGeUrAEP7FBWnCxylvL 29 | ijP/camoJLlOzr5CKi1TTkhitbfSMH1jQosw6JeiHtbnvCyrqNbPYw57gkpRH4FD 30 | Iql0TGAiHRe8l4s0xW79oiqN6vWKICCkekwcuc3NdNFsyxjtPdWI3ni0FulkHX0Y 31 | O+R0Ge+uwoPKiwCT6POzn1sPP6q8kbcvP0QmkNAx7b/JKRPEoe4u9oUNc5qS9gEC 32 | GxzvbXqq7Zv7UmYcTfNSjEWluIy0SYkVB7QkU3ByaW5nICh0ZXN0aW5nKSA8bm9y 33 | ZXBseUBzcHJpbmcuaW8+iQHOBBMBCgA4FiEEkkystQ8WdKVRsEMQjGaXsjMvWqAF 34 | Al7sxWECGwMFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AACgkQjGaXsjMvWqCNTAwA 35 | pg4/XCj0vqdeVNepw4p4mU/62yu2pKXh5usU2BcEvD8dEidUpGRJkyt5n1vWzvC6 36 | 8pbmn+Qa/6QKyL300RHeb3lpKQXbrtx3WWAMIO/JXh5lLtNaytw/N1IpqIVpg85G 37 | L27sjeGwInQ4MleLzKykxygIsqZYUE3KWCb75JmgtEQiyaivAmDxlFClaav35LQp 38 | aAyX2jrRPxPcD3qEL8JwDRpIlYwi1rcJgun9HIPAdma4AIarBBlEmEcXUus4rNAl 39 | 5vVgzB+v6dH3V+TiBL2QpepSoj4snA0iVyxGmLhhuuLf5gdb5sQgBY+BVxmqEji/ 40 | is9/Steis5d25JG5G2qaflv5H00aZBJeCsARKkhBMKqBILHAAkBdr611gGLcHusq 41 | T4GdhYx4BJK1mHjgY08pDV+My4xnwz1wcsS3iAl7efCu8X2lfe9ju+sV1EhXAtj0 42 | XAIaHz1k8bN4dPZDZG8Lk+2kH6WDLr7EOIsJCCsBp4HUFrxUUEdYaUsNDFxKxmmA 43 | nQWGBF7sxWEBDADRHc69S/XH4yDv7Msg7OWW2eEBKkFV7i6lMHCp+lNBqNtxx83Z 44 | ww8BRzqJZqvPRw219hwsVw7XN9YB1c8k5bw14mPx/VMK84oChPKRF58K9Ak8hyV5 45 | 3BSrd4N+DKPYut0l+WhHTfkPIguFGeHp8Kg/GphAlK2eieE8vzrwrUZdNqWCBbuF 46 | +JqU84g9XIMUtfPSIwbnaRh6DkU59cbEaHYl4ltr5+ZExhHypMKt4G0sJu3Vo1iq 47 | nA4NiB1rUwzsvB5NUvTErLDKHscdeKSfbf7VeMe/Oqaa5EHWQuDVWBMDhyqRt4bV 48 | kdHnHogjtNT8Ose2eYgqY+8rzJ1vs84DUuo6Osd/ATc0K6jodZpueYN1NQEP9l2s 49 | VsjJzT4rFb6RUglnEyp4LANrz4ogkx9Y9wnvti0Z3vtLQyAf/DmXBKXzos5lRLBw 50 | Ju+zqUUe6fww11LaftKdSI9yzhAP2ZnZFZ1FtVvuypLBrhZVsiYyRnDN6XhPxJgq 51 | 2A6yIoTNaq/xIA0AEQEAAf4HAwJBDiLQbcpQ8v9Dq9OdYRBZQxhMbhpVB45r8BeR 52 | obnNmZWHRrZcQ7xqaqqWLEb8dtqvAR6lo7c6uZNSpzW59s72HCCvNLm8W8J6iMIb 53 | oPD5Idbk1a0YXETUQOO5MP4NGzb/g6MInXhMM3TeC66YeZecXHiWwdDYk9nSiH7Q 54 | 207vKvDYCxNC1wIV8UqPI7ck0ekAczJB9PlpFDXD2W0JX/JB0hnBAIKKEsVshPEv 55 | FKlDXOrjx2fKV1kzrB9fSewfaKW5MrqWEEElikPwoo5o+mv57ClkhE6TmGqPSA+t 56 | 4kuTOlQwtVwlnLn0n0uyagRDs1eFUFuNXhFlAPAHbSMQeEVboYn7m9h7MYlVJwIT 57 | 4N/8w2cEnjAd/xX/O1maTxI/7MXTboCCE6j9NmLHWTX3MM/xhO248zhXbttwUkxf 58 | 2amL6QhsQiGtoyFKjhQtVTH8VVik05caEkWBOzKfldEVBrky8bacemW2EQp0uNAt 59 | 7IOwzv9uUuWOUd8yAyDb7rI4+JrYsUwFLFk49zFZrYwrn30WvaWTEkRRgL+xGfjC 60 | W4ZLa8OmOO8O6C2sbTZyyCN0noG2IUGdIsIEhVFPIoqyqGlZ8IxF6EovZniz4sf8 61 | Lu0Fo8YN+5LMiS9hCXs2Guv0jaSQ3vJtxU00/hT1zCc7/x9P1G6ks79r4aKJYCwS 62 | c/nAnT87YrXfQS3Zqa50HkbGqey7TwzwyrexC+eXgYvNhvXElG78hpPDhs/cyMcT 63 | ApQNy3jQcXbdXeVL9AfEl6DmDR/XWtWOpz9Cpxz321IT8t6j8ZOdan1F5rgVfNbv 64 | z7lx6AmI5GVZlTA2DBQGjmSHcfHbvo9EPcodALdSvAqwsSmuF72bJBYnkdyiO/6A 65 | /ElYpcHv3X0NRyC93hkipnyUkoBkyWEeDJb69w9tUCleqA4Rd6TuicEIep010lMT 66 | tbzy8wHAciN716PzfJPsnZBB2Mv9sXCzpbbZjT8TNmz6/O0d/a+LNaSCiTvjwqNd 67 | ERvWTgp6f6kcBQZFDSzZIMN9SHNaQAHAFOFVBA0IQfelcSz/bFz21Z9f0ZQ8b3ML 68 | FUMhx59D5Fcrvqn+5D6m8bAXw9gElRmUzi8BKyQay7JkHsQauS66yUrj2EEp94ch 69 | 8WdbE/zTNxbUWkIJxYg36EIYgrH8zf7/M00+tXk6HMZRy0wLbbJqQEh5tDV9Ht8z 70 | +Eu3x6/VKGIFjhtIhVY7ZDCM9wFZjsbq/kQDT8PB9X9wt5o/quDo8wg8Zm0qnJkD 71 | msPMXLh2ZVvKXiFM7WkhUYTOpxApOt+/jMGSqP2peCBqVIwQTdtQQ+wJZjx5sBmz 72 | 2eXKwEu+pmsRAsM3dtPuqXpJWUzrrcuI+okBtgQYAQoAIBYhBJJMrLUPFnSlUbBD 73 | EIxml7IzL1qgBQJe7MVhAhsMAAoJEIxml7IzL1qg9YsMAJXUf1+CJd5mVkOZ551+ 74 | INV3eIf+r5wXO7KoiK8CBUEnAqSNMrQ7QHTXwo9pSjuWR1O5JcRJumvZg/dj4Vox 75 | tb/l26Y5gdyYVkzwjKA6OnuHmICB3Y6xZVNrq1FUMiDThytHbuJz7mZZugJ69lMV 76 | ITA0iKJV+nFNP7slthTSpfP0XkQ74hnteWf+HadXU11MHFEw2Doi2xANMxzoQgy9 77 | 8uY6tp1/07Ll/Te5Y6YB1dlXrHiuJcX7/nUvmNa13y1cq28W2fqVsNVmZPZB7/SK 78 | DNyv6OT0iSIOBH/6AwoTzWo+Rcwr9PDKnII2fxizc3Jq75zjA+7F/Ol8fyaVrIbn 79 | 8oxh88rujnORKevIextgcrAlu+Q8dnspZ9oACqoKQM/W+mVb5ISr9Xf+qnicXWem 80 | uGi6ofVHUZzzJsVRdrASSA6B2+Aup+PP+SuxFSok02/DkxkD2zgT8Xt/T+/usBsy 81 | c9LeCkYBwNlcZZc7jWAJZ6Tt514F4wmJgKFgiuZ6MqBrRQ== 82 | =1LV7 83 | -----END PGP PRIVATE KEY BLOCK----- --------------------------------------------------------------------------------
33 | * The 'merge' extension should be used to define how projects are merged, for example: 34 | *
35 | * configure(subprojects) { 36 | * apply plugin: MergePlugin 37 | * } 38 | * 39 | * project("myproject") { 40 | * } 41 | * 42 | * project("myproject-extra") { 43 | * merge.into = project("myproject") 44 | * } 45 | *
47 | * This plugin adds two new configurations: 48 | *
26 | * Additionally, if 'gradle/dependency-management.gradle' file is present it will be 27 | * automatically applied file for configuring the dependencies. 28 | */ 29 | class SpringDependencyManagementConventionPlugin implements Plugin { 30 | 31 | static final String DEPENDENCY_MANAGEMENT_RESOURCE = "gradle/dependency-management.gradle" 32 | 33 | @Override 34 | void apply(Project project) { 35 | project.getPluginManager().apply(ManagementConfigurationPlugin) 36 | project.getPluginManager().apply(DependencyManagementPlugin) 37 | project.dependencyManagement { 38 | resolutionStrategy { 39 | cacheChangingModulesFor 0, "seconds" 40 | } 41 | } 42 | File rootDir = project.rootDir 43 | List dependencyManagementFiles = [project.rootProject.file(DEPENDENCY_MANAGEMENT_RESOURCE)] 44 | for (File dir = project.projectDir; dir != rootDir; dir = dir.parentFile) { 45 | dependencyManagementFiles.add(new File(dir, DEPENDENCY_MANAGEMENT_RESOURCE)) 46 | } 47 | dependencyManagementFiles.each { f -> 48 | if (f.exists()) { 49 | project.apply from: f.absolutePath 50 | } 51 | } 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/SpringMavenPlugin.groovy: -------------------------------------------------------------------------------- 1 | package io.spring.gradle.convention 2 | 3 | import io.spring.gradle.dependencymanagement.DependencyManagementPlugin 4 | import io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension 5 | import io.spring.gradle.dependencymanagement.dsl.GeneratedPomCustomizationHandler 6 | import org.gradle.api.Action 7 | import org.gradle.api.Plugin 8 | import org.gradle.api.Project 9 | import org.gradle.api.XmlProvider 10 | import org.gradle.api.artifacts.component.ModuleComponentSelector 11 | import org.gradle.api.artifacts.maven.MavenDeployment 12 | import org.gradle.api.artifacts.maven.MavenPom 13 | import org.gradle.api.artifacts.result.ResolvedDependencyResult 14 | import org.gradle.api.plugins.JavaBasePlugin 15 | import org.gradle.api.plugins.JavaPlugin 16 | import org.gradle.api.plugins.JavaPluginConvention 17 | import org.gradle.api.plugins.MavenPlugin 18 | import org.gradle.api.tasks.SourceSet 19 | import org.gradle.api.tasks.bundling.Jar 20 | import org.gradle.api.tasks.javadoc.Javadoc 21 | import org.gradle.plugins.signing.SigningPlugin 22 | import org.slf4j.Logger 23 | import org.slf4j.LoggerFactory 24 | 25 | public class SpringMavenPlugin implements Plugin { 26 | private static final String ARCHIVES = "archives"; 27 | Logger logger = LoggerFactory.getLogger(getClass()); 28 | 29 | @Override 30 | public void apply(Project project) { 31 | project.getPluginManager().apply(JavaPlugin.class); 32 | project.getPluginManager().apply(MavenPlugin.class); 33 | project.getPluginManager().apply(SigningPlugin.class); 34 | 35 | Javadoc javadoc = (Javadoc) project.getTasks().findByPath("javadoc"); 36 | Jar javadocJar = project.getTasks().create("javadocJar", Jar.class); 37 | javadocJar.setClassifier("javadoc"); 38 | javadocJar.from(javadoc); 39 | 40 | JavaPluginConvention java = project.getConvention().getPlugin(JavaPluginConvention.class); 41 | SourceSet mainSourceSet = java.getSourceSets().getByName("main"); 42 | Jar sourcesJar = project.getTasks().create("sourcesJar", Jar.class); 43 | sourcesJar.setClassifier("sources"); 44 | sourcesJar.from(mainSourceSet.getAllSource()); 45 | 46 | project.getArtifacts().add(ARCHIVES, javadocJar); 47 | project.getArtifacts().add(ARCHIVES, sourcesJar); 48 | 49 | project.install { 50 | repositories.mavenInstaller { 51 | configurePom(project, pom) 52 | } 53 | } 54 | project.uploadArchives { 55 | repositories.mavenDeployer { 56 | configurePom(project, pom) 57 | } 58 | } 59 | 60 | project.plugins.withType(DependencyManagementPlugin) { 61 | inlineDependencyManagement(project); 62 | } 63 | 64 | def hasSigningKey = project.hasProperty("signing.keyId") || project.findProperty("signingKey") 65 | if(hasSigningKey && Utils.isRelease(project)) { 66 | sign(project) 67 | } 68 | 69 | project.getPluginManager().apply("io.spring.convention.ossrh"); 70 | } 71 | 72 | private void inlineDependencyManagement(Project project) { 73 | final DependencyManagementExtension dependencyManagement = project.getExtensions().findByType(DependencyManagementExtension.class); 74 | dependencyManagement.generatedPomCustomization( { handler -> handler.setEnabled(false) }); 75 | 76 | project.install { 77 | repositories.mavenInstaller { 78 | configurePomForInlineDependencies(project, pom) 79 | } 80 | } 81 | project.uploadArchives { 82 | repositories.mavenDeployer { 83 | configurePomForInlineDependencies(project, pom) 84 | } 85 | } 86 | } 87 | 88 | private void configurePomForInlineDependencies(Project project, MavenPom pom) { 89 | pom.withXml { XmlProvider xml -> 90 | project.plugins.withType(JavaBasePlugin) { 91 | def dependencies = xml.asNode()?.dependencies?.dependency 92 | def configuredDependencies = project.configurations.findAll{ it.canBeResolved }*.incoming*.resolutionResult*.allDependencies.flatten() 93 | dependencies?.each { Node dep -> 94 | def group = dep.groupId.text() 95 | def name = dep.artifactId.text() 96 | 97 | ResolvedDependencyResult resolved = configuredDependencies.find { r -> 98 | (r.requested instanceof ModuleComponentSelector) && 99 | (r.requested.group == group) && 100 | (r.requested.module == name) 101 | } 102 | 103 | if (!resolved) { 104 | return 105 | } 106 | 107 | def versionNode = dep.version 108 | if (!versionNode) { 109 | dep.appendNode('version') 110 | } 111 | def moduleVersion = resolved.selected.moduleVersion 112 | dep.groupId[0].value = moduleVersion.group 113 | dep.artifactId[0].value = moduleVersion.name 114 | dep.version[0].value = moduleVersion.version 115 | } 116 | } 117 | } 118 | } 119 | 120 | private void sign(Project project) { 121 | project.install { 122 | repositories { 123 | mavenDeployer { 124 | beforeDeployment { MavenDeployment deployment -> project.signing.signPom(deployment) } 125 | } 126 | } 127 | } 128 | 129 | project.uploadArchives { 130 | repositories { 131 | mavenDeployer { 132 | beforeDeployment { MavenDeployment deployment -> project.signing.signPom(deployment) } 133 | } 134 | } 135 | } 136 | 137 | project.signing { 138 | required { project.gradle.taskGraph.hasTask("uploadArchives") } 139 | def signingKeyId = project.findProperty("signingKeyId") 140 | def signingKey = project.findProperty("signingKey") 141 | def signingPassword = project.findProperty("signingPassword") 142 | if (signingKeyId) { 143 | useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword) 144 | } else if (signingKey) { 145 | useInMemoryPgpKeys(signingKey, signingPassword) 146 | } 147 | sign project.configurations.archives 148 | } 149 | } 150 | 151 | private static void configurePom(Project project, MavenPom pom) { 152 | pom.whenConfigured { p -> 153 | p.dependencies = p.dependencies.sort { dep -> 154 | "$dep.scope:$dep.optional:$dep.groupId:$dep.artifactId" 155 | } 156 | } 157 | 158 | pom.project { 159 | boolean isWar = project.hasProperty("war"); 160 | String projectVersion = String.valueOf(project.getVersion()); 161 | String projectName = Utils.getProjectName(project); 162 | 163 | if(isWar) { 164 | packaging = "war" 165 | } 166 | name = project.name 167 | description = project.name 168 | url = 'https://spring.io/spring-security' 169 | organization { 170 | name = 'spring.io' 171 | url = 'https://spring.io/' 172 | } 173 | licenses { 174 | license { 175 | name 'The Apache Software License, Version 2.0' 176 | url 'https://www.apache.org/licenses/LICENSE-2.0.txt' 177 | distribution 'repo' 178 | } 179 | } 180 | scm { 181 | url = 'https://github.com/spring-projects/spring-security' 182 | connection = 'scm:git:git://github.com/spring-projects/spring-security' 183 | developerConnection = 'scm:git:git://github.com/spring-projects/spring-security' 184 | } 185 | developers { 186 | developer { 187 | id = 'rwinch' 188 | name = 'Rob Winch' 189 | email = 'rwinch@pivotal.io' 190 | } 191 | developer { 192 | id = 'jgrandja' 193 | name = 'Joe Grandja' 194 | email = 'jgrandja@pivotal.io' 195 | } 196 | } 197 | 198 | if(isWar) { 199 | properties { 200 | 'm2eclipse.wtp.contextRoot' '/' 201 | } 202 | } 203 | if (Utils.isSnapshot(project)) { 204 | repositories { 205 | repository { 206 | id 'spring-snapshot' 207 | url 'https://repo.spring.io/snapshot' 208 | } 209 | } 210 | } 211 | else if (Utils.isMilestone(project)) { 212 | repositories { 213 | repository { 214 | id 'spring-milestone' 215 | url 'https://repo.spring.io/milestone' 216 | } 217 | } 218 | } 219 | } 220 | } 221 | } 222 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/SpringModulePlugin.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package io.spring.gradle.convention; 18 | 19 | import org.gradle.api.Project 20 | import org.gradle.api.plugins.JavaLibraryPlugin; 21 | import org.gradle.api.plugins.MavenPlugin; 22 | import org.gradle.api.plugins.PluginManager; 23 | 24 | /** 25 | * @author Rob Winch 26 | */ 27 | class SpringModulePlugin extends AbstractSpringJavaPlugin { 28 | 29 | @Override 30 | void additionalPlugins(Project project) { 31 | PluginManager pluginManager = project.getPluginManager(); 32 | pluginManager.apply(JavaLibraryPlugin.class) 33 | pluginManager.apply(MavenPlugin.class); 34 | pluginManager.apply("io.spring.convention.maven"); 35 | pluginManager.apply("io.spring.convention.artifactory"); 36 | pluginManager.apply("io.spring.convention.jacoco"); 37 | pluginManager.apply("io.spring.convention.merge"); 38 | 39 | def deployArtifacts = project.task("deployArtifacts") 40 | deployArtifacts.group = 'Deploy tasks' 41 | deployArtifacts.description = "Deploys the artifacts to either Artifactory or Maven Central" 42 | if (Utils.isRelease(project)) { 43 | deployArtifacts.dependsOn project.tasks.uploadArchives 44 | } 45 | else { 46 | deployArtifacts.dependsOn project.tasks.artifactoryPublish 47 | } 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/SpringPomPlugin.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package io.spring.gradle.convention; 18 | 19 | /** 20 | * @author Rob Winch 21 | */ 22 | public class SpringPomPlugin extends SpringModulePlugin { 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/SpringSampleBootPlugin.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package io.spring.gradle.convention; 18 | 19 | import org.gradle.api.Project; 20 | import org.gradle.api.plugins.PluginManager; 21 | import org.gradle.api.plugins.WarPlugin 22 | import org.gradle.api.plugins.JavaPlugin; 23 | import org.gradle.api.tasks.testing.Test 24 | 25 | /** 26 | * @author Rob Winch 27 | */ 28 | public class SpringSampleBootPlugin extends SpringSamplePlugin { 29 | 30 | @Override 31 | public void additionalPlugins(Project project) { 32 | super.additionalPlugins(project); 33 | 34 | PluginManager pluginManager = project.getPluginManager(); 35 | 36 | pluginManager.apply("org.springframework.boot"); 37 | 38 | project.repositories { 39 | maven { url 'https://repo.spring.io/snapshot' } 40 | maven { url 'https://repo.spring.io/milestone' } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/SpringSamplePlugin.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package io.spring.gradle.convention; 18 | 19 | import org.gradle.api.Project 20 | import org.sonarqube.gradle.SonarQubePlugin; 21 | 22 | /** 23 | * @author Rob Winch 24 | */ 25 | public class SpringSamplePlugin extends AbstractSpringJavaPlugin { 26 | 27 | @Override 28 | public void additionalPlugins(Project project) { 29 | project.plugins.withType(SonarQubePlugin) { 30 | project.sonarqube.skipProject = true 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/SpringSampleWarPlugin.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package io.spring.gradle.convention 18 | 19 | import org.gradle.api.Project 20 | import org.gradle.api.Task 21 | import org.gradle.api.plugins.PluginManager 22 | import org.gradle.api.tasks.testing.Test 23 | 24 | /** 25 | * @author Rob Winch 26 | */ 27 | public class SpringSampleWarPlugin extends SpringSamplePlugin { 28 | 29 | @Override 30 | public void additionalPlugins(Project project) { 31 | super.additionalPlugins(project); 32 | 33 | PluginManager pluginManager = project.getPluginManager(); 34 | 35 | pluginManager.apply("war"); 36 | pluginManager.apply("org.gretty"); 37 | 38 | project.gretty { 39 | servletContainer = 'tomcat85' 40 | contextPath = '/' 41 | fileLogEnabled = false 42 | } 43 | 44 | Task prepareAppServerForIntegrationTests = project.tasks.create('prepareAppServerForIntegrationTests') { 45 | group = 'Verification' 46 | description = 'Prepares the app server for integration tests' 47 | doFirst { 48 | project.gretty { 49 | httpPort = getRandomFreePort() 50 | httpsPort = getRandomPort() 51 | } 52 | } 53 | } 54 | project.tasks.withType(org.akhikhl.gretty.AppBeforeIntegrationTestTask).all { task -> 55 | task.dependsOn prepareAppServerForIntegrationTests 56 | } 57 | 58 | project.tasks.withType(Test).all { task -> 59 | if("integrationTest".equals(task.name)) { 60 | applyForIntegrationTest(project, task) 61 | } 62 | } 63 | } 64 | 65 | def applyForIntegrationTest(Project project, Task integrationTest) { 66 | project.gretty.integrationTestTask = integrationTest.name 67 | 68 | integrationTest.doFirst { 69 | def gretty = project.gretty 70 | String host = project.gretty.host ?: 'localhost' 71 | boolean isHttps = gretty.httpsEnabled 72 | Integer httpPort = integrationTest.systemProperties['gretty.httpPort'] 73 | Integer httpsPort = integrationTest.systemProperties['gretty.httpsPort'] 74 | int port = isHttps ? httpsPort : httpPort 75 | String contextPath = project.gretty.contextPath 76 | String httpBaseUrl = "http://${host}:${httpPort}${contextPath}" 77 | String httpsBaseUrl = "https://${host}:${httpsPort}${contextPath}" 78 | String baseUrl = isHttps ? httpsBaseUrl : httpBaseUrl 79 | integrationTest.systemProperty 'app.port', port 80 | integrationTest.systemProperty 'app.httpPort', httpPort 81 | integrationTest.systemProperty 'app.httpsPort', httpsPort 82 | integrationTest.systemProperty 'app.baseURI', baseUrl 83 | integrationTest.systemProperty 'app.httpBaseURI', httpBaseUrl 84 | integrationTest.systemProperty 'app.httpsBaseURI', httpsBaseUrl 85 | 86 | integrationTest.systemProperty 'geb.build.baseUrl', baseUrl 87 | integrationTest.systemProperty 'geb.build.reportsDir', 'build/geb-reports' 88 | } 89 | } 90 | 91 | def getRandomPort() { 92 | ServerSocket ss = new ServerSocket(0) 93 | int port = ss.localPort 94 | ss.close() 95 | return port 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/SpringTestPlugin.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package io.spring.gradle.convention; 18 | 19 | import org.gradle.api.Project; 20 | 21 | /** 22 | * @author Rob Winch 23 | */ 24 | public class SpringTestPlugin extends AbstractSpringJavaPlugin { 25 | 26 | @Override 27 | public void additionalPlugins(Project project) { 28 | project.sonarqube.skipProject = true 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/TestsConfigurationPlugin.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package io.spring.gradle.convention; 17 | 18 | import org.gradle.api.Plugin 19 | import org.gradle.api.Project 20 | import org.gradle.api.plugins.JavaPlugin 21 | import org.gradle.jvm.tasks.Jar 22 | 23 | /** 24 | * Adds the ability to depends on the test jar within other projects using: 25 | * 26 | * 27 | * testCompile project(path: ':foo', configuration: 'tests') 28 | * 29 | * 30 | * @author Rob Winch 31 | */ 32 | public class TestsConfigurationPlugin implements Plugin { 33 | @Override 34 | public void apply(Project project) { 35 | project.plugins.withType(JavaPlugin) { 36 | applyJavaProject(project) 37 | } 38 | } 39 | 40 | private void applyJavaProject(Project project) { 41 | project.configurations { 42 | tests.extendsFrom testRuntime 43 | } 44 | 45 | project.tasks.create('testJar', Jar) { 46 | classifier = 'test' 47 | from project.sourceSets.test.output 48 | } 49 | 50 | project.artifacts { 51 | tests project.testJar 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/groovy/io/spring/gradle/convention/Utils.groovy: -------------------------------------------------------------------------------- 1 | package io.spring.gradle.convention; 2 | 3 | import org.gradle.api.Project; 4 | 5 | public class Utils { 6 | 7 | static String getProjectName(Project project) { 8 | String projectName = project.getRootProject().getName(); 9 | if(projectName.endsWith("-build")) { 10 | projectName = projectName.substring(0, projectName.length() - "-build".length()); 11 | } 12 | return projectName; 13 | } 14 | 15 | static boolean isSnapshot(Project project) { 16 | String projectVersion = projectVersion(project) 17 | return projectVersion.matches('^.*([.-]BUILD)?-SNAPSHOT$') 18 | } 19 | 20 | static boolean isMilestone(Project project) { 21 | String projectVersion = projectVersion(project) 22 | return projectVersion.matches('^.*[.-]M\\d+$') || projectVersion.matches('^.*[.-]RC\\d+$') 23 | } 24 | 25 | static boolean isRelease(Project project) { 26 | return !(isSnapshot(project) || isMilestone(project)) 27 | } 28 | 29 | private static String projectVersion(Project project) { 30 | return String.valueOf(project.getVersion()); 31 | } 32 | 33 | private Utils() {} 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/spring/gradle/convention/AsciidoctorConventionPlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-2020 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.spring.gradle.convention; 18 | 19 | import org.asciidoctor.gradle.base.AsciidoctorAttributeProvider; 20 | import org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask; 21 | import org.asciidoctor.gradle.jvm.AsciidoctorJExtension; 22 | import org.asciidoctor.gradle.jvm.AsciidoctorJPlugin; 23 | import org.asciidoctor.gradle.jvm.AsciidoctorTask; 24 | import org.gradle.api.Action; 25 | import org.gradle.api.Plugin; 26 | import org.gradle.api.Project; 27 | import org.gradle.api.artifacts.Configuration; 28 | import org.gradle.api.artifacts.DependencySet; 29 | import org.gradle.api.artifacts.dsl.RepositoryHandler; 30 | import org.gradle.api.file.CopySpec; 31 | import org.gradle.api.file.FileTree; 32 | import org.gradle.api.tasks.Sync; 33 | 34 | import java.io.File; 35 | import java.net.URI; 36 | import java.time.LocalDate; 37 | import java.util.ArrayList; 38 | import java.util.Collections; 39 | import java.util.HashMap; 40 | import java.util.List; 41 | import java.util.Map; 42 | import java.util.concurrent.Callable; 43 | import java.util.function.Consumer; 44 | 45 | /** 46 | * Conventions that are applied in the presence of the {@link AsciidoctorJPlugin}. When 47 | * the plugin is applied: 48 | * 49 | * 50 | * All warnings are made fatal. 51 | * A task is created to resolve and unzip our documentation resources (CSS and 52 | * Javascript). 53 | * For each {@link AsciidoctorTask} (HTML only): 54 | * 55 | * A configuration named asciidoctorExtensions is ued to add the 56 | * block 57 | * switch extension 58 | * {@code doctype} {@link AsciidoctorTask#options(Map) option} is configured. 59 | * {@link AsciidoctorTask#attributes(Map) Attributes} are configured for syntax 60 | * highlighting, CSS styling, docinfo, etc. 61 | * 62 | * For each {@link AbstractAsciidoctorTask} (HTML and PDF): 63 | * 64 | * {@link AsciidoctorTask#attributes(Map) Attributes} are configured to enable 65 | * warnings for references to missing attributes, the year is added as @{code today-year}, 66 | * etc 67 | * {@link AbstractAsciidoctorTask#baseDirFollowsSourceDir() baseDirFollowsSourceDir()} 68 | * is enabled. 69 | * 70 | * 71 | * 72 | * @author Andy Wilkinson 73 | * @author Rob Winch 74 | */ 75 | public class AsciidoctorConventionPlugin implements Plugin { 76 | 77 | public void apply(Project project) { 78 | project.getPlugins().withType(AsciidoctorJPlugin.class, (asciidoctorPlugin) -> { 79 | createDefaultAsciidoctorRepository(project); 80 | makeAllWarningsFatal(project); 81 | Sync unzipResources = createUnzipDocumentationResourcesTask(project); 82 | project.getTasks().withType(AbstractAsciidoctorTask.class, (asciidoctorTask) -> { 83 | asciidoctorTask.dependsOn(unzipResources); 84 | configureExtensions(project, asciidoctorTask); 85 | configureCommonAttributes(project, asciidoctorTask); 86 | configureOptions(asciidoctorTask); 87 | asciidoctorTask.baseDirFollowsSourceDir(); 88 | asciidoctorTask.useIntermediateWorkDir(); 89 | asciidoctorTask.resources(new Action() { 90 | @Override 91 | public void execute(CopySpec resourcesSpec) { 92 | resourcesSpec.from(unzipResources); 93 | resourcesSpec.from(asciidoctorTask.getSourceDir(), new Action() { 94 | @Override 95 | public void execute(CopySpec resourcesSrcDirSpec) { 96 | // https://github.com/asciidoctor/asciidoctor-gradle-plugin/issues/523 97 | // For now copy the entire sourceDir over so that include files are 98 | // available in the intermediateWorkDir 99 | // resourcesSrcDirSpec.include("images/**"); 100 | } 101 | }); 102 | } 103 | }); 104 | if (asciidoctorTask instanceof AsciidoctorTask) { 105 | configureHtmlOnlyAttributes(project, asciidoctorTask); 106 | } 107 | }); 108 | }); 109 | } 110 | 111 | private void createDefaultAsciidoctorRepository(Project project) { 112 | project.getGradle().afterProject(new Action() { 113 | @Override 114 | public void execute(Project project) { 115 | RepositoryHandler repositories = project.getRepositories(); 116 | if (repositories.isEmpty()) { 117 | repositories.mavenCentral(); 118 | repositories.maven(repo -> { 119 | repo.setUrl(URI.create("https://repo.spring.io/release")); 120 | }); 121 | } 122 | } 123 | }); 124 | } 125 | 126 | private void makeAllWarningsFatal(Project project) { 127 | project.getExtensions().getByType(AsciidoctorJExtension.class).fatalWarnings(".*"); 128 | } 129 | 130 | private void configureExtensions(Project project, AbstractAsciidoctorTask asciidoctorTask) { 131 | Configuration extensionsConfiguration = project.getConfigurations().maybeCreate("asciidoctorExtensions"); 132 | extensionsConfiguration.defaultDependencies(new Action() { 133 | @Override 134 | public void execute(DependencySet dependencies) { 135 | dependencies.add(project.getDependencies().create("io.spring.asciidoctor:spring-asciidoctor-extensions-block-switch:0.4.2.RELEASE")); 136 | } 137 | }); 138 | asciidoctorTask.configurations(extensionsConfiguration); 139 | } 140 | 141 | private Sync createUnzipDocumentationResourcesTask(Project project) { 142 | Configuration documentationResources = project.getConfigurations().maybeCreate("documentationResources"); 143 | documentationResources.getDependencies() 144 | .add(project.getDependencies().create("io.spring.docresources:spring-doc-resources:0.2.5")); 145 | Sync unzipResources = project.getTasks().create("unzipDocumentationResources", 146 | Sync.class, new Action() { 147 | @Override 148 | public void execute(Sync sync) { 149 | sync.dependsOn(documentationResources); 150 | sync.from(new Callable>() { 151 | @Override 152 | public List call() throws Exception { 153 | List result = new ArrayList<>(); 154 | documentationResources.getAsFileTree().forEach(new Consumer() { 155 | @Override 156 | public void accept(File file) { 157 | result.add(project.zipTree(file)); 158 | } 159 | }); 160 | return result; 161 | } 162 | }); 163 | File destination = new File(project.getBuildDir(), "docs/resources"); 164 | sync.into(project.relativePath(destination)); 165 | } 166 | }); 167 | return unzipResources; 168 | } 169 | 170 | private void configureOptions(AbstractAsciidoctorTask asciidoctorTask) { 171 | asciidoctorTask.options(Collections.singletonMap("doctype", "book")); 172 | } 173 | 174 | private void configureHtmlOnlyAttributes(Project project, AbstractAsciidoctorTask asciidoctorTask) { 175 | Map attributes = new HashMap<>(); 176 | attributes.put("source-highlighter", "highlight.js"); 177 | attributes.put("highlightjsdir", "js/highlight"); 178 | attributes.put("highlightjs-theme", "github"); 179 | attributes.put("linkcss", true); 180 | attributes.put("icons", "font"); 181 | attributes.put("stylesheet", "css/spring.css"); 182 | asciidoctorTask.getAttributeProviders().add(new AsciidoctorAttributeProvider() { 183 | @Override 184 | public Map getAttributes() { 185 | Object version = project.getVersion(); 186 | Map attrs = new HashMap<>(); 187 | if (version != null && version.toString() != Project.DEFAULT_VERSION) { 188 | attrs.put("revnumber", version); 189 | } 190 | return attrs; 191 | } 192 | }); 193 | asciidoctorTask.attributes(attributes); 194 | } 195 | 196 | private void configureCommonAttributes(Project project, AbstractAsciidoctorTask asciidoctorTask) { 197 | Map attributes = new HashMap<>(); 198 | attributes.put("attribute-missing", "warn"); 199 | attributes.put("icons", "font"); 200 | attributes.put("idprefix", ""); 201 | attributes.put("idseparator", "-"); 202 | attributes.put("docinfo", "shared"); 203 | attributes.put("sectanchors", ""); 204 | attributes.put("sectnums", ""); 205 | attributes.put("today-year", LocalDate.now().getYear()); 206 | asciidoctorTask.attributes(attributes); 207 | } 208 | } 209 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.artifactory.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.ArtifactoryPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.bom.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.MavenBomPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.checkstyle.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.CheckstylePlugin 2 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.dependency-set.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.DependencySetPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.docs.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.DocsPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.integration-test.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.IntegrationTestPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.jacoco.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.JacocoPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.javadoc-api.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.JavadocApiPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.javadoc-options.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.JavadocOptionsPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.maven.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.SpringMavenPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.merge.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.MergePlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.ossrh.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.OssrhPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.repository.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.RepositoryConventionPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.root.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.RootProjectPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.spring-module.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.SpringModulePlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.spring-pom.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.SpringPomPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.spring-sample-boot.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.SpringSampleBootPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.spring-sample-war.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.SpringSampleWarPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.spring-sample.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.SpringSamplePlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.spring-test.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.SpringTestPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.springdependencymangement.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.SpringDependencyManagementConventionPlugin -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/io.spring.convention.tests-configuration.properties: -------------------------------------------------------------------------------- 1 | implementation-class=io.spring.gradle.convention.TestsConfigurationPlugin -------------------------------------------------------------------------------- /src/test/groovy/io/spring/gradle/convention/DependencySetPluginITest.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package io.spring.gradle.convention 17 | 18 | import io.spring.gradle.testkit.junit.rules.TestKit 19 | import org.gradle.testkit.runner.BuildResult 20 | import org.junit.Rule 21 | import spock.lang.Specification 22 | 23 | import static org.gradle.testkit.runner.TaskOutcome.SUCCESS 24 | 25 | class DependencySetPluginITest extends Specification { 26 | @Rule final TestKit testKit = new TestKit() 27 | 28 | def "dependencies"() { 29 | when: 30 | BuildResult result = testKit.withProjectResource("samples/dependencyset") 31 | .withArguments('dependencies') 32 | .build(); 33 | then: 34 | result.task(":dependencies").outcome == SUCCESS 35 | !result.output.contains("FAILED") 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/test/groovy/io/spring/gradle/convention/DocsPluginITest.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package io.spring.gradle.convention 17 | 18 | import io.spring.gradle.testkit.junit.rules.TestKit 19 | import org.gradle.testkit.runner.BuildResult 20 | import org.junit.Rule 21 | import spock.lang.Specification 22 | 23 | import java.util.zip.ZipFile 24 | 25 | import static org.gradle.testkit.runner.TaskOutcome.FAILED 26 | import static org.gradle.testkit.runner.TaskOutcome.SUCCESS 27 | 28 | class DocsPluginITest extends Specification { 29 | @Rule final TestKit testKit = new TestKit() 30 | 31 | def "build triggers docs"() { 32 | when: 33 | BuildResult result = testKit.withProjectResource("samples/docs/simple/") 34 | .withArguments('build') 35 | .build(); 36 | then: 37 | result.task(":build").outcome == SUCCESS 38 | and: 39 | result.task(":docs").outcome == SUCCESS 40 | and: 41 | result.task(":docsZip").outcome == SUCCESS 42 | and: 43 | def zip = new File(testKit.getRootDir(), 'build/distributions/simple-1.0.0.BUILD-SNAPSHOT-docs.zip') 44 | def names = new ZipFile(zip).entries()*.name 45 | names.contains("docs/reference/html5/index.html") 46 | names.contains("docs/reference/pdf/simple-reference.pdf") 47 | } 48 | 49 | def "asciidoc copies images"() { 50 | when: 51 | BuildResult result = testKit.withProjectResource("samples/docs/simple/") 52 | .withArguments('asciidoctor') 53 | .build(); 54 | then: 55 | result.task(":asciidoctor").outcome == SUCCESS 56 | new File(testKit.getRootDir(), "build/docs/asciidoc/images").exists() 57 | } 58 | 59 | def "asciidoc docinfo from resources used"() { 60 | when: 61 | BuildResult result = testKit.withProjectResource("samples/docs/simple/") 62 | .withArguments('asciidoctor') 63 | .build(); 64 | then: 65 | result.task(":asciidoctor").outcome == SUCCESS 66 | new File(testKit.getRootDir(), "build/docs/asciidoc/index.html").getText().contains("""""") 67 | } 68 | 69 | def "missing attribute fails"() { 70 | when: 71 | BuildResult result = testKit.withProjectResource("samples/docs/missing-attribute/") 72 | .withArguments(':asciidoctor') 73 | .buildAndFail(); 74 | then: 75 | result.task(":asciidoctor").outcome == FAILED 76 | } 77 | 78 | def "missing include"() { 79 | when: 80 | BuildResult result = testKit.withProjectResource("samples/docs/missing-include/") 81 | .withArguments(':asciidoctor') 82 | .buildAndFail(); 83 | then: 84 | result.task(":asciidoctor").outcome == FAILED 85 | } 86 | 87 | def "missing cross reference"() { 88 | when: 89 | BuildResult result = testKit.withProjectResource("samples/docs/missing-cross-reference/") 90 | .withArguments(':asciidoctor') 91 | .buildAndFail(); 92 | then: 93 | result.task(":asciidoctor").outcome == FAILED 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/test/groovy/io/spring/gradle/convention/IntegrationTestPluginITest.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package io.spring.gradle.convention 17 | 18 | import io.spring.gradle.testkit.junit.rules.TestKit 19 | import org.gradle.testkit.runner.BuildResult 20 | import org.junit.Rule 21 | import spock.lang.Specification 22 | 23 | import static org.gradle.testkit.runner.TaskOutcome.SUCCESS 24 | 25 | class IntegrationTestPluginITest extends Specification { 26 | @Rule final TestKit testKit = new TestKit() 27 | 28 | def "check with java plugin"() { 29 | when: 30 | BuildResult result = testKit.withProjectResource("samples/integrationtest/withjava/") 31 | .withArguments('check') 32 | .build(); 33 | then: 34 | result.task(":check").outcome == SUCCESS 35 | and: 36 | new File(testKit.getRootDir(), 'build/test-results/integrationTest/').exists() 37 | new File(testKit.getRootDir(), 'build/reports/tests/integrationTest/').exists() 38 | } 39 | 40 | def "check with propdeps"() { 41 | when: 42 | BuildResult result = testKit.withProjectResource("samples/integrationtest/withpropdeps/") 43 | .withArguments('check') 44 | .build(); 45 | then: 46 | result.task(":check").outcome == SUCCESS 47 | and: 48 | new File(testKit.getRootDir(), 'build/test-results/integrationTest/').exists() 49 | new File(testKit.getRootDir(), 'build/reports/tests/integrationTest/').exists() 50 | } 51 | 52 | def "check with groovy plugin"() { 53 | when: 54 | BuildResult result = testKit.withProjectResource("samples/integrationtest/withgroovy/") 55 | .withArguments('check') 56 | .build(); 57 | then: 58 | result.task(":check").outcome == SUCCESS 59 | and: 60 | new File(testKit.getRootDir(), 'build/test-results/integrationTest/').exists() 61 | new File(testKit.getRootDir(), 'build/reports/tests/integrationTest/').exists() 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/test/groovy/io/spring/gradle/convention/JacocoPluginITest.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package io.spring.gradle.convention 17 | 18 | import io.spring.gradle.testkit.junit.rules.TestKit 19 | import org.gradle.testkit.runner.BuildResult 20 | import org.junit.Rule 21 | import spock.lang.Specification 22 | 23 | import static org.gradle.testkit.runner.TaskOutcome.SUCCESS 24 | 25 | class JacocoPluginITest extends Specification { 26 | @Rule final TestKit testKit = new TestKit() 27 | 28 | def "check with java plugin"() { 29 | when: 30 | BuildResult result = testKit.withProjectResource("samples/jacoco/java/") 31 | .withArguments('check') 32 | .build(); 33 | then: 34 | result.task(":check").outcome == SUCCESS 35 | and: 36 | new File(testKit.getRootDir(), 'build/jacoco').exists() 37 | new File(testKit.getRootDir(), 'build/reports/jacoco/test/html/').exists() 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/groovy/io/spring/gradle/convention/JavadocApiPluginITest.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package io.spring.gradle.convention 17 | 18 | import org.gradle.testkit.runner.BuildResult 19 | import org.gradle.testkit.runner.GradleRunner 20 | import org.junit.Rule 21 | import org.junit.rules.TemporaryFolder 22 | import spock.lang.Specification 23 | 24 | import static org.gradle.testkit.runner.TaskOutcome.*; 25 | 26 | import io.spring.gradle.testkit.junit.rules.TestKit 27 | import org.apache.commons.io.FileUtils 28 | 29 | class JavadocApiPluginITest extends Specification { 30 | @Rule final TestKit testKit = new TestKit() 31 | 32 | def "multimodule api"() { 33 | when: 34 | BuildResult result = testKit.withProjectResource("samples/javadocapi/multimodule/") 35 | .withArguments('api') 36 | .build(); 37 | then: 38 | result.task(":api").outcome == SUCCESS 39 | and: 40 | File allClasses = new File(testKit.getRootDir(), 'build/api/allclasses-noframe.html'); 41 | allClasses.text.contains('sample/Api.html') 42 | allClasses.text.contains('sample/Impl.html') 43 | !allClasses.text.contains('sample/Sample.html') 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/test/groovy/io/spring/gradle/convention/ShowcaseITest.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package io.spring.gradle.convention 18 | 19 | import io.spring.gradle.testkit.junit.rules.TestKit 20 | import org.gradle.testkit.runner.BuildResult 21 | import org.gradle.testkit.runner.TaskOutcome 22 | import org.junit.Rule 23 | import spock.lang.Specification 24 | 25 | class ShowcaseITest extends Specification { 26 | 27 | @Rule final TestKit testKit = new TestKit() 28 | 29 | def "build"() { 30 | when: 31 | BuildResult result = testKit.withProjectResource("samples/showcase/") 32 | .withArguments('build','--stacktrace') 33 | .forwardOutput() 34 | .build(); 35 | then: 'entire build passes' 36 | result.output.contains("BUILD SUCCESSFUL") 37 | 38 | and: 'javadoc api works' 39 | 40 | and: 'integration tests run' 41 | new File(testKit.getRootDir(), 'samples/sgbcs-sample-war/build/test-results/integrationTest/').exists() 42 | new File(testKit.getRootDir(), 'samples/sgbcs-sample-war/build/reports/tests/integrationTest/').exists() 43 | } 44 | 45 | def "install"() { 46 | when: 47 | BuildResult result = testKit.withProjectResource("samples/showcase/") 48 | .withArguments('install','--stacktrace') 49 | .build(); 50 | then: 51 | result.output.contains("SUCCESS") 52 | 53 | and: 'pom exists' 54 | File pom = new File(testKit.getRootDir(), 'sgbcs-core/build/poms/pom-default.xml') 55 | pom.exists() 56 | String pomText = pom.getText() 57 | 58 | and: 'pom does not contain ' 59 | !pomText.contains('') 60 | 61 | and: 'creates optional dependencies correctly' 62 | pomText.replaceAll('\\s','').contains(""" 63 | org.springframework 64 | spring-test 65 | test 66 | 4.3.6.RELEASE 67 | """.replaceAll('\\s','')) 68 | 69 | and: 'adds author' 70 | pomText.replaceAll('\\s','').contains(""" 71 | 72 | rwinch 73 | Rob Winch 74 | rwinch@pivotal.io 75 | 76 | 77 | jgrandja 78 | Joe Grandja 79 | jgrandja@pivotal.io 80 | 81 | """.replaceAll('\\s','')) 82 | 83 | and: 'adds repositories' 84 | pomText.replaceAll('\\s','').contains(""" 85 | scm:git:git://github.com/spring-projects/spring-security 86 | scm:git:git://github.com/spring-projects/spring-security 87 | https://github.com/spring-projects/spring-security 88 | """.replaceAll('\\s','')) 89 | 90 | and: 'adds description & url' 91 | pomText.contains('sgbcs-core') 92 | pomText.contains('https://spring.io/spring-security') 93 | 94 | and: 'adds organization' 95 | pomText.replaceAll('\\s','').contains(''' 96 | spring.io 97 | https://spring.io/ 98 | '''.replaceAll('\\s','')) 99 | 100 | and: 'adds licenses' 101 | pomText.replaceAll('\\s','').contains(''' 102 | 103 | The Apache Software License, Version 2.0 104 | https://www.apache.org/licenses/LICENSE-2.0.txt 105 | repo 106 | 107 | '''.replaceAll('\\s','')) 108 | 109 | and: 'adds scm' 110 | pomText.replaceAll('\\s','').replaceAll('\\s','').contains(""" 111 | scm:git:git://github.com/spring-projects/spring-security 112 | scm:git:git://github.com/spring-projects/spring-security 113 | https://github.com/spring-projects/spring-security 114 | """.replaceAll('\\s','')) 115 | 116 | and: 'bom created' 117 | File bom = new File(testKit.getRootDir(), 'bom/build/poms/pom-default.xml') 118 | bom.exists() 119 | String bomText = bom.getText() 120 | bomText.contains("""sgbcs-core""") 121 | 122 | when: 'mavenBom ran again' 123 | result = testKit.withProjectResource("samples/showcase/") 124 | .withArguments('mavenBom','--stacktrace') 125 | .build(); 126 | then: 'mavenBom is not up to date since install is never up to date' 127 | result.task(':bom:mavenBom').getOutcome() == TaskOutcome.SUCCESS 128 | } 129 | 130 | } 131 | -------------------------------------------------------------------------------- /src/test/groovy/io/spring/gradle/convention/SpringMavenPluginITest.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2019 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package io.spring.gradle.convention 18 | 19 | import io.spring.gradle.testkit.junit.rules.TestKit 20 | import org.gradle.testkit.runner.BuildResult 21 | import org.junit.Rule 22 | import spock.lang.Specification 23 | 24 | import static org.gradle.testkit.runner.TaskOutcome.SUCCESS 25 | 26 | class SpringMavenPluginITest extends Specification { 27 | 28 | @Rule final TestKit testKit = new TestKit() 29 | 30 | def "install"() { 31 | when: 32 | BuildResult result = testKit.withProjectResource("samples/maven/install") 33 | .withArguments('install') 34 | .build(); 35 | then: 'pom contains optional' 36 | result.output.contains("SUCCESS") 37 | File pom = new File(testKit.getRootDir(), 'build/poms/pom-default.xml') 38 | pom.exists() 39 | String pomText = pom.getText() 40 | pomText.replaceAll('\\s','').contains(""" 41 | aopalliance 42 | aopalliance 43 | 1.0 44 | compile 45 | true 46 | """.replaceAll('\\s','')) 47 | } 48 | 49 | def "signArchives when in memory"() { 50 | when: 51 | BuildResult result = testKit.withProjectResource("samples/maven/signing") 52 | .withArguments('signArchives') 53 | .withEnvironment(["ORG_GRADLE_PROJECT_signingKey" : signingKey, 54 | "ORG_GRADLE_PROJECT_signingPassword" : "password"]) 55 | .forwardOutput() 56 | .build(); 57 | then: 58 | result.output.contains("SUCCESS") 59 | File jar = new File(testKit.getRootDir(), 'build/libs/signing-1.0.0.RELEASE.jar') 60 | jar.exists() 61 | File signature = new File("${jar.absolutePath}.asc") 62 | signature.exists() 63 | } 64 | 65 | def "upload"() { 66 | when: 67 | BuildResult result = testKit.withProjectResource("samples/maven/upload") 68 | .withArguments('uploadArchives') 69 | .forwardOutput() 70 | .build(); 71 | then: 'pom contains optional' 72 | result.output.contains("SUCCESS") 73 | File pom = new File(testKit.getRootDir(), 'build/poms/pom-default.xml') 74 | pom.exists() 75 | String pomText = pom.getText() 76 | pomText.replaceAll('\\s','').contains(""" 77 | aopalliance 78 | aopalliance 79 | 1.0 80 | compile 81 | true 82 | """.replaceAll('\\s','')) 83 | } 84 | 85 | def getSigningKey() { 86 | getClass().getResource("/test-private.pgp").text 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/test/groovy/io/spring/gradle/convention/TestsConfigurationPluginITest.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package io.spring.gradle.convention 17 | 18 | import io.spring.gradle.testkit.junit.rules.TestKit 19 | import org.gradle.testkit.runner.BuildResult 20 | import org.junit.Rule 21 | import spock.lang.Specification 22 | 23 | import static org.gradle.testkit.runner.TaskOutcome.SUCCESS 24 | 25 | class TestsConfigurationPluginITest extends Specification { 26 | @Rule final TestKit testKit = new TestKit() 27 | 28 | def "can find dependency"() { 29 | when: 30 | BuildResult result = testKit.withProjectResource("samples/testsconfiguration") 31 | .withArguments('check') 32 | .build(); 33 | then: 34 | result.task(":web:check").outcome == SUCCESS 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/test/groovy/io/spring/gradle/testkit/junit/rules/TestKit.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package io.spring.gradle.testkit.junit.rules; 17 | 18 | import java.io.File; 19 | import java.io.IOException; 20 | import java.io.InputStream; 21 | import java.net.URISyntaxException; 22 | import java.net.URL; 23 | import java.nio.file.Paths; 24 | import java.util.Enumeration; 25 | 26 | import org.apache.commons.io.FileUtils; 27 | import org.gradle.testkit.runner.GradleRunner; 28 | import org.junit.rules.TemporaryFolder; 29 | import org.junit.rules.TestRule; 30 | import org.junit.runner.Description; 31 | import org.junit.runners.model.Statement; 32 | 33 | public class TestKit implements TestRule { 34 | final TemporaryFolder testProjectDir = new TemporaryFolder(); 35 | File buildDir; 36 | 37 | @Override 38 | public Statement apply(Statement base, Description description) { 39 | Statement wrapped = new Statement() { 40 | 41 | @Override 42 | public void evaluate() throws Throwable { 43 | try { 44 | buildDir = testProjectDir.newFolder(); 45 | } catch(IOException e) { 46 | throw new RuntimeException(e); 47 | } 48 | base.evaluate(); 49 | } 50 | }; 51 | return testProjectDir.apply(wrapped, description); 52 | } 53 | 54 | public File getRootDir() { 55 | return buildDir; 56 | } 57 | 58 | public GradleRunner withProjectDir(File projectDir) throws IOException { 59 | FileUtils.copyDirectory(projectDir, buildDir); 60 | return GradleRunner.create() 61 | .withProjectDir(buildDir) 62 | .withPluginClasspath(); 63 | } 64 | 65 | public GradleRunner withProjectResource(String projectResourceName) throws IOException, URISyntaxException { 66 | ClassLoader classLoader = getClass().getClassLoader(); 67 | Enumeration resources = classLoader.getResources(projectResourceName); 68 | if(!resources.hasMoreElements()) { 69 | throw new IOException("Cannot find resource " + projectResourceName + " with " + classLoader); 70 | } 71 | URL resourceUrl = resources.nextElement(); 72 | File projectDir = Paths.get(resourceUrl.toURI()).toFile(); 73 | return withProjectDir(projectDir); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/test/java/io/spring/gradle/convention/IntegrationPluginTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package io.spring.gradle.convention; 18 | 19 | import org.apache.commons.io.FileUtils; 20 | import org.gradle.api.Project; 21 | import org.gradle.api.plugins.JavaPlugin; 22 | import org.gradle.api.tasks.javadoc.Javadoc; 23 | import org.gradle.testfixtures.ProjectBuilder; 24 | import org.junit.After; 25 | import org.junit.Test; 26 | 27 | import java.io.File; 28 | 29 | import static org.assertj.core.api.Assertions.assertThat; 30 | 31 | /** 32 | * @author Rob Winch 33 | */ 34 | public class IntegrationPluginTest { 35 | Project rootProject; 36 | 37 | @After 38 | public void cleanup() throws Exception { 39 | if (rootProject != null) { 40 | FileUtils.deleteDirectory(rootProject.getProjectDir()); 41 | } 42 | } 43 | 44 | @Test 45 | public void applyWhenNoSourceThenIntegrationTestTaskNull() { 46 | rootProject = ProjectBuilder.builder().build(); 47 | rootProject.getPlugins().apply(JavaPlugin.class); 48 | rootProject.getPlugins().apply(IntegrationTestPlugin.class); 49 | 50 | assertThat(rootProject.getTasks().findByPath("integrationTest")).isNull(); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/test/java/io/spring/gradle/convention/JavadocApiPluginTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2016 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package io.spring.gradle.convention; 18 | 19 | import java.io.File; 20 | 21 | import org.apache.commons.io.FileUtils; 22 | import static org.assertj.core.api.Assertions.assertThat; 23 | import org.gradle.api.Project; 24 | import org.gradle.api.tasks.javadoc.Javadoc; 25 | import org.gradle.testfixtures.ProjectBuilder; 26 | import org.junit.After; 27 | import org.junit.Test; 28 | 29 | /** 30 | * @author Rob Winch 31 | */ 32 | public class JavadocApiPluginTest { 33 | Project rootProject; 34 | 35 | @After 36 | public void cleanup() throws Exception { 37 | if (rootProject != null) { 38 | FileUtils.deleteDirectory(rootProject.getProjectDir()); 39 | } 40 | } 41 | 42 | @Test 43 | public void applyWhenNotOverrideThenPropertiesDefaulted() { 44 | rootProject = ProjectBuilder.builder().build(); 45 | rootProject.getPlugins().apply(JavadocApiPlugin.class); 46 | 47 | Javadoc apiTask = (Javadoc) rootProject.getTasks().getByPath("api"); 48 | 49 | assertThat(apiTask).isNotNull(); 50 | assertThat(apiTask.getGroup()).isEqualTo("Documentation"); 51 | assertThat(apiTask.getDescription()).isEqualTo("Generates aggregated Javadoc API documentation."); 52 | assertThat(apiTask.getMaxMemory()).isEqualTo("1024m"); 53 | assertThat(apiTask.getDestinationDir()).isEqualTo(new File(rootProject.getBuildDir(), "api")); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/test/java/io/spring/gradle/convention/RepositoryConventionPluginTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016-2018 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | 17 | package io.spring.gradle.convention; 18 | 19 | import org.gradle.api.Project; 20 | import org.gradle.api.artifacts.dsl.RepositoryHandler; 21 | import org.gradle.api.artifacts.repositories.ArtifactRepository; 22 | import org.gradle.api.artifacts.repositories.MavenArtifactRepository; 23 | import org.gradle.api.plugins.ExtraPropertiesExtension; 24 | import org.gradle.testfixtures.ProjectBuilder; 25 | import org.junit.Before; 26 | import org.junit.Test; 27 | 28 | import static org.assertj.core.api.Assertions.assertThat; 29 | 30 | /** 31 | * Tests for {@link RepositoryConventionPlugin}. 32 | */ 33 | public class RepositoryConventionPluginTests { 34 | 35 | private Project project = ProjectBuilder.builder().build(); 36 | 37 | @Before 38 | public void setUp() { 39 | this.project.getProperties().clear(); 40 | } 41 | 42 | @Test 43 | public void applyWhenIsReleaseThenShouldIncludeReleaseRepo() { 44 | this.project.setVersion("1.0.0.RELEASE"); 45 | this.project.getPluginManager().apply(RepositoryConventionPlugin.class); 46 | 47 | RepositoryHandler repositories = this.project.getRepositories(); 48 | assertReleaseRepository(repositories); 49 | } 50 | 51 | @Test 52 | public void applyWhenIsMilestoneThenShouldIncludeMilestoneRepo() { 53 | this.project.setVersion("1.0.0.M1"); 54 | this.project.getPluginManager().apply(RepositoryConventionPlugin.class); 55 | 56 | RepositoryHandler repositories = this.project.getRepositories(); 57 | assertMilestoneRepository(repositories); // milestone 58 | } 59 | 60 | @Test 61 | public void applyWhenIsSnapshotThenShouldIncludeSnapshotRepo() { 62 | this.project.setVersion("1.0.0.BUILD-SNAPSHOT"); 63 | this.project.getPluginManager().apply(RepositoryConventionPlugin.class); 64 | 65 | RepositoryHandler repositories = this.project.getRepositories(); 66 | assertSnapshotRepository(repositories); 67 | } 68 | 69 | @Test 70 | public void applyWhenIsSnapshotWithForceReleaseThenShouldOnlyIncludeReleaseRepo() { 71 | this.project.getExtensions().getByType(ExtraPropertiesExtension.class) 72 | .set("forceMavenRepositories", "release"); 73 | this.project.setVersion("1.0.0.RELEASE"); 74 | this.project.getPluginManager().apply(RepositoryConventionPlugin.class); 75 | 76 | RepositoryHandler repositories = this.project.getRepositories(); 77 | assertReleaseRepository(repositories); 78 | } 79 | 80 | @Test 81 | public void applyWhenIsReleaseWithForceMilestoneThenShouldIncludeMilestoneRepo() { 82 | this.project.getExtensions().getByType(ExtraPropertiesExtension.class) 83 | .set("forceMavenRepositories", "milestone"); 84 | this.project.setVersion("1.0.0.RELEASE"); 85 | this.project.getPluginManager().apply(RepositoryConventionPlugin.class); 86 | 87 | RepositoryHandler repositories = this.project.getRepositories(); 88 | assertMilestoneRepository(repositories); 89 | } 90 | 91 | @Test 92 | public void applyWhenIsReleaseWithForceSnapshotThenShouldIncludeSnapshotRepo() { 93 | this.project.getExtensions().getByType(ExtraPropertiesExtension.class) 94 | .set("forceMavenRepositories", "snapshot"); 95 | this.project.setVersion("1.0.0.RELEASE"); 96 | this.project.getPluginManager().apply(RepositoryConventionPlugin.class); 97 | 98 | RepositoryHandler repositories = this.project.getRepositories(); 99 | assertSnapshotRepository(repositories); 100 | } 101 | 102 | @Test 103 | public void applyWhenIsReleaseWithForceLocalThenShouldIncludeReleaseAndLocalRepos() { 104 | this.project.getExtensions().getByType(ExtraPropertiesExtension.class) 105 | .set("forceMavenRepositories", "local"); 106 | this.project.setVersion("1.0.0.RELEASE"); 107 | this.project.getPluginManager().apply(RepositoryConventionPlugin.class); 108 | 109 | RepositoryHandler repositories = this.project.getRepositories(); 110 | assertThat(repositories).hasSize(4); 111 | assertThat((repositories.get(0)).getName()).isEqualTo("MavenLocal"); 112 | } 113 | 114 | @Test 115 | public void applyWhenIsReleaseWithForceMilestoneAndLocalThenShouldIncludeMilestoneAndLocalRepos() { 116 | this.project.getExtensions().getByType(ExtraPropertiesExtension.class) 117 | .set("forceMavenRepositories", "milestone,local"); 118 | this.project.setVersion("1.0.0.RELEASE"); 119 | this.project.getPluginManager().apply(RepositoryConventionPlugin.class); 120 | 121 | RepositoryHandler repositories = this.project.getRepositories(); 122 | assertThat(repositories).hasSize(5); 123 | assertThat((repositories.get(0)).getName()).isEqualTo("MavenLocal"); 124 | } 125 | 126 | private void assertSnapshotRepository(RepositoryHandler repositories) { 127 | assertThat(repositories).extracting(ArtifactRepository::getName).hasSize(5); 128 | assertThat(((MavenArtifactRepository) repositories.get(0)).getUrl().toString()) 129 | .isEqualTo("https://repo.maven.apache.org/maven2/"); 130 | assertThat(((MavenArtifactRepository) repositories.get(1)).getUrl().toString()) 131 | .isEqualTo("https://jcenter.bintray.com/"); 132 | assertThat(((MavenArtifactRepository) repositories.get(2)).getUrl().toString()) 133 | .isEqualTo("https://repo.spring.io/snapshot/"); 134 | assertThat(((MavenArtifactRepository) repositories.get(3)).getUrl().toString()) 135 | .isEqualTo("https://repo.spring.io/milestone/"); 136 | } 137 | 138 | private void assertMilestoneRepository(RepositoryHandler repositories) { 139 | assertThat(repositories).extracting(ArtifactRepository::getName).hasSize(4); 140 | assertThat(((MavenArtifactRepository) repositories.get(0)).getUrl().toString()) 141 | .isEqualTo("https://repo.maven.apache.org/maven2/"); 142 | assertThat(((MavenArtifactRepository) repositories.get(1)).getUrl().toString()) 143 | .isEqualTo("https://jcenter.bintray.com/"); 144 | assertThat(((MavenArtifactRepository) repositories.get(2)).getUrl().toString()) 145 | .isEqualTo("https://repo.spring.io/milestone/"); 146 | } 147 | 148 | private void assertReleaseRepository(RepositoryHandler repositories) { 149 | assertThat(repositories).extracting(ArtifactRepository::getName).hasSize(3); 150 | assertThat(((MavenArtifactRepository) repositories.get(0)).getUrl().toString()) 151 | .isEqualTo("https://repo.maven.apache.org/maven2/"); 152 | assertThat(((MavenArtifactRepository) repositories.get(1)).getUrl().toString()) 153 | .isEqualTo("https://jcenter.bintray.com/"); 154 | assertThat(((MavenArtifactRepository) repositories.get(2)).getUrl().toString()) 155 | .isEqualTo("https://repo.spring.io/release/"); 156 | } 157 | 158 | } 159 | -------------------------------------------------------------------------------- /src/test/java/io/spring/gradle/convention/UtilsTest.java: -------------------------------------------------------------------------------- 1 | package io.spring.gradle.convention; 2 | 3 | 4 | import static org.assertj.core.api.Assertions.assertThat; 5 | import static org.mockito.Mockito.when; 6 | 7 | import org.gradle.api.Project; 8 | import org.junit.Before; 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | import org.mockito.Mock; 12 | import org.mockito.junit.MockitoJUnitRunner; 13 | 14 | @RunWith(MockitoJUnitRunner.class) 15 | public class UtilsTest { 16 | @Mock 17 | Project project; 18 | @Mock 19 | Project rootProject; 20 | 21 | @Before 22 | public void setup() { 23 | when(project.getRootProject()).thenReturn(rootProject); 24 | } 25 | 26 | @Test 27 | public void getProjectName() { 28 | when(rootProject.getName()).thenReturn("spring-security"); 29 | 30 | assertThat(Utils.getProjectName(project)).isEqualTo("spring-security"); 31 | } 32 | 33 | @Test 34 | public void getProjectNameWhenEndsWithBuildThenStrippedOut() { 35 | when(rootProject.getName()).thenReturn("spring-security-build"); 36 | 37 | assertThat(Utils.getProjectName(project)).isEqualTo("spring-security"); 38 | } 39 | 40 | @Test 41 | public void isSnapshotValidWithDot() { 42 | when(project.getVersion()).thenReturn("1.0.0.BUILD-SNAPSHOT"); 43 | 44 | assertThat(Utils.isSnapshot(project)).isTrue(); 45 | } 46 | 47 | @Test 48 | public void isSnapshotValidWithNoBuild() { 49 | when(project.getVersion()).thenReturn("1.0.0-SNAPSHOT"); 50 | 51 | assertThat(Utils.isSnapshot(project)).isTrue(); 52 | } 53 | 54 | @Test 55 | public void isSnapshotValidWithDash() { 56 | when(project.getVersion()).thenReturn("Theme-BUILD-SNAPSHOT"); 57 | 58 | assertThat(Utils.isSnapshot(project)).isTrue(); 59 | } 60 | 61 | @Test 62 | public void isSnapshotInvalid() { 63 | when(project.getVersion()).thenReturn("1.0.0.SNAPSHOT"); 64 | 65 | assertThat(Utils.isSnapshot(project)).isFalse(); 66 | } 67 | 68 | @Test 69 | public void isMilestoneValidWithDot() { 70 | when(project.getVersion()).thenReturn("1.0.0.M1"); 71 | 72 | assertThat(Utils.isMilestone(project)).isTrue(); 73 | } 74 | 75 | @Test 76 | public void isMilestoneValidWithDash() { 77 | when(project.getVersion()).thenReturn("Theme-M1"); 78 | 79 | assertThat(Utils.isMilestone(project)).isTrue(); 80 | } 81 | 82 | @Test 83 | public void isMilestoneValidWithNumberDash() { 84 | when(project.getVersion()).thenReturn("1.0.0-M1"); 85 | 86 | assertThat(Utils.isMilestone(project)).isTrue(); 87 | } 88 | 89 | @Test 90 | public void isMilestoneInvalid() { 91 | when(project.getVersion()).thenReturn("1.0.0.M"); 92 | 93 | assertThat(Utils.isMilestone(project)).isFalse(); 94 | } 95 | 96 | @Test 97 | public void isReleaseCandidateValidWithDot() { 98 | when(project.getVersion()).thenReturn("1.0.0.RC1"); 99 | 100 | assertThat(Utils.isMilestone(project)).isTrue(); 101 | } 102 | 103 | @Test 104 | public void isReleaseCandidateValidWithNumberDash() { 105 | when(project.getVersion()).thenReturn("1.0.0-RC1"); 106 | 107 | assertThat(Utils.isMilestone(project)).isTrue(); 108 | } 109 | 110 | @Test 111 | public void isReleaseCandidateValidWithDash() { 112 | when(project.getVersion()).thenReturn("Theme-RC1"); 113 | 114 | assertThat(Utils.isMilestone(project)).isTrue(); 115 | } 116 | 117 | @Test 118 | public void isReleaseCandidateInvalid() { 119 | when(project.getVersion()).thenReturn("1.0.0.RC"); 120 | 121 | assertThat(Utils.isMilestone(project)).isFalse(); 122 | } 123 | 124 | @Test 125 | public void isReleaseValidWithDot() { 126 | when(project.getVersion()).thenReturn("1.0.0.RELEASE"); 127 | 128 | assertThat(Utils.isRelease(project)).isTrue(); 129 | } 130 | 131 | @Test 132 | public void isReleaseValidWithNoRelease() { 133 | when(project.getVersion()).thenReturn("1.0.0"); 134 | 135 | assertThat(Utils.isRelease(project)).isTrue(); 136 | } 137 | 138 | @Test 139 | public void isReleaseValidWithDash() { 140 | when(project.getVersion()).thenReturn("Theme-RELEASE"); 141 | 142 | assertThat(Utils.isRelease(project)).isTrue(); 143 | } 144 | 145 | @Test 146 | public void isServiceReleaseValid() { 147 | when(project.getVersion()).thenReturn("Theme-SR1"); 148 | 149 | assertThat(Utils.isRelease(project)).isTrue(); 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /src/test/resources/samples/dependencyset/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.dependency-set' 3 | } 4 | 5 | apply plugin: 'java' 6 | apply from: "$rootDir/gradle/dependency-management.gradle" 7 | 8 | repositories { 9 | mavenCentral() 10 | } 11 | 12 | dependencies { 13 | testCompile spockDependencies 14 | testCompile gebDependencies 15 | testCompile powerMockDependencies 16 | testCompile seleniumDependencies 17 | testCompile slf4jDependencies 18 | testCompile springCoreDependency 19 | testCompile jstlDependencies 20 | testCompile apachedsDependencies 21 | } -------------------------------------------------------------------------------- /src/test/resources/samples/docs/missing-attribute/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.docs' 3 | id 'java' 4 | } 5 | 6 | version = '1.0.0.BUILD-SNAPSHOT' -------------------------------------------------------------------------------- /src/test/resources/samples/docs/missing-attribute/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'simple' -------------------------------------------------------------------------------- /src/test/resources/samples/docs/missing-attribute/src/docs/asciidoc/index.adoc: -------------------------------------------------------------------------------- 1 | = Example Manual 2 | 3 | This will fail due to {missing} attribute -------------------------------------------------------------------------------- /src/test/resources/samples/docs/missing-cross-reference/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.docs' 3 | id 'java' 4 | } 5 | 6 | version = '1.0.0.BUILD-SNAPSHOT' -------------------------------------------------------------------------------- /src/test/resources/samples/docs/missing-cross-reference/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'missing-include' -------------------------------------------------------------------------------- /src/test/resources/samples/docs/missing-cross-reference/src/docs/asciidoc/index.adoc: -------------------------------------------------------------------------------- 1 | = Example Manual 2 | 3 | This will fail due to <> cross reference -------------------------------------------------------------------------------- /src/test/resources/samples/docs/missing-include/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.docs' 3 | id 'java' 4 | } 5 | 6 | version = '1.0.0.BUILD-SNAPSHOT' -------------------------------------------------------------------------------- /src/test/resources/samples/docs/missing-include/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'missing-include' -------------------------------------------------------------------------------- /src/test/resources/samples/docs/missing-include/src/docs/asciidoc/index.adoc: -------------------------------------------------------------------------------- 1 | = Example Manual 2 | 3 | This will fail due to missing include 4 | 5 | include::missing.adoc[] -------------------------------------------------------------------------------- /src/test/resources/samples/docs/simple/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.docs' 3 | id 'java' 4 | } 5 | 6 | version = '1.0.0.BUILD-SNAPSHOT' 7 | 8 | asciidoctorj { 9 | attributes \ 10 | 'build-gradle': project.buildFile, 11 | 'sourcedir': project.sourceSets.main.java.srcDirs[0], 12 | 'endpoint-url': 'https://example.org' 13 | } -------------------------------------------------------------------------------- /src/test/resources/samples/docs/simple/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'simple' -------------------------------------------------------------------------------- /src/test/resources/samples/docs/simple/src/docs/asciidoc/docinfo.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/test/resources/samples/docs/simple/src/docs/asciidoc/images/sunset.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-gradle-plugins/spring-build-conventions/1527cecd379b865b8b70a85acea3c8e25068fb77/src/test/resources/samples/docs/simple/src/docs/asciidoc/images/sunset.jpg -------------------------------------------------------------------------------- /src/test/resources/samples/docs/simple/src/docs/asciidoc/index.adoc: -------------------------------------------------------------------------------- 1 | = Example Manual 2 | Doc Writer 3 | 2014-09-09 4 | :example-caption!: 5 | ifndef::imagesdir[:imagesdir: images] 6 | ifndef::sourcedir[:sourcedir: ../java] 7 | 8 | This is a user manual for an example project. 9 | 10 | == Introduction 11 | 12 | This project does something. 13 | We just haven't decided what that is yet. 14 | 15 | == Source Code 16 | 17 | [source,java] 18 | .Java code from project 19 | ---- 20 | include::{sourcedir}/example/StringUtils.java[tags=contains,indent=0] 21 | ---- 22 | 23 | This page was built by the following command: 24 | 25 | $ ./gradlew asciidoctor 26 | 27 | == Images 28 | 29 | [.thumb] 30 | image::sunset.jpg[scaledwidth=75%] 31 | 32 | == Attributes 33 | 34 | .Built-in 35 | asciidoctor-version:: {asciidoctor-version} 36 | safe-mode-name:: {safe-mode-name} 37 | docdir:: {docdir} 38 | docfile:: {docfile} 39 | imagesdir:: {imagesdir} 40 | revnumber:: {revnumber} 41 | 42 | .Custom 43 | sourcedir:: {sourcedir} 44 | endpoint-url:: {endpoint-url} 45 | 46 | == Includes 47 | 48 | .include::subdir/_b.adoc[] 49 | ==== 50 | include::subdir/_b.adoc[] 51 | ==== 52 | 53 | WARNING: Includes can be tricky! 54 | 55 | == build.gradle 56 | 57 | [source,groovy] 58 | ---- 59 | include::{build-gradle}[] 60 | ---- 61 | -------------------------------------------------------------------------------- /src/test/resources/samples/docs/simple/src/docs/asciidoc/subdir/_b.adoc: -------------------------------------------------------------------------------- 1 | content from _src/docs/asciidoc/subdir/_b.adoc_. 2 | 3 | .include::_c.adoc[] 4 | [example] 5 | -- 6 | include::_c.adoc[] 7 | -- 8 | -------------------------------------------------------------------------------- /src/test/resources/samples/docs/simple/src/docs/asciidoc/subdir/_c.adoc: -------------------------------------------------------------------------------- 1 | content from _src/docs/asciidoc/subdir/c.adoc_. 2 | -------------------------------------------------------------------------------- /src/test/resources/samples/docs/simple/src/main/java/example/StringUtils.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | public class StringUtils { 4 | // tag::contains[] 5 | public boolean contains(String haystack, String needle) { 6 | return haystack.contains(needle); 7 | } 8 | // end::contains[] 9 | } 10 | -------------------------------------------------------------------------------- /src/test/resources/samples/integrationtest/withgroovy/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.integration-test' 3 | } 4 | 5 | apply plugin: 'java' 6 | apply plugin: 'groovy' 7 | 8 | repositories { 9 | mavenCentral() 10 | } 11 | 12 | dependencies { 13 | testCompile 'junit:junit:4.12' 14 | testCompile 'org.spockframework:spock-core:1.0-groovy-2.4' 15 | integrationTestCompile 'org.springframework:spring-core:4.3.7.RELEASE' 16 | } -------------------------------------------------------------------------------- /src/test/resources/samples/integrationtest/withgroovy/src/integration-test/groovy/sample/TheTest.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package sample; 17 | 18 | import org.springframework.core.Ordered; 19 | import spock.lang.Specification; 20 | 21 | class TheTest extends Specification { 22 | def "has Ordered"() { 23 | expect: 'Loads Ordered fine' 24 | Ordered ordered = new Ordered() { 25 | @Override 26 | int getOrder() { 27 | return 0 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /src/test/resources/samples/integrationtest/withjava/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.integration-test' 3 | } 4 | 5 | apply plugin: 'java' 6 | 7 | repositories { 8 | mavenCentral() 9 | } 10 | 11 | dependencies { 12 | testCompile 'junit:junit:4.12' 13 | integrationTestCompile 'org.springframework:spring-core:4.3.7.RELEASE' 14 | } -------------------------------------------------------------------------------- /src/test/resources/samples/integrationtest/withjava/src/integration-test/java/sample/TheTest.java: -------------------------------------------------------------------------------- 1 | package sample; 2 | 3 | import org.junit.Test; 4 | import org.springframework.core.Ordered; 5 | 6 | public class TheTest { 7 | @Test 8 | public void compilesAndRuns() { 9 | Ordered ordered = new Ordered() { 10 | @Override 11 | public int getOrder() { 12 | return 0; 13 | } 14 | }; 15 | } 16 | } -------------------------------------------------------------------------------- /src/test/resources/samples/integrationtest/withpropdeps/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.integration-test' 3 | } 4 | 5 | apply plugin: 'java' 6 | apply plugin: 'propdeps' 7 | 8 | repositories { 9 | mavenCentral() 10 | } 11 | 12 | dependencies { 13 | optional 'javax.servlet:javax.servlet-api:3.1.0' 14 | testCompile 'junit:junit:4.12' 15 | } -------------------------------------------------------------------------------- /src/test/resources/samples/integrationtest/withpropdeps/src/integration-test/java/sample/TheTest.java: -------------------------------------------------------------------------------- 1 | package sample; 2 | 3 | import org.junit.Test; 4 | import javax.servlet.http.HttpServletRequest; 5 | 6 | public class TheTest { 7 | @Test 8 | public void compilesAndRuns() { 9 | HttpServletRequest request = null; 10 | } 11 | } -------------------------------------------------------------------------------- /src/test/resources/samples/jacoco/java/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.jacoco' 3 | } 4 | 5 | apply plugin: 'java' 6 | 7 | repositories { 8 | mavenCentral() 9 | } 10 | 11 | dependencies { 12 | testCompile 'junit:junit:4.12' 13 | } -------------------------------------------------------------------------------- /src/test/resources/samples/jacoco/java/src/main/java/sample/TheClass.java: -------------------------------------------------------------------------------- 1 | package sample; 2 | 3 | public class TheClass { 4 | public boolean doStuff(boolean b) { 5 | if(b) { 6 | return true; 7 | } else { 8 | return false; 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /src/test/resources/samples/jacoco/java/src/test/java/sample/TheClassTest.java: -------------------------------------------------------------------------------- 1 | package sample; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import org.junit.Test; 6 | 7 | public class TheClassTest { 8 | TheClass theClass = new TheClass(); 9 | 10 | @Test 11 | public void doStuffWhenTrueThenTrue() { 12 | assertTrue(theClass.doStuff(true)); 13 | } 14 | 15 | @Test 16 | public void doStuffWhenTrueThenFalse() { 17 | assertFalse(theClass.doStuff(false)); 18 | } 19 | } -------------------------------------------------------------------------------- /src/test/resources/samples/javadocapi/multimodule/api/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'io.spring.convention.spring-module' -------------------------------------------------------------------------------- /src/test/resources/samples/javadocapi/multimodule/api/src/main/java/sample/Api.java: -------------------------------------------------------------------------------- 1 | package sample; 2 | 3 | /** 4 | * Testing this 5 | * @author Rob Winch 6 | * 7 | */ 8 | public class Api { 9 | 10 | /** 11 | * This does stuff 12 | */ 13 | public void doStuff() {} 14 | } 15 | -------------------------------------------------------------------------------- /src/test/resources/samples/javadocapi/multimodule/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.javadoc-api' 3 | id 'io.spring.convention.spring-module' apply false 4 | id 'io.spring.convention.spring-sample' apply false 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/samples/javadocapi/multimodule/impl/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'io.spring.convention.spring-module' -------------------------------------------------------------------------------- /src/test/resources/samples/javadocapi/multimodule/impl/src/main/java/sample/Impl.java: -------------------------------------------------------------------------------- 1 | package sample; 2 | 3 | /** 4 | * Testing this 5 | * @author Rob Winch 6 | * 7 | */ 8 | public class Impl { 9 | 10 | /** 11 | * This does stuff 12 | */ 13 | public void otherThings() {} 14 | } 15 | -------------------------------------------------------------------------------- /src/test/resources/samples/javadocapi/multimodule/sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'io.spring.convention.spring-sample' -------------------------------------------------------------------------------- /src/test/resources/samples/javadocapi/multimodule/sample/src/main/java/sample/Sample.java: -------------------------------------------------------------------------------- 1 | package sample; 2 | 3 | /** 4 | * Testing this 5 | * @author Rob Winch 6 | * 7 | */ 8 | public class Sample { 9 | 10 | /** 11 | * This does stuff 12 | */ 13 | public void doSample() {} 14 | } 15 | -------------------------------------------------------------------------------- /src/test/resources/samples/javadocapi/multimodule/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':api' 2 | include ':impl' 3 | include ':sample' -------------------------------------------------------------------------------- /src/test/resources/samples/maven/install-with-springio/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.spring-module' 3 | } 4 | 5 | repositories { 6 | mavenCentral() 7 | } 8 | 9 | dependencies { 10 | testCompile 'junit:junit:4.12' 11 | compile 'org.springframework:spring-core' 12 | } -------------------------------------------------------------------------------- /src/test/resources/samples/maven/install-with-springio/gradle/dependency-management.gradle: -------------------------------------------------------------------------------- 1 | dependencyManagement { 2 | dependencies { 3 | dependency 'org.springframework:spring-core:3.0.0.RELEASE' 4 | } 5 | } -------------------------------------------------------------------------------- /src/test/resources/samples/maven/install/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.root' 3 | } 4 | 5 | apply plugin: 'propdeps-maven' 6 | apply plugin: 'io.spring.convention.maven' 7 | 8 | repositories { 9 | mavenCentral() 10 | } 11 | 12 | dependencies { 13 | testCompile 'junit:junit:4.12' 14 | optional 'aopalliance:aopalliance:1.0' 15 | } -------------------------------------------------------------------------------- /src/test/resources/samples/maven/signing/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.root' 3 | } 4 | 5 | version = "1.0.0.RELEASE" 6 | 7 | apply plugin: 'propdeps-maven' 8 | apply plugin: 'io.spring.convention.maven' 9 | 10 | repositories { 11 | mavenCentral() 12 | } 13 | 14 | dependencies { 15 | testCompile 'junit:junit:4.12' 16 | optional 'aopalliance:aopalliance:1.0' 17 | } -------------------------------------------------------------------------------- /src/test/resources/samples/maven/signing/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'signing' -------------------------------------------------------------------------------- /src/test/resources/samples/maven/upload/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.root' 3 | } 4 | 5 | apply plugin: 'propdeps-maven' 6 | 7 | repositories { 8 | mavenCentral() 9 | } 10 | 11 | dependencies { 12 | testCompile 'junit:junit:4.12' 13 | optional 'aopalliance:aopalliance:1.0' 14 | } 15 | 16 | uploadArchives { 17 | repositories { 18 | mavenDeployer { 19 | repository(url: "file:$buildDir/repo") 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/Jenkinsfile: -------------------------------------------------------------------------------- 1 | parallel check: { 2 | stage('Check') { 3 | node { 4 | checkout scm 5 | sh "./gradlew check --refresh-dependencies --no-daemon" 6 | } 7 | } 8 | }, 9 | sonar: { 10 | stage('Sonar') { 11 | node { 12 | checkout scm 13 | withCredentials([string(credentialsId: 'spring-sonar.login', variable: 'SONAR_LOGIN')]) { 14 | sh "./gradlew sonarqube -Dsonar.host.url=$SPRING_SONAR_HOST_URL -Dsonar.login=$SONAR_LOGIN --refresh-dependencies --no-daemon" 15 | } 16 | } 17 | } 18 | }, 19 | ossrh: { 20 | stage('OSSRH Deploy') { 21 | node { 22 | checkout scm 23 | withCredentials([file(credentialsId: 'spring-signing-secring.gpg', variable: 'SIGNING_KEYRING_FILE')]) { 24 | withCredentials([string(credentialsId: 'spring-gpg-passphrase', variable: 'SIGNING_PASSWORD')]) { 25 | withCredentials([usernamePassword(credentialsId: 'oss-token', passwordVariable: 'OSSRH_PASSWORD', usernameVariable: 'OSSRH_USERNAME')]) { 26 | sh "./gradlew uploadArchives -Psigning.secretKeyRingFile=$SIGNING_KEYRING_FILE -Psigning.keyId=$SPRING_SIGNING_KEYID -Psigning.password=$SIGNING_PASSWORD -PossrhUsername=$OSSRH_USERNAME -PossrhPassword=$OSSRH_PASSWORD --refresh-dependencies --no-daemon" 27 | } 28 | } 29 | } 30 | } 31 | } 32 | }, 33 | docs: { 34 | stage('Deploy Docs') { 35 | node { 36 | checkout scm 37 | withCredentials([file(credentialsId: 'docs.spring.io-jenkins_private_ssh_key', variable: 'DEPLOY_SSH_KEY')]) { 38 | sh "./gradlew deployDocs -PdeployDocsSshKeyPath=$DEPLOY_SSH_KEY -PdeployDocsSshUsername=$SPRING_DOCS_USERNAME --refresh-dependencies --no-daemon --stacktrace" 39 | } 40 | } 41 | } 42 | }, 43 | schema: { 44 | stage('Deploy Schema') { 45 | node { 46 | checkout scm 47 | withCredentials([file(credentialsId: 'docs.spring.io-jenkins_private_ssh_key', variable: 'DEPLOY_SSH_KEY')]) { 48 | sh "./gradlew deploySchema -PdeployDocsSshKeyPath=$DEPLOY_SSH_KEY -PdeployDocsSshUsername=$SPRING_DOCS_USERNAME --refresh-dependencies --no-daemon --stacktrace" 49 | } 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/bom/bom.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'io.spring.convention.bom' 2 | 3 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.root' 3 | } 4 | 5 | group = "org.springframework.build.test" 6 | version = "1.0.0.BUILD-SNAPSHOT" 7 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/etc/checkstyle/checkstyle.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/gradle/dependency-management.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | management platform('io.spring.platform:platform-bom:Brussels-RELEASE') 3 | } -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/samples/sgbcs-sample-war/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'io.spring.convention.spring-sample-war' 2 | 3 | dependencies { 4 | provided 'javax.servlet:javax.servlet-api' 5 | testCompile 'commons-io:commons-io' 6 | testCompile 'junit:junit' 7 | } -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/samples/sgbcs-sample-war/src/integration-test/java/sample/HelloServletTest.java: -------------------------------------------------------------------------------- 1 | package sample; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import java.io.InputStream; 6 | import java.net.URL; 7 | import java.nio.charset.Charset; 8 | 9 | import org.apache.commons.io.IOUtils; 10 | import org.junit.Test; 11 | 12 | public class HelloServletTest { 13 | 14 | @Test 15 | public void hello() throws Exception { 16 | String url = System.getProperty("app.baseURI"); 17 | try(InputStream get = new URL(url).openConnection().getInputStream()) { 18 | String hello = IOUtils.toString(get, Charset.defaultCharset()); 19 | assertEquals("Hello", hello); 20 | } 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/samples/sgbcs-sample-war/src/main/java/sample/HelloServlet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2017 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package sample; 17 | 18 | import java.io.IOException; 19 | 20 | import javax.servlet.ServletException; 21 | import javax.servlet.annotation.WebServlet; 22 | import javax.servlet.http.HttpServlet; 23 | import javax.servlet.http.HttpServletRequest; 24 | import javax.servlet.http.HttpServletResponse; 25 | 26 | @WebServlet("/") 27 | public class HelloServlet extends HttpServlet { 28 | 29 | @Override 30 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 31 | resp.getWriter().write("Hello"); 32 | } 33 | 34 | private static final long serialVersionUID = -166535360229360350L; 35 | } 36 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'spring-gradle-build-conventions-sample' 2 | 3 | 4 | FileTree projects = fileTree(rootDir) { 5 | include '**/*.gradle' 6 | exclude '**/gradle', 'settings.gradle', 'buildSrc', '/build.gradle', '.*' 7 | } 8 | 9 | String rootDirPath = rootDir.absolutePath + File.separator 10 | projects.each { File buildFile -> 11 | String buildFilePath = buildFile.parentFile.absolutePath 12 | 13 | String projectPath = buildFilePath.replace(rootDirPath, '').replaceAll(File.separator, ':') 14 | 15 | include projectPath 16 | 17 | def project = findProject(":${projectPath}") 18 | if(!'build.gradle'.equals(buildFile.name)) { 19 | project.name = buildFile.name.replace('.gradle','') 20 | project.buildFileName = buildFile.name 21 | } 22 | project.projectDir = buildFile.parentFile 23 | } -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-api/sgbcs-api.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'io.spring.convention.spring-module' 2 | 3 | dependencies { 4 | compile 'org.springframework:spring-web' 5 | compile 'org.springframework:spring-core' 6 | testCompile 'junit:junit' 7 | } 8 | 9 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-api/src/main/java/api/Api.java: -------------------------------------------------------------------------------- 1 | package api; 2 | 3 | /** 4 | * 5 | * @author Rob Winch 6 | * 7 | */ 8 | public class Api { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-api/src/test/java/api/ApiTest.java: -------------------------------------------------------------------------------- 1 | package api; 2 | 3 | import org.junit.Test; 4 | 5 | public class ApiTest { 6 | 7 | @Test 8 | public void api() {} 9 | } 10 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-core/sgbcs-core.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'io.spring.convention.spring-module' 2 | 3 | dependencies { 4 | optional 'ch.qos.logback:logback-classic' 5 | testCompile 'junit:junit' 6 | } -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-core/src/main/java/core/CoreClass.java: -------------------------------------------------------------------------------- 1 | package core; 2 | 3 | /** 4 | * 5 | * @author Rob Winch 6 | * 7 | */ 8 | public class CoreClass { 9 | 10 | public void run() { 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-core/src/main/java/core/HasOptional.java: -------------------------------------------------------------------------------- 1 | package core; 2 | 3 | 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | 8 | public class HasOptional { 9 | 10 | public static void doStuffWithOptionalDependency() { 11 | Logger logger = LoggerFactory.getLogger(HasOptional.class); 12 | logger.debug("This is optional"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-core/src/main/resources/META-INF/spring.handlers: -------------------------------------------------------------------------------- 1 | http\://www.springframework.org/schema/springgradlebuildsample=org.springframework.ldap.config.LdapNamespaceHandler -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-core/src/main/resources/META-INF/spring.schemas: -------------------------------------------------------------------------------- 1 | http\://www.springframework.org/schema/springgradlebuildsample/spring-springgradlebuildsample.xsd=org/springframework/springgradlebuildsample/config/spring-springgradlebuildsample-2.2.xsd 2 | http\://www.springframework.org/schema/springgradlebuildsample/spring-springgradlebuildsample-2.0.xsd=org/springframework/springgradlebuildsample/config/spring-springgradlebuildsample-2.0.xsd 3 | http\://www.springframework.org/schema/springgradlebuildsample/spring-springgradlebuildsample-2.1.xsd=org/springframework/springgradlebuildsample/config/spring-springgradlebuildsample-2.1.xsd 4 | http\://www.springframework.org/schema/springgradlebuildsample/spring-springgradlebuildsample-2.2.xsd=org/springframework/springgradlebuildsample/config/spring-springgradlebuildsample-2.2.xsd -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-core/src/main/resources/org/springframework/springgradlebuildsample/config/spring-springgradlebuildsample-2.0.xsd: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | A bean identifier, used for referring to the bean elsewhere in the context. 16 | "contextSource". 17 | 18 | 19 | 20 | 21 | 22 | 23 | Defines whether read-only operations will be performed using an anonymous (unauthenticated) context. 24 | 25 | 26 | 27 | 28 | 29 | 30 | Id of the AuthenticationSource instance to use. If not specified, a SimpleAuthenticationSource will 31 | be used. 32 | 33 | 34 | 35 | 36 | 37 | 38 | Id of the DirContextAuthenticationStrategy instance to use. If not specified, a SimpleDirContextAuthenticationStrategy 39 | will be used. 40 | 41 | 42 | 43 | 44 | 45 | 46 | The base DN. If configured, all LDAP operations on contexts retrieved from this ContextSource will 47 | be relative to this DN. Default is an empty distinguished name (i.e. all operations will be 48 | relative to the directory root). 49 | 50 | 51 | 52 | 53 | 54 | 55 | The password to use for authentication. 56 | 57 | 58 | 59 | 60 | 61 | 62 | Specify whether native Java LDAP connection pooling should be used. Default is false. 63 | 64 | 65 | 66 | 67 | 68 | 69 | Defines the strategy to handle referrals, as described on https://docs.oracle.com/javase/jndi/tutorial/ldap/referral/jndi.html. 70 | Default is null. 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | URL of the LDAP server to use. If fail-over functionality is desired, more than one URL can 85 | be specified, separated using comma (,). 86 | 87 | 88 | 89 | 90 | 91 | 92 | The username (principal) to use for authentication. This will normally be the distinguished name 93 | of an admin user. 94 | 95 | 96 | 97 | 98 | 99 | 100 | Reference to a Map of custom environment properties that should supplied with the environment 101 | sent to the DirContext on construction. 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | The maximum number of active connections of each type (read-only|read-write) 112 | that can be allocated from the pool at the same time, or non-positive for no limit. 113 | Default is 8. 114 | 115 | 116 | 117 | 118 | 119 | 120 | The overall maximum number of active connections (for all types) that can be allocated from 121 | this pool at the same time, or non-positive for no limit. Default is -1 (no limit). 122 | 123 | 124 | 125 | 126 | 127 | 128 | The maximum number of active connections of each type (read-only|read-write) that can remain idle in the pool, 129 | without extra ones being released, or non-positive for no limit. Default is 8. 130 | 131 | 132 | 133 | 134 | 135 | 136 | The minimum number of active connections of each type (read-only|read-write) that can remain 137 | idle in the pool, without extra ones being created, or zero to create none. Default is 0. 138 | 139 | 140 | 141 | 142 | 143 | 144 | The maximum number of milliseconds that the pool will wait (when there are no available connections) 145 | for a connection to be returned before throwing an exception, or non-positive to wait indefinitely. 146 | Default is -1. 147 | 148 | 149 | 150 | 151 | 152 | 153 | Specifies the behaviour when the pool is exhausted. 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | Throw a NoSuchElementException when the pool is exhausted 162 | 163 | 164 | 165 | 166 | 167 | 168 | Wait until a new object is available. If max-wait is positive a NoSuchElementException 169 | is thrown if no new object is available after the maxWait time expires. 170 | 171 | 172 | 173 | 174 | 175 | 176 | Create and return a new object (essentially making maxActive meaningless). 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | The indication of whether objects will be validated before being borrowed from the pool. 187 | If the object fails to validate, it will be dropped from the pool, and an attempt to borrow another will be made. 188 | Default is false. 189 | 190 | 191 | 192 | 193 | 194 | 195 | The indication of whether objects will be validated before being returned to the pool. 196 | Default is false. 197 | 198 | 199 | 200 | 201 | 202 | 203 | The indication of whether objects will be validated by the idle object evictor (if any). 204 | If an object fails to validate, it will be dropped from the pool. 205 | Default is false. 206 | 207 | 208 | 209 | 210 | 211 | 212 | The number of milliseconds to sleep between runs of the idle object evictor thread. When non-positive, 213 | no idle object evictor thread will be run. Default is -1. 214 | 215 | 216 | 217 | 218 | 219 | 220 | The number of objects to examine during each run of the idle object evictor thread (if any). 221 | Default is 3. 222 | 223 | 224 | 225 | 226 | 227 | 228 | The minimum amount of time an object may sit idle in the pool before it is eligible 229 | for eviction by the idle object evictor (if any). Default is 1000 * 60 * 30. 230 | 231 | 232 | 233 | 234 | 235 | 236 | The base dn to use for validation searches. Default is LdapUtils.emptyPath(). 237 | 238 | 239 | 240 | 241 | 242 | 243 | The filter to use for validation queries. Default is (objectclass=*). 244 | 245 | 246 | 247 | 248 | 249 | 250 | Id of the SearchControls instance to use for searches. Default is searchScope=OBJECT_SCOPE; 251 | countLimit: 1; timeLimit: 500; returningAttributes: [objectclass]. 252 | 253 | 254 | 255 | 256 | 257 | 258 | Id of the SearchControls instance to use for searches. Default is searchScope=OBJECT_SCOPE; 259 | countLimit: 1; timeLimit: 500; returningAttributes: [objectclass]. 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | Creates a ContextSource instance to be used to get LdapContexts for communicating with an LDAP server. 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | Defines the settings to use for the Spring LDAP connection pooling support. 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | A bean identifier, used for referring to the bean elsewhere in the context. 293 | Default is "ldapTemplate". 294 | 295 | 296 | 297 | 298 | 299 | 300 | Id of the ContextSource instance to use. Default is "contextSource". 301 | 302 | 303 | 304 | 305 | 306 | 307 | The default count limit for searches. Default is 0 (no limit). 308 | 309 | 310 | 311 | 312 | 313 | 314 | The default time limit for searches. Default is 0 (no limit). 315 | 316 | 317 | 318 | 319 | 320 | 321 | The default search scope for searches. Default is SUBTREE. 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | Specifies whether NameNotFoundException should be ignored in searches. Setting this 336 | attribute to true will cause errors caused by invalid search base to be silently swallowed. 337 | Default is false. 338 | 339 | 340 | 341 | 342 | 343 | 344 | Specifies whether PartialResultException should be ignored in searches. Some LDAP servers 345 | have problems with referrals; these should normally be followed automatically, but if this 346 | doesn't work it will manifest itself with a PartialResultException. Setting this attribute 347 | to true presents a work-around to this problem. Default is false. 348 | 349 | 350 | 351 | 352 | 353 | 354 | Id of the ObjectDirectoryMapper instance to use. Default is a default-configured DefaultObjectDirectoryMapper. 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | Creates an LdapTemplate instance. 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | Id of this instance. Default is "transactionManager". 376 | 377 | 378 | 379 | 380 | 381 | 382 | Id of the ContextSource instance to use. "contextSource". 383 | 384 | 385 | 386 | 387 | 388 | 389 | Id of the DataSource instance to use. 390 | 391 | 392 | 393 | 394 | 395 | 396 | Id of the Hibernate SessionFactory instance to use. 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | Creates an ContextSourceTransactionManager. If data-source-ref or session-factory-ref is specified, 406 | a DataSourceAndContextSourceTransactionManager/HibernateAndContextSourceTransactionManager will be 407 | created. 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | The default (simplistic) TempEntryRenamingStrategy. Please note that this 416 | strategy will not work for more advanced scenarios. See reference documentation 417 | for details. 418 | 419 | 420 | 421 | 422 | 423 | 424 | The default suffix that will be added to modified entries. 425 | Default is "_temp". 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | TempEntryRenamingStrategy that moves the entry to a different subtree than 435 | the original entry. 436 | 437 | 438 | 439 | 440 | 441 | 442 | The subtree base where changed entries should be moved. 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | The reference to an LdapTemplate. Will default to 'ldapTemplate'. 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-core/src/test/java/core/CoreClassTest.java: -------------------------------------------------------------------------------- 1 | package core; 2 | 3 | import org.junit.Test; 4 | 5 | public class CoreClassTest { 6 | 7 | @Test 8 | public void test() { 9 | new CoreClass().run(); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-core/src/test/java/core/HasOptionalTest.java: -------------------------------------------------------------------------------- 1 | package core; 2 | 3 | import org.junit.Test; 4 | 5 | public class HasOptionalTest { 6 | 7 | @Test 8 | public void test() { 9 | HasOptional.doStuffWithOptionalDependency(); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-docs/sgbcs-docs.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'io.spring.convention.docs' 3 | 4 | version = "1.0.0.BUILD-SNAPSHOT" 5 | 6 | asciidoctorj { 7 | attributes \ 8 | 'build-gradle': project.buildFile, 9 | 'sourcedir': project.sourceSets.main.java.srcDirs[0], 10 | 'endpoint-url': 'https://example.org' 11 | } -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-docs/src/docs/asciidoc/docinfo.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-docs/src/docs/asciidoc/images/sunset.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spring-gradle-plugins/spring-build-conventions/1527cecd379b865b8b70a85acea3c8e25068fb77/src/test/resources/samples/showcase/sgbcs-docs/src/docs/asciidoc/images/sunset.jpg -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-docs/src/docs/asciidoc/index.adoc: -------------------------------------------------------------------------------- 1 | = Example Manual 2 | Doc Writer 3 | 2014-09-09 4 | :example-caption!: 5 | ifndef::imagesdir[:imagesdir: images] 6 | ifndef::sourcedir[:sourcedir: ../java] 7 | 8 | This is a user manual for an example project. 9 | 10 | == Introduction 11 | 12 | This project does something. 13 | We just haven't decided what that is yet. 14 | 15 | == Source Code 16 | 17 | [source,java] 18 | .Java code from project 19 | ---- 20 | include::{sourcedir}/example/StringUtils.java[tags=contains,indent=0] 21 | ---- 22 | 23 | This page was built by the following command: 24 | 25 | $ ./gradlew asciidoctor 26 | 27 | == Images 28 | 29 | [.thumb] 30 | image::sunset.jpg[scaledwidth=75%] 31 | 32 | == Attributes 33 | 34 | .Built-in 35 | asciidoctor-version:: {asciidoctor-version} 36 | safe-mode-name:: {safe-mode-name} 37 | docdir:: {docdir} 38 | docfile:: {docfile} 39 | imagesdir:: {imagesdir} 40 | revnumber:: {revnumber} 41 | 42 | .Custom 43 | sourcedir:: {sourcedir} 44 | endpoint-url:: {endpoint-url} 45 | 46 | == Includes 47 | 48 | .include::subdir/_b.adoc[] 49 | ==== 50 | include::subdir/_b.adoc[] 51 | ==== 52 | 53 | WARNING: Includes can be tricky! 54 | 55 | == build.gradle 56 | 57 | [source,groovy] 58 | ---- 59 | include::{build-gradle}[] 60 | ---- 61 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-docs/src/docs/asciidoc/subdir/_b.adoc: -------------------------------------------------------------------------------- 1 | content from _src/docs/asciidoc/subdir/_b.adoc_. 2 | 3 | .include::_c.adoc[] 4 | [example] 5 | -- 6 | include::_c.adoc[] 7 | -- 8 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-docs/src/docs/asciidoc/subdir/_c.adoc: -------------------------------------------------------------------------------- 1 | content from _src/docs/asciidoc/subdir/c.adoc_. 2 | -------------------------------------------------------------------------------- /src/test/resources/samples/showcase/sgbcs-docs/src/main/java/example/StringUtils.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | public class StringUtils { 4 | // tag::contains[] 5 | public boolean contains(String haystack, String needle) { 6 | return haystack.contains(needle); 7 | } 8 | // end::contains[] 9 | } 10 | -------------------------------------------------------------------------------- /src/test/resources/samples/testsconfiguration/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'io.spring.convention.tests-configuration' 3 | id 'java' 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/samples/testsconfiguration/core/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'io.spring.convention.tests-configuration' 2 | apply plugin: 'java' // second to test ordering 3 | -------------------------------------------------------------------------------- /src/test/resources/samples/testsconfiguration/core/src/test/java/sample/Dependency.java: -------------------------------------------------------------------------------- 1 | package sample; 2 | 3 | public class Dependency {} -------------------------------------------------------------------------------- /src/test/resources/samples/testsconfiguration/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':core' 2 | include ':web' -------------------------------------------------------------------------------- /src/test/resources/samples/testsconfiguration/web/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | 3 | repositories { 4 | mavenCentral() 5 | } 6 | 7 | dependencies { 8 | testCompile project(path: ':core', configuration: 'tests') 9 | testCompile 'junit:junit:4.12' 10 | } -------------------------------------------------------------------------------- /src/test/resources/samples/testsconfiguration/web/src/test/java/sample/DependencyTest.java: -------------------------------------------------------------------------------- 1 | package sample; 2 | 3 | import org.junit.*; 4 | 5 | public class DependencyTest { 6 | @Test 7 | public void findsDependencyOnClasspath() { 8 | new Dependency(); 9 | } 10 | } -------------------------------------------------------------------------------- /src/test/resources/test-private.pgp: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP PRIVATE KEY BLOCK----- 2 | 3 | lQWGBF7sxWEBDADekNzn2KDfbb8QGPTHZLzqvNgfYVGXIWLFfEWsA0wTPn3YQh78 4 | vhsK+nq598R5Rjt2s4lm/L8y5eQ4GWpok9wu5gna4s+nHbdwDjJKoXA/GVN8Y/oi 5 | g37CafIqWACdzGpN5fjvblsfrNjVmwLdgq2kYoYqduOtiFeeQDivRJdZp3417e3C 6 | xAdarksMkWOuDKD7JQU46ofxoMX5+WsvZ0DYuKybXAiVhNTpn3rl/4MIvu6XlMBS 7 | EdLCdQkrdiSs6dBt8iQWkSDmwl4qaFyOmtlwjtzpJ+mPYpTWWWN3ukBRCM/AJRqm 8 | IgLXnYnrvTmEmuZwfcZrLGwPDa30aaCK5Jjq4WLD1lwpFBuZMT46saLA+y8CvcSW 9 | 8vPAvQFzSrbBaEGu4ZIpU2aWBRW4JYpN+l90RFoWfdPyxrQ4rmPp4BIoEG25+zxI 10 | 8XMJNwr4T/t8C4I6YQfCKqnyeeR94ZF8JjGJh3Ts6nLHDN84IZbeJRypvYpcTPAD 11 | HZiWnk4QREuSyhEAEQEAAf4HAwLsRiB8Oo4Nef+LrgBEtQ86fdfs5mTbxPv+XNGb 12 | Wugl7HtIbgjhcmDw1zaWt9B7PKhSn2FQwJQduijE/Ae7OmNkFBQoeUeN0QADlarA 13 | Xb5dlANIbfEJk/9KR769YL9HTy6y25LxrfgH3mrV2848dA/ilgv/WGmAz0SGER1t 14 | OKvgOfGrmQECKbw7+U9EyEPl7nWRgJrkRK8/zgMnAA1TuXG3Rr3FvuUlw51MnBxx 15 | sYOj6A7Xk0ijvh1szMwcUwVtZWDAiRFVhMcgopf7jCKs1UlrWJ98sa7WNXje25Mo 16 | WXZ8VRA1/FbM/ifzuICOmKc7C+rNff7H3U7PBwRCGJrG6m0EJ/Cwrko5uHVq+fG5 17 | s2Vl7817ztM3/rkmNkC9jmE/sKHlkPlVc9hZGPTbqBC6BThpbBzNLUoTPmAgzbqU 18 | hgW2ES938D7ipt7IzhRxTitQN8a1JRk8v710g/D2skLhTx9T3SkJyJkXbmOVJJXc 19 | IN/mtlzRykR/c/TGOsMQR6v+nz42jZ1AY406AKMjd1R15wamscg4d457qVxn89T0 20 | wne+eShON8vPNpu1bAaN8soHxC5a4eVnLNVguxs+Abc0x/qwpwvd0VOMd86Aukte 21 | YsS+fzGSSpX9PqHVNThK9Z1dU13J7RONeO+2xZnThhiMyGvpqL5PQ3lE3P4zkccB 22 | jlQuuHW/6jD0/W1tlPPcsTcWDS4Ku7xxXg+ZSR3LfC4ukBWQLGiYNBWA2Zi1zW0A 23 | xXB9kdP9MJcxdBlsUa+xVrI71LcWaREGA/O5KGMmTXQaJJNvp/2bCauAIE8AJEN9 24 | MrGLe+SBu3n0PJxpCB3iqLXNe9nebf0I4E8uisKB6zcQMFMEWxI5R3oRweVKYIBo 25 | 8Le5tlJ9DSwvwTI0tyDMW7Y9KCrAcIpz7tx0cIn4RzMGzCtDaLpwDk973jUQcFeE 26 | OQBLCWPm2pIuoKO4RkIHaqhYXc9SYG3E+qQ481DohAoB/Gr3Vf80wQyIGAorg4wM 27 | OhYmFp5pl8XDDpa7Sth8w/0flA08IRA466IYaBAhuP0ug+rhMjNfLwy+anurUd9f 28 | M3UD21WqIUEscN5SkPI2OhGCXf5rbAQ+PkyrbgHXZpW29fGeUrAEP7FBWnCxylvL 29 | ijP/camoJLlOzr5CKi1TTkhitbfSMH1jQosw6JeiHtbnvCyrqNbPYw57gkpRH4FD 30 | Iql0TGAiHRe8l4s0xW79oiqN6vWKICCkekwcuc3NdNFsyxjtPdWI3ni0FulkHX0Y 31 | O+R0Ge+uwoPKiwCT6POzn1sPP6q8kbcvP0QmkNAx7b/JKRPEoe4u9oUNc5qS9gEC 32 | GxzvbXqq7Zv7UmYcTfNSjEWluIy0SYkVB7QkU3ByaW5nICh0ZXN0aW5nKSA8bm9y 33 | ZXBseUBzcHJpbmcuaW8+iQHOBBMBCgA4FiEEkkystQ8WdKVRsEMQjGaXsjMvWqAF 34 | Al7sxWECGwMFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AACgkQjGaXsjMvWqCNTAwA 35 | pg4/XCj0vqdeVNepw4p4mU/62yu2pKXh5usU2BcEvD8dEidUpGRJkyt5n1vWzvC6 36 | 8pbmn+Qa/6QKyL300RHeb3lpKQXbrtx3WWAMIO/JXh5lLtNaytw/N1IpqIVpg85G 37 | L27sjeGwInQ4MleLzKykxygIsqZYUE3KWCb75JmgtEQiyaivAmDxlFClaav35LQp 38 | aAyX2jrRPxPcD3qEL8JwDRpIlYwi1rcJgun9HIPAdma4AIarBBlEmEcXUus4rNAl 39 | 5vVgzB+v6dH3V+TiBL2QpepSoj4snA0iVyxGmLhhuuLf5gdb5sQgBY+BVxmqEji/ 40 | is9/Steis5d25JG5G2qaflv5H00aZBJeCsARKkhBMKqBILHAAkBdr611gGLcHusq 41 | T4GdhYx4BJK1mHjgY08pDV+My4xnwz1wcsS3iAl7efCu8X2lfe9ju+sV1EhXAtj0 42 | XAIaHz1k8bN4dPZDZG8Lk+2kH6WDLr7EOIsJCCsBp4HUFrxUUEdYaUsNDFxKxmmA 43 | nQWGBF7sxWEBDADRHc69S/XH4yDv7Msg7OWW2eEBKkFV7i6lMHCp+lNBqNtxx83Z 44 | ww8BRzqJZqvPRw219hwsVw7XN9YB1c8k5bw14mPx/VMK84oChPKRF58K9Ak8hyV5 45 | 3BSrd4N+DKPYut0l+WhHTfkPIguFGeHp8Kg/GphAlK2eieE8vzrwrUZdNqWCBbuF 46 | +JqU84g9XIMUtfPSIwbnaRh6DkU59cbEaHYl4ltr5+ZExhHypMKt4G0sJu3Vo1iq 47 | nA4NiB1rUwzsvB5NUvTErLDKHscdeKSfbf7VeMe/Oqaa5EHWQuDVWBMDhyqRt4bV 48 | kdHnHogjtNT8Ose2eYgqY+8rzJ1vs84DUuo6Osd/ATc0K6jodZpueYN1NQEP9l2s 49 | VsjJzT4rFb6RUglnEyp4LANrz4ogkx9Y9wnvti0Z3vtLQyAf/DmXBKXzos5lRLBw 50 | Ju+zqUUe6fww11LaftKdSI9yzhAP2ZnZFZ1FtVvuypLBrhZVsiYyRnDN6XhPxJgq 51 | 2A6yIoTNaq/xIA0AEQEAAf4HAwJBDiLQbcpQ8v9Dq9OdYRBZQxhMbhpVB45r8BeR 52 | obnNmZWHRrZcQ7xqaqqWLEb8dtqvAR6lo7c6uZNSpzW59s72HCCvNLm8W8J6iMIb 53 | oPD5Idbk1a0YXETUQOO5MP4NGzb/g6MInXhMM3TeC66YeZecXHiWwdDYk9nSiH7Q 54 | 207vKvDYCxNC1wIV8UqPI7ck0ekAczJB9PlpFDXD2W0JX/JB0hnBAIKKEsVshPEv 55 | FKlDXOrjx2fKV1kzrB9fSewfaKW5MrqWEEElikPwoo5o+mv57ClkhE6TmGqPSA+t 56 | 4kuTOlQwtVwlnLn0n0uyagRDs1eFUFuNXhFlAPAHbSMQeEVboYn7m9h7MYlVJwIT 57 | 4N/8w2cEnjAd/xX/O1maTxI/7MXTboCCE6j9NmLHWTX3MM/xhO248zhXbttwUkxf 58 | 2amL6QhsQiGtoyFKjhQtVTH8VVik05caEkWBOzKfldEVBrky8bacemW2EQp0uNAt 59 | 7IOwzv9uUuWOUd8yAyDb7rI4+JrYsUwFLFk49zFZrYwrn30WvaWTEkRRgL+xGfjC 60 | W4ZLa8OmOO8O6C2sbTZyyCN0noG2IUGdIsIEhVFPIoqyqGlZ8IxF6EovZniz4sf8 61 | Lu0Fo8YN+5LMiS9hCXs2Guv0jaSQ3vJtxU00/hT1zCc7/x9P1G6ks79r4aKJYCwS 62 | c/nAnT87YrXfQS3Zqa50HkbGqey7TwzwyrexC+eXgYvNhvXElG78hpPDhs/cyMcT 63 | ApQNy3jQcXbdXeVL9AfEl6DmDR/XWtWOpz9Cpxz321IT8t6j8ZOdan1F5rgVfNbv 64 | z7lx6AmI5GVZlTA2DBQGjmSHcfHbvo9EPcodALdSvAqwsSmuF72bJBYnkdyiO/6A 65 | /ElYpcHv3X0NRyC93hkipnyUkoBkyWEeDJb69w9tUCleqA4Rd6TuicEIep010lMT 66 | tbzy8wHAciN716PzfJPsnZBB2Mv9sXCzpbbZjT8TNmz6/O0d/a+LNaSCiTvjwqNd 67 | ERvWTgp6f6kcBQZFDSzZIMN9SHNaQAHAFOFVBA0IQfelcSz/bFz21Z9f0ZQ8b3ML 68 | FUMhx59D5Fcrvqn+5D6m8bAXw9gElRmUzi8BKyQay7JkHsQauS66yUrj2EEp94ch 69 | 8WdbE/zTNxbUWkIJxYg36EIYgrH8zf7/M00+tXk6HMZRy0wLbbJqQEh5tDV9Ht8z 70 | +Eu3x6/VKGIFjhtIhVY7ZDCM9wFZjsbq/kQDT8PB9X9wt5o/quDo8wg8Zm0qnJkD 71 | msPMXLh2ZVvKXiFM7WkhUYTOpxApOt+/jMGSqP2peCBqVIwQTdtQQ+wJZjx5sBmz 72 | 2eXKwEu+pmsRAsM3dtPuqXpJWUzrrcuI+okBtgQYAQoAIBYhBJJMrLUPFnSlUbBD 73 | EIxml7IzL1qgBQJe7MVhAhsMAAoJEIxml7IzL1qg9YsMAJXUf1+CJd5mVkOZ551+ 74 | INV3eIf+r5wXO7KoiK8CBUEnAqSNMrQ7QHTXwo9pSjuWR1O5JcRJumvZg/dj4Vox 75 | tb/l26Y5gdyYVkzwjKA6OnuHmICB3Y6xZVNrq1FUMiDThytHbuJz7mZZugJ69lMV 76 | ITA0iKJV+nFNP7slthTSpfP0XkQ74hnteWf+HadXU11MHFEw2Doi2xANMxzoQgy9 77 | 8uY6tp1/07Ll/Te5Y6YB1dlXrHiuJcX7/nUvmNa13y1cq28W2fqVsNVmZPZB7/SK 78 | DNyv6OT0iSIOBH/6AwoTzWo+Rcwr9PDKnII2fxizc3Jq75zjA+7F/Ol8fyaVrIbn 79 | 8oxh88rujnORKevIextgcrAlu+Q8dnspZ9oACqoKQM/W+mVb5ISr9Xf+qnicXWem 80 | uGi6ofVHUZzzJsVRdrASSA6B2+Aup+PP+SuxFSok02/DkxkD2zgT8Xt/T+/usBsy 81 | c9LeCkYBwNlcZZc7jWAJZ6Tt514F4wmJgKFgiuZ6MqBrRQ== 82 | =1LV7 83 | -----END PGP PRIVATE KEY BLOCK----- --------------------------------------------------------------------------------
27 | * testCompile project(path: ':foo', configuration: 'tests') 28 | *