Port the build to Gradle
Closes gh-19609 Closes gh-19608
This commit is contained in:
@@ -1,71 +1,112 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath("io.spring.javaformat:spring-javaformat-gradle-plugin:0.0.15")
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'eclipse'
|
||||
id 'java-gradle-plugin'
|
||||
id 'maven-publish'
|
||||
id 'org.asciidoctor.jvm.convert'
|
||||
id 'org.asciidoctor.jvm.pdf'
|
||||
id 'org.springframework.boot.conventions'
|
||||
id 'org.springframework.boot.maven-repository'
|
||||
id 'org.springframework.boot.optional-dependencies'
|
||||
}
|
||||
|
||||
apply plugin: 'io.spring.javaformat'
|
||||
description = 'Spring Boot Gradle Plugin'
|
||||
|
||||
configurations {
|
||||
asciidoctorExtensions
|
||||
documentation
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
maven {
|
||||
url 'https://repo.spring.io/release'
|
||||
mavenContent {
|
||||
includeGroup 'io.spring.asciidoctor'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation localGroovy()
|
||||
implementation gradleApi()
|
||||
implementation fileTree(dir: 'target/dependencies/compile', include: '*.jar')
|
||||
testImplementation gradleTestKit()
|
||||
testImplementation 'org.apache.commons:commons-compress:1.13'
|
||||
testImplementation fileTree(dir: 'target/dependencies/test', include: '*.jar')
|
||||
asciidoctorExtensions 'io.spring.asciidoctor:spring-asciidoctor-extensions-block-switch:0.3.0.RELEASE'
|
||||
implementation enforcedPlatform(project(':spring-boot-project:spring-boot-dependencies'))
|
||||
implementation project(':spring-boot-project:spring-boot-tools:spring-boot-loader-tools')
|
||||
implementation 'io.spring.gradle:dependency-management-plugin'
|
||||
implementation 'org.apache.commons:commons-compress'
|
||||
implementation 'org.springframework:spring-core'
|
||||
|
||||
optional enforcedPlatform(project(':spring-boot-project:spring-boot-dependencies'))
|
||||
optional 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50'
|
||||
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.mockito:mockito-core'
|
||||
}
|
||||
|
||||
gradlePlugin {
|
||||
plugins {
|
||||
springBootPlugin {
|
||||
id = 'org.springframework.boot'
|
||||
implementationClass = 'org.springframework.boot.gradle.plugin.SpringBootPlugin'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
jar {
|
||||
manifest {
|
||||
attributes 'Implementation-Version': (version ? version : 'unknown')
|
||||
attributes 'Implementation-Version': project.version
|
||||
}
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
testLogging {
|
||||
events "passed", "skipped", "failed"
|
||||
task dependencyVersions(type: org.springframework.boot.build.constraints.ExtractVersionConstraints) {
|
||||
enforcedPlatform(':spring-boot-project:spring-boot-dependencies')
|
||||
}
|
||||
|
||||
tasks.withType(org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask) {
|
||||
dependsOn dependencyVersions
|
||||
doFirst {
|
||||
attributes 'dependency-management-plugin-version': dependencyVersions.versionConstraints['io.spring.gradle:dependency-management-plugin']
|
||||
}
|
||||
}
|
||||
|
||||
asciidoctor {
|
||||
configurations 'asciidoctorExtensions'
|
||||
sources {
|
||||
include 'index.adoc'
|
||||
}
|
||||
attributes 'stylesheet': 'css/style.css'
|
||||
}
|
||||
|
||||
asciidoctorPdf {
|
||||
sources {
|
||||
include 'index.adoc'
|
||||
}
|
||||
}
|
||||
|
||||
javadoc {
|
||||
options {
|
||||
author()
|
||||
stylesheetFile = file('src/main/javadoc/spring-javadoc.css')
|
||||
links = [
|
||||
'https://docs.oracle.com/javase/8/docs/api/',
|
||||
'https://docs.gradle.org/current/javadoc/'
|
||||
]
|
||||
source = '8'
|
||||
author = true
|
||||
docTitle = "Spring Boot Gradle Plugin ${project.version} API"
|
||||
encoding = 'UTF-8'
|
||||
memberLevel = 'protected'
|
||||
outputLevel = 'quiet'
|
||||
splitIndex = true
|
||||
use = true
|
||||
windowTitle = "Spring Boot Gradle Plugin ${project.version} API"
|
||||
}
|
||||
title = "${project.description} $version API"
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar) {
|
||||
classifier = 'sources'
|
||||
from sourceSets.main.allSource
|
||||
}
|
||||
|
||||
task javadocJar(type: Jar) {
|
||||
classifier = "javadoc"
|
||||
from javadoc
|
||||
task zip(type: Zip) {
|
||||
dependsOn asciidoctor, asciidoctorPdf
|
||||
duplicatesStrategy 'fail'
|
||||
from(asciidoctorPdf.outputDir) {
|
||||
into 'reference/pdf'
|
||||
}
|
||||
from(asciidoctor.outputDir) {
|
||||
into 'reference/html'
|
||||
}
|
||||
from(javadoc) {
|
||||
into 'api'
|
||||
}
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives sourcesJar
|
||||
archives javadocJar
|
||||
'documentation' zip
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
org.gradle.daemon=false
|
||||
Binary file not shown.
@@ -1,5 +0,0 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -1,172 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
fi
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
@@ -1,84 +0,0 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -1,399 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-tools</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<artifactId>spring-boot-gradle-plugin</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>Spring Boot Gradle Plugin</name>
|
||||
<description>Spring Boot Gradle Plugin</description>
|
||||
<properties>
|
||||
<main.basedir>${basedir}/../../..</main.basedir>
|
||||
<gradle.executable>./gradlew</gradle.executable>
|
||||
<gradle.task>build</gradle.task>
|
||||
<refdocs.build.directory>${project.build.directory}/refdocs/</refdocs.build.directory>
|
||||
</properties>
|
||||
<scm>
|
||||
<url>${git.url}</url>
|
||||
<connection>${git.connection}</connection>
|
||||
<developerConnection>${git.developerConnection}</developerConnection>
|
||||
</scm>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-loader-tools</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.spring.gradle</groupId>
|
||||
<artifactId>dependency-management-plugin</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-compress</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-gradle-plugin</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>com.googlecode.maven-download-plugin</groupId>
|
||||
<artifactId>download-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>unpack-doc-resources</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>wget</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<url>${spring-doc-resources.url}</url>
|
||||
<unpack>true</unpack>
|
||||
<outputDirectory>${refdocs.build.directory}/asciidoc</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-compile-dependencies</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<inherited>false</inherited>
|
||||
<configuration>
|
||||
<includeScope>compile</includeScope>
|
||||
<outputDirectory>${project.build.directory}/dependencies/compile</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>copy-test-dependencies</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<inherited>false</inherited>
|
||||
<configuration>
|
||||
<includeScope>test</includeScope>
|
||||
<outputDirectory>${project.build.directory}/dependencies/test</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-asciidoc-resources</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${refdocs.build.directory}/asciidoc</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/asciidoc</directory>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>copy-gradle-resources</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${refdocs.build.directory}/gradle</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/gradle</directory>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>gradle</id>
|
||||
<phase>prepare-package</phase>
|
||||
<configuration>
|
||||
<executable>${gradle.executable}</executable>
|
||||
<arguments>
|
||||
<argument>clean</argument>
|
||||
<argument>${gradle.task}</argument>
|
||||
<argument>-Pversion=${project.version}</argument>
|
||||
<argument>-Pdescription=${project.description}</argument>
|
||||
<argument>-S</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-artifacts</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>attach-artifact</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifacts>
|
||||
<artifact>
|
||||
<file>build/libs/${project.artifactId}-${project.version}.jar</file>
|
||||
<type>jar</type>
|
||||
</artifact>
|
||||
<artifact>
|
||||
<file>build/libs/${project.artifactId}-${project.version}-javadoc.jar</file>
|
||||
<type>jar</type>
|
||||
<classifier>javadoc</classifier>
|
||||
</artifact>
|
||||
<artifact>
|
||||
<file>build/libs/${project.artifactId}-${project.version}-sources.jar</file>
|
||||
<type>jar</type>
|
||||
<classifier>sources</classifier>
|
||||
</artifact>
|
||||
</artifacts>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>windows</id>
|
||||
<activation>
|
||||
<os>
|
||||
<family>windows</family>
|
||||
</os>
|
||||
</activation>
|
||||
<properties>
|
||||
<gradle.executable>gradlew.bat</gradle.executable>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>skipTests</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>skipTests</name>
|
||||
<value>true</value>
|
||||
</property>
|
||||
</activation>
|
||||
<properties>
|
||||
<gradle.task>assemble</gradle.task>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>full</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>full</name>
|
||||
</property>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ant-contrib</groupId>
|
||||
<artifactId>ant-contrib</artifactId>
|
||||
<version>1.0b3</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>ant</groupId>
|
||||
<artifactId>ant</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.ant</groupId>
|
||||
<artifactId>ant-nodeps</artifactId>
|
||||
<version>1.8.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.tigris.antelope</groupId>
|
||||
<artifactId>antelopetasks</artifactId>
|
||||
<version>3.2.10</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>set-up-maven-properties</id>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<exportAntProperties>true</exportAntProperties>
|
||||
<target>
|
||||
<taskdef resource="net/sf/antcontrib/antcontrib.properties" />
|
||||
<taskdef name="stringutil" classname="ise.antelope.tasks.StringUtilTask" />
|
||||
<var name="version-type" value="${project.version}" />
|
||||
<propertyregex property="version-type" override="true"
|
||||
input="${version-type}" regexp=".*\.(.*)" replace="\1" />
|
||||
<propertyregex property="version-type" override="true"
|
||||
input="${version-type}" regexp="(M)\d+" replace="MILESTONE" />
|
||||
<propertyregex property="version-type" override="true"
|
||||
input="${version-type}" regexp="(RC)\d+" replace="MILESTONE" />
|
||||
<propertyregex property="version-type" override="true"
|
||||
input="${version-type}" regexp="BUILD-(.*)" replace="SNAPSHOT" />
|
||||
<var name="github-tag" value="v${project.version}" />
|
||||
<propertyregex property="github-tag" override="true"
|
||||
input="${github-tag}" regexp=".*SNAPSHOT" replace="master" />
|
||||
</target>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>package-docs-zip</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<target>
|
||||
<zip
|
||||
destfile="${project.build.directory}/${project.artifactId}-${project.version}-docs.zip">
|
||||
<zipfileset
|
||||
src="build/libs/${project.artifactId}-${project.version}-javadoc.jar"
|
||||
prefix="api" />
|
||||
<zipfileset dir="${project.build.directory}/generated-docs/reference/html"
|
||||
prefix="reference/html" />
|
||||
<mappedresources>
|
||||
<fileset dir="${project.build.directory}/generated-docs/reference/pdf"
|
||||
includes="index.pdf" />
|
||||
<globmapper from="index.pdf"
|
||||
to="reference/pdf/spring-boot-gradle-plugin-reference.pdf" />
|
||||
</mappedresources>
|
||||
</zip>
|
||||
</target>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.asciidoctor</groupId>
|
||||
<artifactId>asciidoctor-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>generate-html-documentation</id>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>process-asciidoc</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<backend>html5</backend>
|
||||
<outputDirectory>${project.build.directory}/generated-docs/reference/html</outputDirectory>
|
||||
<sourceHighlighter>highlight.js</sourceHighlighter>
|
||||
<doctype>book</doctype>
|
||||
<attributes>
|
||||
<highlightjsdir>js/highlight</highlightjsdir>
|
||||
<highlightjs-theme>github</highlightjs-theme>
|
||||
<linkcss>true</linkcss>
|
||||
<imagesdir>./images</imagesdir>
|
||||
<icons>font</icons>
|
||||
<stylesdir>css/</stylesdir>
|
||||
<stylesheet>style.css</stylesheet>
|
||||
<attribute-missing>warn</attribute-missing>
|
||||
</attributes>
|
||||
<logHandler>
|
||||
<outputToConsole>true</outputToConsole>
|
||||
<failIf>
|
||||
<severity>DEBUG</severity>
|
||||
</failIf>
|
||||
</logHandler>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>generate-pdf-documentation</id>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>process-asciidoc</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<backend>pdf</backend>
|
||||
<outputDirectory>${project.build.directory}/generated-docs/reference/pdf</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<sourceDirectory>${refdocs.build.directory}/asciidoc</sourceDirectory>
|
||||
<sourceDocumentName>index.adoc</sourceDocumentName>
|
||||
<attributes>
|
||||
<github-tag>${github-tag}</github-tag>
|
||||
<version-type>${version-type}</version-type>
|
||||
<version>${project.version}</version>
|
||||
<dependency-management-plugin-version>${dependency-management-plugin.version}</dependency-management-plugin-version>
|
||||
</attributes>
|
||||
</configuration>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.spring.asciidoctor</groupId>
|
||||
<artifactId>spring-asciidoctor-extensions-block-switch</artifactId>
|
||||
<version>${spring-asciidoctor-extensions.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-zip</id>
|
||||
<goals>
|
||||
<goal>attach-artifact</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifacts>
|
||||
<artifact>
|
||||
<file>${project.build.directory}/${project.artifactId}-${project.version}-docs.zip</file>
|
||||
<type>zip</type>
|
||||
<classifier>docs</classifier>
|
||||
</artifact>
|
||||
</artifacts>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>java13</id>
|
||||
<activation>
|
||||
<jdk>13</jdk>
|
||||
</activation>
|
||||
<properties>
|
||||
<gradle.task>assemble</gradle.task>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
@@ -22,7 +22,7 @@ Andy Wilkinson
|
||||
:maven-publish-plugin: {gradle-userguide}/maven_publish_plugin.html
|
||||
:software-component: {gradle-userguide}/software_model_extend.html
|
||||
:kotlin-plugin: https://kotlinlang.org/docs/reference/using-gradle.html
|
||||
:spring-boot-docs: https://docs.spring.io/spring-boot/docs/{version}
|
||||
:spring-boot-docs: https://docs.spring.io/spring-boot/docs/{gradle-project-version}
|
||||
:api-documentation: {spring-boot-docs}/gradle-plugin/api
|
||||
:spring-boot-reference: {spring-boot-docs}/reference/htmlsingle
|
||||
:build-info-javadoc: {api-documentation}/org/springframework/boot/gradle/tasks/buildinfo/BuildInfo.html
|
||||
@@ -1 +0,0 @@
|
||||
implementation-class=org.springframework.boot.gradle.plugin.SpringBootPlugin
|
||||
@@ -38,7 +38,7 @@ class GettingStartedDocumentationTests {
|
||||
|
||||
@TestTemplate
|
||||
void typicalPluginsAppliesExceptedPlugins() {
|
||||
this.gradleBuild.script("src/main/gradle/getting-started/typical-plugins").build("verify");
|
||||
this.gradleBuild.script("src/docs/gradle/getting-started/typical-plugins").build("verify");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,14 +42,14 @@ class IntegratingWithActuatorDocumentationTests {
|
||||
|
||||
@TestTemplate
|
||||
void basicBuildInfo() throws IOException {
|
||||
this.gradleBuild.script("src/main/gradle/integrating-with-actuator/build-info-basic").build("bootBuildInfo");
|
||||
this.gradleBuild.script("src/docs/gradle/integrating-with-actuator/build-info-basic").build("bootBuildInfo");
|
||||
assertThat(new File(this.gradleBuild.getProjectDir(), "build/resources/main/META-INF/build-info.properties"))
|
||||
.isFile();
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void buildInfoCustomValues() throws IOException {
|
||||
this.gradleBuild.script("src/main/gradle/integrating-with-actuator/build-info-custom-values")
|
||||
this.gradleBuild.script("src/docs/gradle/integrating-with-actuator/build-info-custom-values")
|
||||
.build("bootBuildInfo");
|
||||
File file = new File(this.gradleBuild.getProjectDir(), "build/resources/main/META-INF/build-info.properties");
|
||||
assertThat(file).isFile();
|
||||
@@ -62,7 +62,7 @@ class IntegratingWithActuatorDocumentationTests {
|
||||
|
||||
@TestTemplate
|
||||
void buildInfoAdditional() throws IOException {
|
||||
this.gradleBuild.script("src/main/gradle/integrating-with-actuator/build-info-additional")
|
||||
this.gradleBuild.script("src/docs/gradle/integrating-with-actuator/build-info-additional")
|
||||
.build("bootBuildInfo");
|
||||
File file = new File(this.gradleBuild.getProjectDir(), "build/resources/main/META-INF/build-info.properties");
|
||||
assertThat(file).isFile();
|
||||
|
||||
@@ -39,18 +39,18 @@ class ManagingDependenciesDocumentationTests {
|
||||
|
||||
@TestTemplate
|
||||
void dependenciesExampleEvaluatesSuccessfully() {
|
||||
this.gradleBuild.script("src/main/gradle/managing-dependencies/dependencies").build();
|
||||
this.gradleBuild.script("src/docs/gradle/managing-dependencies/dependencies").build();
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void customManagedVersions() {
|
||||
assertThat(this.gradleBuild.script("src/main/gradle/managing-dependencies/custom-version").build("slf4jVersion")
|
||||
assertThat(this.gradleBuild.script("src/docs/gradle/managing-dependencies/custom-version").build("slf4jVersion")
|
||||
.getOutput()).contains("1.7.20");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void dependencyManagementInIsolation() {
|
||||
assertThat(this.gradleBuild.script("src/main/gradle/managing-dependencies/configure-bom")
|
||||
assertThat(this.gradleBuild.script("src/docs/gradle/managing-dependencies/configure-bom")
|
||||
.build("dependencyManagement").getOutput()).contains("org.springframework.boot:spring-boot-starter ");
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ class ManagingDependenciesDocumentationTests {
|
||||
void dependencyManagementInIsolationWithPluginsBlock() {
|
||||
assumingThat(this.gradleBuild.getDsl() == Dsl.KOTLIN,
|
||||
() -> assertThat(
|
||||
this.gradleBuild.script("src/main/gradle/managing-dependencies/configure-bom-with-plugins")
|
||||
this.gradleBuild.script("src/docs/gradle/managing-dependencies/configure-bom-with-plugins")
|
||||
.build("dependencyManagement").getOutput())
|
||||
.contains("org.springframework.boot:spring-boot-starter TEST-SNAPSHOT"));
|
||||
}
|
||||
|
||||
@@ -49,12 +49,12 @@ class PackagingDocumentationTests {
|
||||
|
||||
@TestTemplate
|
||||
void warContainerDependencyEvaluatesSuccessfully() {
|
||||
this.gradleBuild.script("src/main/gradle/packaging/war-container-dependency").build();
|
||||
this.gradleBuild.script("src/docs/gradle/packaging/war-container-dependency").build();
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void bootJarMainClass() throws IOException {
|
||||
this.gradleBuild.script("src/main/gradle/packaging/boot-jar-main-class").build("bootJar");
|
||||
this.gradleBuild.script("src/docs/gradle/packaging/boot-jar-main-class").build("bootJar");
|
||||
File file = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/libs/" + this.gradleBuild.getProjectDir().getName() + ".jar");
|
||||
assertThat(file).isFile();
|
||||
@@ -66,7 +66,7 @@ class PackagingDocumentationTests {
|
||||
|
||||
@TestTemplate
|
||||
void bootJarManifestMainClass() throws IOException {
|
||||
this.gradleBuild.script("src/main/gradle/packaging/boot-jar-manifest-main-class").build("bootJar");
|
||||
this.gradleBuild.script("src/docs/gradle/packaging/boot-jar-manifest-main-class").build("bootJar");
|
||||
File file = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/libs/" + this.gradleBuild.getProjectDir().getName() + ".jar");
|
||||
assertThat(file).isFile();
|
||||
@@ -78,7 +78,7 @@ class PackagingDocumentationTests {
|
||||
|
||||
@TestTemplate
|
||||
void applicationPluginMainClass() throws IOException {
|
||||
this.gradleBuild.script("src/main/gradle/packaging/application-plugin-main-class").build("bootJar");
|
||||
this.gradleBuild.script("src/docs/gradle/packaging/application-plugin-main-class").build("bootJar");
|
||||
File file = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/libs/" + this.gradleBuild.getProjectDir().getName() + ".jar");
|
||||
assertThat(file).isFile();
|
||||
@@ -90,7 +90,7 @@ class PackagingDocumentationTests {
|
||||
|
||||
@TestTemplate
|
||||
void springBootDslMainClass() throws IOException {
|
||||
this.gradleBuild.script("src/main/gradle/packaging/spring-boot-dsl-main-class").build("bootJar");
|
||||
this.gradleBuild.script("src/docs/gradle/packaging/spring-boot-dsl-main-class").build("bootJar");
|
||||
File file = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/libs/" + this.gradleBuild.getProjectDir().getName() + ".jar");
|
||||
assertThat(file).isFile();
|
||||
@@ -103,7 +103,7 @@ class PackagingDocumentationTests {
|
||||
@TestTemplate
|
||||
void bootWarIncludeDevtools() throws IOException {
|
||||
jarFile(new File(this.gradleBuild.getProjectDir(), "spring-boot-devtools-1.2.3.RELEASE.jar"));
|
||||
this.gradleBuild.script("src/main/gradle/packaging/boot-war-include-devtools").build("bootWar");
|
||||
this.gradleBuild.script("src/docs/gradle/packaging/boot-war-include-devtools").build("bootWar");
|
||||
File file = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/libs/" + this.gradleBuild.getProjectDir().getName() + ".war");
|
||||
assertThat(file).isFile();
|
||||
@@ -114,7 +114,7 @@ class PackagingDocumentationTests {
|
||||
|
||||
@TestTemplate
|
||||
void bootJarRequiresUnpack() throws IOException {
|
||||
this.gradleBuild.script("src/main/gradle/packaging/boot-jar-requires-unpack").build("bootJar");
|
||||
this.gradleBuild.script("src/docs/gradle/packaging/boot-jar-requires-unpack").build("bootJar");
|
||||
File file = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/libs/" + this.gradleBuild.getProjectDir().getName() + ".jar");
|
||||
assertThat(file).isFile();
|
||||
@@ -127,7 +127,7 @@ class PackagingDocumentationTests {
|
||||
|
||||
@TestTemplate
|
||||
void bootJarIncludeLaunchScript() throws IOException {
|
||||
this.gradleBuild.script("src/main/gradle/packaging/boot-jar-include-launch-script").build("bootJar");
|
||||
this.gradleBuild.script("src/docs/gradle/packaging/boot-jar-include-launch-script").build("bootJar");
|
||||
File file = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/libs/" + this.gradleBuild.getProjectDir().getName() + ".jar");
|
||||
assertThat(file).isFile();
|
||||
@@ -136,7 +136,7 @@ class PackagingDocumentationTests {
|
||||
|
||||
@TestTemplate
|
||||
void bootJarLaunchScriptProperties() throws IOException {
|
||||
this.gradleBuild.script("src/main/gradle/packaging/boot-jar-launch-script-properties").build("bootJar");
|
||||
this.gradleBuild.script("src/docs/gradle/packaging/boot-jar-launch-script-properties").build("bootJar");
|
||||
File file = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/libs/" + this.gradleBuild.getProjectDir().getName() + ".jar");
|
||||
assertThat(file).isFile();
|
||||
@@ -148,7 +148,7 @@ class PackagingDocumentationTests {
|
||||
File customScriptFile = new File(this.gradleBuild.getProjectDir(), "src/custom.script");
|
||||
customScriptFile.getParentFile().mkdirs();
|
||||
FileCopyUtils.copy("custom", new FileWriter(customScriptFile));
|
||||
this.gradleBuild.script("src/main/gradle/packaging/boot-jar-custom-launch-script").build("bootJar");
|
||||
this.gradleBuild.script("src/docs/gradle/packaging/boot-jar-custom-launch-script").build("bootJar");
|
||||
File file = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/libs/" + this.gradleBuild.getProjectDir().getName() + ".jar");
|
||||
assertThat(file).isFile();
|
||||
@@ -157,7 +157,7 @@ class PackagingDocumentationTests {
|
||||
|
||||
@TestTemplate
|
||||
void bootWarPropertiesLauncher() throws IOException {
|
||||
this.gradleBuild.script("src/main/gradle/packaging/boot-war-properties-launcher").build("bootWar");
|
||||
this.gradleBuild.script("src/docs/gradle/packaging/boot-war-properties-launcher").build("bootWar");
|
||||
File file = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/libs/" + this.gradleBuild.getProjectDir().getName() + ".war");
|
||||
assertThat(file).isFile();
|
||||
@@ -169,7 +169,7 @@ class PackagingDocumentationTests {
|
||||
|
||||
@TestTemplate
|
||||
void bootJarAndJar() {
|
||||
this.gradleBuild.script("src/main/gradle/packaging/boot-jar-and-jar").build("assemble");
|
||||
this.gradleBuild.script("src/docs/gradle/packaging/boot-jar-and-jar").build("assemble");
|
||||
File jar = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/libs/" + this.gradleBuild.getProjectDir().getName() + ".jar");
|
||||
assertThat(jar).isFile();
|
||||
|
||||
@@ -39,13 +39,13 @@ class PublishingDocumentationTests {
|
||||
|
||||
@TestTemplate
|
||||
void mavenUpload() throws IOException {
|
||||
assertThat(this.gradleBuild.script("src/main/gradle/publishing/maven").build("deployerRepository").getOutput())
|
||||
assertThat(this.gradleBuild.script("src/docs/gradle/publishing/maven").build("deployerRepository").getOutput())
|
||||
.contains("https://repo.example.com");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void mavenPublish() throws IOException {
|
||||
assertThat(this.gradleBuild.script("src/main/gradle/publishing/maven-publish").build("publishingConfiguration")
|
||||
assertThat(this.gradleBuild.script("src/docs/gradle/publishing/maven-publish").build("publishingConfiguration")
|
||||
.getOutput()).contains("MavenPublication").contains("https://repo.example.com");
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.jupiter.api.TestTemplate;
|
||||
import org.junit.jupiter.api.condition.DisabledOnJre;
|
||||
import org.junit.jupiter.api.condition.JRE;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import org.springframework.boot.gradle.junit.GradleMultiDslExtension;
|
||||
@@ -39,32 +41,35 @@ class RunningDocumentationTests {
|
||||
GradleBuild gradleBuild;
|
||||
|
||||
@TestTemplate
|
||||
@DisabledOnJre(JRE.JAVA_13)
|
||||
void bootRunMain() throws IOException {
|
||||
assertThat(this.gradleBuild.script("src/main/gradle/running/boot-run-main").build("configuredMainClass")
|
||||
.getOutput()).contains("com.example.ExampleApplication");
|
||||
// TODO Testing of convention mappings is flakey in 5.2+
|
||||
// https://github.com/gradle/gradle/issues/11323
|
||||
assertThat(this.gradleBuild.gradleVersion("5.1.1").script("src/docs/gradle/running/boot-run-main")
|
||||
.build("configuredMainClass").getOutput()).contains("com.example.ExampleApplication");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void applicationPluginMainClassName() {
|
||||
assertThat(this.gradleBuild.script("src/main/gradle/running/application-plugin-main-class-name")
|
||||
assertThat(this.gradleBuild.script("src/docs/gradle/running/application-plugin-main-class-name")
|
||||
.build("configuredMainClass").getOutput()).contains("com.example.ExampleApplication");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void springBootDslMainClassName() throws IOException {
|
||||
assertThat(this.gradleBuild.script("src/main/gradle/running/spring-boot-dsl-main-class-name")
|
||||
assertThat(this.gradleBuild.script("src/docs/gradle/running/spring-boot-dsl-main-class-name")
|
||||
.build("configuredMainClass").getOutput()).contains("com.example.ExampleApplication");
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void bootRunSourceResources() throws IOException {
|
||||
assertThat(this.gradleBuild.script("src/main/gradle/running/boot-run-source-resources")
|
||||
assertThat(this.gradleBuild.script("src/docs/gradle/running/boot-run-source-resources")
|
||||
.build("configuredClasspath").getOutput()).contains(new File("src/main/resources").getPath());
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void bootRunDisableOptimizedLaunch() throws IOException {
|
||||
assertThat(this.gradleBuild.script("src/main/gradle/running/boot-run-disable-optimized-launch")
|
||||
assertThat(this.gradleBuild.script("src/docs/gradle/running/boot-run-disable-optimized-launch")
|
||||
.build("optimizedLaunch").getOutput()).contains("false");
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,11 @@
|
||||
package org.springframework.boot.gradle.junit;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.gradle.api.JavaVersion;
|
||||
import org.junit.jupiter.api.TestTemplate;
|
||||
import org.junit.jupiter.api.extension.Extension;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
@@ -38,8 +40,17 @@ import org.springframework.boot.gradle.testkit.GradleBuildExtension;
|
||||
*/
|
||||
public final class GradleCompatibilityExtension implements TestTemplateInvocationContextProvider {
|
||||
|
||||
private static final List<String> GRADLE_VERSIONS = Arrays.asList("default", "5.0", "5.1.1", "5.2.1", "5.3.1",
|
||||
"5.4.1", "5.5.1", "5.6.4", "6.0.1");
|
||||
private static final List<String> GRADLE_VERSIONS;
|
||||
|
||||
static {
|
||||
if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_13)) {
|
||||
GRADLE_VERSIONS = Collections.singletonList("default");
|
||||
}
|
||||
else {
|
||||
GRADLE_VERSIONS = Arrays.asList("4.10.3", "5.0", "5.1.1", "5.2.1", "5.3.1", "5.4.1", "5.5.1", "5.6.4",
|
||||
"default");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(ExtensionContext context) {
|
||||
|
||||
@@ -99,8 +99,7 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
void basicArchiveCreation() throws IOException {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
executeTask();
|
||||
assertThat(this.task.getArchivePath()).exists();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchiveFile().get().getAsFile())) {
|
||||
assertThat(jarFile.getManifest().getMainAttributes().getValue("Main-Class")).isEqualTo(this.launcherClass);
|
||||
assertThat(jarFile.getManifest().getMainAttributes().getValue("Start-Class")).isEqualTo("com.example.Main");
|
||||
assertThat(jarFile.getManifest().getMainAttributes().getValue("Spring-Boot-Classes"))
|
||||
@@ -115,7 +114,7 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
this.task.classpath(jarFile("one.jar"), jarFile("two.jar"));
|
||||
executeTask();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchiveFile().get().getAsFile())) {
|
||||
assertThat(jarFile.getEntry(this.libPath + "one.jar")).isNotNull();
|
||||
assertThat(jarFile.getEntry(this.libPath + "two.jar")).isNotNull();
|
||||
}
|
||||
@@ -130,7 +129,7 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
applicationClass.createNewFile();
|
||||
this.task.classpath(classpathFolder);
|
||||
executeTask();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchiveFile().get().getAsFile())) {
|
||||
assertThat(jarFile.getEntry(this.classesPath + "com/example/Application.class")).isNotNull();
|
||||
}
|
||||
}
|
||||
@@ -146,8 +145,8 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
applicationClass.getParentFile().mkdirs();
|
||||
applicationClass.createNewFile();
|
||||
this.task.classpath(classpathFolder);
|
||||
this.task.execute();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
|
||||
executeTask();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchiveFile().get().getAsFile())) {
|
||||
assertThat(jarFile.getEntry(this.classesPath + "com/example/Application.class")).isNotNull();
|
||||
assertThat(jarFile.getEntry("com/example/Application.class")).isNull();
|
||||
assertThat(jarFile.getEntry("module-info.class")).isNotNull();
|
||||
@@ -161,7 +160,7 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
this.task.classpath(jarFile("one.jar"));
|
||||
this.task.setClasspath(this.task.getProject().files(jarFile("two.jar")));
|
||||
executeTask();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchiveFile().get().getAsFile())) {
|
||||
assertThat(jarFile.getEntry(this.libPath + "one.jar")).isNull();
|
||||
assertThat(jarFile.getEntry(this.libPath + "two.jar")).isNotNull();
|
||||
}
|
||||
@@ -173,7 +172,7 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
this.task.classpath(jarFile("one.jar"));
|
||||
this.task.setClasspath(jarFile("two.jar"));
|
||||
executeTask();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchiveFile().get().getAsFile())) {
|
||||
assertThat(jarFile.getEntry(this.libPath + "one.jar")).isNull();
|
||||
assertThat(jarFile.getEntry(this.libPath + "two.jar")).isNotNull();
|
||||
}
|
||||
@@ -183,8 +182,8 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
void filesOnTheClasspathThatAreNotZipFilesAreSkipped() throws IOException {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
this.task.classpath(new File("test.pom"));
|
||||
this.task.execute();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
|
||||
executeTask();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchiveFile().get().getAsFile())) {
|
||||
assertThat(jarFile.getEntry(this.libPath + "/test.pom")).isNull();
|
||||
}
|
||||
}
|
||||
@@ -193,12 +192,13 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
void loaderIsWrittenToTheRootOfTheJarAfterManifest() throws IOException {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
executeTask();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchiveFile().get().getAsFile())) {
|
||||
assertThat(jarFile.getEntry("org/springframework/boot/loader/LaunchedURLClassLoader.class")).isNotNull();
|
||||
assertThat(jarFile.getEntry("org/springframework/boot/loader/")).isNotNull();
|
||||
}
|
||||
// gh-16698
|
||||
try (ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream(this.task.getArchivePath()))) {
|
||||
try (ZipInputStream zipInputStream = new ZipInputStream(
|
||||
new FileInputStream(this.task.getArchiveFile().get().getAsFile()))) {
|
||||
assertThat(zipInputStream.getNextEntry().getName()).isEqualTo("META-INF/");
|
||||
assertThat(zipInputStream.getNextEntry().getName()).isEqualTo("META-INF/MANIFEST.MF");
|
||||
}
|
||||
@@ -209,7 +209,7 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
executeTask();
|
||||
this.task.getManifest().getAttributes().put("Main-Class", "org.springframework.boot.loader.PropertiesLauncher");
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchiveFile().get().getAsFile())) {
|
||||
assertThat(jarFile.getEntry("org/springframework/boot/loader/LaunchedURLClassLoader.class")).isNotNull();
|
||||
assertThat(jarFile.getEntry("org/springframework/boot/loader/")).isNotNull();
|
||||
}
|
||||
@@ -221,7 +221,7 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
this.task.classpath(jarFile("one.jar"), jarFile("two.jar"));
|
||||
this.task.requiresUnpack("**/one.jar");
|
||||
executeTask();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchiveFile().get().getAsFile())) {
|
||||
assertThat(jarFile.getEntry(this.libPath + "one.jar").getComment()).startsWith("UNPACK:");
|
||||
assertThat(jarFile.getEntry(this.libPath + "two.jar").getComment()).isNull();
|
||||
}
|
||||
@@ -233,7 +233,7 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
this.task.classpath(jarFile("one.jar"), jarFile("two.jar"));
|
||||
this.task.requiresUnpack((element) -> element.getName().endsWith("two.jar"));
|
||||
executeTask();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchiveFile().get().getAsFile())) {
|
||||
assertThat(jarFile.getEntry(this.libPath + "two.jar").getComment()).startsWith("UNPACK:");
|
||||
assertThat(jarFile.getEntry(this.libPath + "one.jar").getComment()).isNull();
|
||||
}
|
||||
@@ -245,13 +245,14 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
this.task.launchScript();
|
||||
executeTask();
|
||||
Map<String, String> properties = new HashMap<>();
|
||||
properties.put("initInfoProvides", this.task.getBaseName());
|
||||
properties.put("initInfoProvides", this.task.getArchiveBaseName().get());
|
||||
properties.put("initInfoShortDescription", this.project.getDescription());
|
||||
properties.put("initInfoDescription", this.project.getDescription());
|
||||
assertThat(Files.readAllBytes(this.task.getArchivePath().toPath()))
|
||||
assertThat(Files.readAllBytes(this.task.getArchiveFile().get().getAsFile().toPath()))
|
||||
.startsWith(new DefaultLaunchScript(null, properties).toByteArray());
|
||||
try {
|
||||
Set<PosixFilePermission> permissions = Files.getPosixFilePermissions(this.task.getArchivePath().toPath());
|
||||
Set<PosixFilePermission> permissions = Files
|
||||
.getPosixFilePermissions(this.task.getArchiveFile().get().getAsFile().toPath());
|
||||
assertThat(permissions).contains(PosixFilePermission.OWNER_EXECUTE);
|
||||
}
|
||||
catch (UnsupportedOperationException ex) {
|
||||
@@ -266,7 +267,8 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
Files.write(customScript.toPath(), Arrays.asList("custom script"), StandardOpenOption.CREATE);
|
||||
this.task.launchScript((configuration) -> configuration.setScript(customScript));
|
||||
executeTask();
|
||||
assertThat(Files.readAllBytes(this.task.getArchivePath().toPath())).startsWith("custom script".getBytes());
|
||||
assertThat(Files.readAllBytes(this.task.getArchiveFile().get().getAsFile().toPath()))
|
||||
.startsWith("custom script".getBytes());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -278,7 +280,7 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
configuration.getProperties().put("initInfoDescription", "description");
|
||||
});
|
||||
executeTask();
|
||||
byte[] bytes = Files.readAllBytes(this.task.getArchivePath().toPath());
|
||||
byte[] bytes = Files.readAllBytes(this.task.getArchiveFile().get().getAsFile().toPath());
|
||||
assertThat(bytes).containsSequence("Provides: provides".getBytes());
|
||||
assertThat(bytes).containsSequence("Short-Description: short description".getBytes());
|
||||
assertThat(bytes).containsSequence("Description: description".getBytes());
|
||||
@@ -289,8 +291,8 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
this.task.getManifest().getAttributes().put("Main-Class", "com.example.CustomLauncher");
|
||||
executeTask();
|
||||
assertThat(this.task.getArchivePath()).exists();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
|
||||
assertThat(this.task.getArchiveFile().get().getAsFile()).exists();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchiveFile().get().getAsFile())) {
|
||||
assertThat(jarFile.getManifest().getMainAttributes().getValue("Main-Class"))
|
||||
.isEqualTo("com.example.CustomLauncher");
|
||||
assertThat(jarFile.getManifest().getMainAttributes().getValue("Start-Class")).isEqualTo("com.example.Main");
|
||||
@@ -303,8 +305,8 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
this.task.getManifest().getAttributes().put("Start-Class", "com.example.CustomMain");
|
||||
executeTask();
|
||||
assertThat(this.task.getArchivePath()).exists();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
|
||||
assertThat(this.task.getArchiveFile().get().getAsFile()).exists();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchiveFile().get().getAsFile())) {
|
||||
assertThat(jarFile.getManifest().getMainAttributes().getValue("Main-Class")).isEqualTo(this.launcherClass);
|
||||
assertThat(jarFile.getManifest().getMainAttributes().getValue("Start-Class"))
|
||||
.isEqualTo("com.example.CustomMain");
|
||||
@@ -316,8 +318,8 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
this.task.setPreserveFileTimestamps(false);
|
||||
executeTask();
|
||||
assertThat(this.task.getArchivePath()).exists();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
|
||||
assertThat(this.task.getArchiveFile().get().getAsFile()).exists();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchiveFile().get().getAsFile())) {
|
||||
Enumeration<JarEntry> entries = jarFile.entries();
|
||||
while (entries.hasMoreElements()) {
|
||||
JarEntry entry = entries.nextElement();
|
||||
@@ -332,9 +334,9 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
this.task.from(newFile("bravo.txt"), newFile("alpha.txt"), newFile("charlie.txt"));
|
||||
this.task.setReproducibleFileOrder(true);
|
||||
executeTask();
|
||||
assertThat(this.task.getArchivePath()).exists();
|
||||
assertThat(this.task.getArchiveFile().get().getAsFile()).exists();
|
||||
List<String> textFiles = new ArrayList<>();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchiveFile().get().getAsFile())) {
|
||||
Enumeration<JarEntry> entries = jarFile.entries();
|
||||
while (entries.hasMoreElements()) {
|
||||
JarEntry entry = entries.nextElement();
|
||||
@@ -351,8 +353,8 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
this.task.setMainClassName("com.example.Main");
|
||||
this.task.classpath(newFile("spring-boot-devtools-0.1.2.jar"));
|
||||
executeTask();
|
||||
assertThat(this.task.getArchivePath()).exists();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
|
||||
assertThat(this.task.getArchiveFile().get().getAsFile()).exists();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchiveFile().get().getAsFile())) {
|
||||
assertThat(jarFile.getEntry(this.libPath + "spring-boot-devtools-0.1.2.jar")).isNull();
|
||||
}
|
||||
}
|
||||
@@ -363,8 +365,8 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
this.task.classpath(jarFile("spring-boot-devtools-0.1.2.jar"));
|
||||
this.task.setExcludeDevtools(false);
|
||||
executeTask();
|
||||
assertThat(this.task.getArchivePath()).exists();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchivePath())) {
|
||||
assertThat(this.task.getArchiveFile().get().getAsFile()).exists();
|
||||
try (JarFile jarFile = new JarFile(this.task.getArchiveFile().get().getAsFile())) {
|
||||
assertThat(jarFile.getEntry(this.libPath + "spring-boot-devtools-0.1.2.jar")).isNotNull();
|
||||
}
|
||||
}
|
||||
@@ -379,7 +381,7 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
resource.createNewFile();
|
||||
this.task.classpath(classpathFolder);
|
||||
executeTask();
|
||||
File archivePath = this.task.getArchivePath();
|
||||
File archivePath = this.task.getArchiveFile().get().getAsFile();
|
||||
try (ZipFile zip = new ZipFile(archivePath)) {
|
||||
Enumeration<ZipArchiveEntry> entries = zip.getEntries();
|
||||
while (entries.hasMoreElements()) {
|
||||
@@ -401,9 +403,10 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
jarFile("third-library.jar"));
|
||||
this.task.requiresUnpack("second-library.jar");
|
||||
executeTask();
|
||||
assertThat(getEntryNames(this.task.getArchivePath())).containsSubsequence("org/springframework/boot/loader/",
|
||||
this.classesPath + "com/example/Application.class", this.libPath + "first-library.jar",
|
||||
this.libPath + "second-library.jar", this.libPath + "third-library.jar");
|
||||
assertThat(getEntryNames(this.task.getArchiveFile().get().getAsFile())).containsSubsequence(
|
||||
"org/springframework/boot/loader/", this.classesPath + "com/example/Application.class",
|
||||
this.libPath + "first-library.jar", this.libPath + "second-library.jar",
|
||||
this.libPath + "third-library.jar");
|
||||
}
|
||||
|
||||
protected File jarFile(String name) throws IOException {
|
||||
@@ -418,10 +421,10 @@ abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
|
||||
|
||||
private T configure(T task) throws IOException {
|
||||
AbstractArchiveTask archiveTask = task;
|
||||
archiveTask.setBaseName("test");
|
||||
archiveTask.getArchiveBaseName().set("test");
|
||||
File destination = new File(this.temp, "destination");
|
||||
destination.mkdirs();
|
||||
archiveTask.setDestinationDir(destination);
|
||||
archiveTask.getDestinationDirectory().set(destination);
|
||||
return task;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ class BootJarTests extends AbstractBootArchiveTests<BootJar> {
|
||||
bootJar.setMainClassName("com.example.Application");
|
||||
bootJar.getBootInf().into("test").from(new File("build.gradle").getAbsolutePath());
|
||||
bootJar.copy();
|
||||
try (JarFile jarFile = new JarFile(bootJar.getArchivePath())) {
|
||||
try (JarFile jarFile = new JarFile(bootJar.getArchiveFile().get().getAsFile())) {
|
||||
assertThat(jarFile.getJarEntry("BOOT-INF/test/build.gradle")).isNotNull();
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ class BootJarTests extends AbstractBootArchiveTests<BootJar> {
|
||||
bootJar.setMainClassName("com.example.Application");
|
||||
bootJar.bootInf((copySpec) -> copySpec.into("test").from(new File("build.gradle").getAbsolutePath()));
|
||||
bootJar.copy();
|
||||
try (JarFile jarFile = new JarFile(bootJar.getArchivePath())) {
|
||||
try (JarFile jarFile = new JarFile(bootJar.getArchiveFile().get().getAsFile())) {
|
||||
assertThat(jarFile.getJarEntry("BOOT-INF/test/build.gradle")).isNotNull();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ class BootWarTests extends AbstractBootArchiveTests<BootWar> {
|
||||
getTask().setMainClassName("com.example.Main");
|
||||
getTask().providedClasspath(jarFile("one.jar"), jarFile("two.jar"));
|
||||
executeTask();
|
||||
try (JarFile jarFile = new JarFile(getTask().getArchivePath())) {
|
||||
try (JarFile jarFile = new JarFile(getTask().getArchiveFile().get().getAsFile())) {
|
||||
assertThat(jarFile.getEntry("WEB-INF/lib-provided/one.jar")).isNotNull();
|
||||
assertThat(jarFile.getEntry("WEB-INF/lib-provided/two.jar")).isNotNull();
|
||||
}
|
||||
@@ -52,7 +52,7 @@ class BootWarTests extends AbstractBootArchiveTests<BootWar> {
|
||||
getTask().providedClasspath(jarFile("one.jar"));
|
||||
getTask().setProvidedClasspath(getTask().getProject().files(jarFile("two.jar")));
|
||||
executeTask();
|
||||
try (JarFile jarFile = new JarFile(getTask().getArchivePath())) {
|
||||
try (JarFile jarFile = new JarFile(getTask().getArchiveFile().get().getAsFile())) {
|
||||
assertThat(jarFile.getEntry("WEB-INF/lib-provided/one.jar")).isNull();
|
||||
assertThat(jarFile.getEntry("WEB-INF/lib-provided/two.jar")).isNotNull();
|
||||
}
|
||||
@@ -64,7 +64,7 @@ class BootWarTests extends AbstractBootArchiveTests<BootWar> {
|
||||
getTask().providedClasspath(jarFile("one.jar"));
|
||||
getTask().setProvidedClasspath(jarFile("two.jar"));
|
||||
executeTask();
|
||||
try (JarFile jarFile = new JarFile(getTask().getArchivePath())) {
|
||||
try (JarFile jarFile = new JarFile(getTask().getArchiveFile().get().getAsFile())) {
|
||||
assertThat(jarFile.getEntry("WEB-INF/lib-provided/one.jar")).isNull();
|
||||
assertThat(jarFile.getEntry("WEB-INF/lib-provided/two.jar")).isNotNull();
|
||||
}
|
||||
@@ -75,8 +75,7 @@ class BootWarTests extends AbstractBootArchiveTests<BootWar> {
|
||||
getTask().setMainClassName("com.example.Main");
|
||||
getTask().providedClasspath(newFile("spring-boot-devtools-0.1.2.jar"));
|
||||
executeTask();
|
||||
assertThat(getTask().getArchivePath()).exists();
|
||||
try (JarFile jarFile = new JarFile(getTask().getArchivePath())) {
|
||||
try (JarFile jarFile = new JarFile(getTask().getArchiveFile().get().getAsFile())) {
|
||||
assertThat(jarFile.getEntry("WEB-INF/lib-provided/spring-boot-devtools-0.1.2.jar")).isNull();
|
||||
}
|
||||
}
|
||||
@@ -87,8 +86,7 @@ class BootWarTests extends AbstractBootArchiveTests<BootWar> {
|
||||
getTask().providedClasspath(jarFile("spring-boot-devtools-0.1.2.jar"));
|
||||
getTask().setExcludeDevtools(false);
|
||||
executeTask();
|
||||
assertThat(getTask().getArchivePath()).exists();
|
||||
try (JarFile jarFile = new JarFile(getTask().getArchivePath())) {
|
||||
try (JarFile jarFile = new JarFile(getTask().getArchiveFile().get().getAsFile())) {
|
||||
assertThat(jarFile.getEntry("WEB-INF/lib-provided/spring-boot-devtools-0.1.2.jar")).isNotNull();
|
||||
}
|
||||
}
|
||||
@@ -103,8 +101,7 @@ class BootWarTests extends AbstractBootArchiveTests<BootWar> {
|
||||
getTask().from(webappFolder);
|
||||
getTask().setMainClassName("com.example.Main");
|
||||
executeTask();
|
||||
assertThat(getTask().getArchivePath()).exists();
|
||||
try (JarFile jarFile = new JarFile(getTask().getArchivePath())) {
|
||||
try (JarFile jarFile = new JarFile(getTask().getArchiveFile().get().getAsFile())) {
|
||||
assertThat(jarFile.getEntry("org/")).isNotNull();
|
||||
assertThat(jarFile.getEntry("org/foo.txt")).isNotNull();
|
||||
}
|
||||
@@ -116,8 +113,8 @@ class BootWarTests extends AbstractBootArchiveTests<BootWar> {
|
||||
getTask().classpath(jarFile("library.jar"));
|
||||
getTask().providedClasspath(jarFile("provided-library.jar"));
|
||||
executeTask();
|
||||
assertThat(getEntryNames(getTask().getArchivePath())).containsSubsequence("WEB-INF/lib/library.jar",
|
||||
"WEB-INF/lib-provided/provided-library.jar");
|
||||
assertThat(getEntryNames(getTask().getArchiveFile().get().getAsFile()))
|
||||
.containsSubsequence("WEB-INF/lib/library.jar", "WEB-INF/lib-provided/provided-library.jar");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.boot.gradle.tasks.bundling;
|
||||
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.provider.Property;
|
||||
import org.gradle.api.tasks.bundling.AbstractArchiveTask;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -43,7 +44,8 @@ class LaunchScriptConfigurationTests {
|
||||
|
||||
@Test
|
||||
void initInfoProvidesUsesArchiveBaseNameByDefault() {
|
||||
given(this.task.getBaseName()).willReturn("base-name");
|
||||
Property<String> baseName = stringProperty("base-name");
|
||||
given(this.task.getArchiveBaseName()).willReturn(baseName);
|
||||
assertThat(new LaunchScriptConfiguration(this.task).getProperties()).containsEntry("initInfoProvides",
|
||||
"base-name");
|
||||
}
|
||||
@@ -57,7 +59,8 @@ class LaunchScriptConfigurationTests {
|
||||
|
||||
@Test
|
||||
void initInfoShortDescriptionUsesArchiveBaseNameWhenDescriptionIsNull() {
|
||||
given(this.task.getBaseName()).willReturn("base-name");
|
||||
Property<String> baseName = stringProperty("base-name");
|
||||
given(this.task.getArchiveBaseName()).willReturn(baseName);
|
||||
assertThat(new LaunchScriptConfiguration(this.task).getProperties()).containsEntry("initInfoShortDescription",
|
||||
"base-name");
|
||||
}
|
||||
@@ -71,7 +74,8 @@ class LaunchScriptConfigurationTests {
|
||||
|
||||
@Test
|
||||
void initInfoDescriptionUsesArchiveBaseNameWhenDescriptionIsNull() {
|
||||
given(this.task.getBaseName()).willReturn("base-name");
|
||||
Property<String> baseName = stringProperty("base-name");
|
||||
given(this.task.getArchiveBaseName()).willReturn(baseName);
|
||||
assertThat(new LaunchScriptConfiguration(this.task).getProperties()).containsEntry("initInfoDescription",
|
||||
"base-name");
|
||||
}
|
||||
@@ -90,4 +94,11 @@ class LaunchScriptConfigurationTests {
|
||||
"The\n# project\n# description");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Property<String> stringProperty(String value) {
|
||||
Property<String> property = mock(Property.class);
|
||||
given(property.get()).willReturn(value);
|
||||
return property;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.boot.gradle.tasks.run;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.gradle.api.JavaVersion;
|
||||
import org.gradle.testkit.runner.BuildResult;
|
||||
import org.gradle.testkit.runner.TaskOutcome;
|
||||
import org.junit.jupiter.api.TestTemplate;
|
||||
@@ -88,7 +89,12 @@ class BootRunIntegrationTests {
|
||||
copyJvmArgsApplication();
|
||||
BuildResult result = this.gradleBuild.build("bootRun");
|
||||
assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("1. -Xverify:none").contains("2. -XX:TieredStopAtLevel=1");
|
||||
if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_13)) {
|
||||
assertThat(result.getOutput()).contains("1. -XX:TieredStopAtLevel=1");
|
||||
}
|
||||
else {
|
||||
assertThat(result.getOutput()).contains("1. -Xverify:none").contains("2. -XX:TieredStopAtLevel=1");
|
||||
}
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
@@ -104,8 +110,14 @@ class BootRunIntegrationTests {
|
||||
copyJvmArgsApplication();
|
||||
BuildResult result = this.gradleBuild.build("bootRun");
|
||||
assertThat(result.task(":bootRun").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
assertThat(result.getOutput()).contains("1. -Dcom.bar=baz").contains("2. -Dcom.foo=bar")
|
||||
.contains("3. -Xverify:none").contains("4. -XX:TieredStopAtLevel=1");
|
||||
if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_13)) {
|
||||
assertThat(result.getOutput()).contains("1. -Dcom.bar=baz").contains("2. -Dcom.foo=bar")
|
||||
.contains("3. -XX:TieredStopAtLevel=1");
|
||||
}
|
||||
else {
|
||||
assertThat(result.getOutput()).contains("1. -Dcom.bar=baz").contains("2. -Dcom.foo=bar")
|
||||
.contains("3. -Xverify:none").contains("4. -XX:TieredStopAtLevel=1");
|
||||
}
|
||||
}
|
||||
|
||||
private void copyClasspathApplication() throws IOException {
|
||||
|
||||
Reference in New Issue
Block a user