diff --git a/dd-smoke-tests/apm-tracing-disabled/application/build.gradle b/dd-smoke-tests/apm-tracing-disabled/application/build.gradle new file mode 100644 index 00000000000..3f5c868f46a --- /dev/null +++ b/dd-smoke-tests/apm-tracing-disabled/application/build.gradle @@ -0,0 +1,38 @@ +plugins { + id 'java' + id 'org.springframework.boot' version '2.7.15' + id 'io.spring.dependency-management' version '1.0.15.RELEASE' +} + +def sharedRootDir = "$rootDir/../../../" +def sharedConfigDirectory = "$sharedRootDir/gradle" +rootProject.ext.sharedConfigDirectory = sharedConfigDirectory + +apply from: "$sharedConfigDirectory/repositories.gradle" + +if (hasProperty('appBuildDir')) { + buildDir = property('appBuildDir') +} + +version = "" + +java { + sourceCompatibility = '1.8' +} + +if (hasProperty('apiJar')) { + dependencies { + implementation files(property('apiJar')) + } +} else { + dependencies { + implementation "com.datadoghq:dd-trace-api:+" + } +} + +dependencies { + compileOnly 'com.github.spotbugs:spotbugs-annotations:4.9.8' + implementation 'org.springframework.boot:spring-boot-starter-web' + implementation group: 'io.opentracing', name: 'opentracing-api', version: '0.32.0' + implementation group: 'io.opentracing', name: 'opentracing-util', version: '0.32.0' +} diff --git a/dd-smoke-tests/apm-tracing-disabled/application/gradle/wrapper/gradle-wrapper.jar b/dd-smoke-tests/apm-tracing-disabled/application/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000000..e708b1c023e Binary files /dev/null and b/dd-smoke-tests/apm-tracing-disabled/application/gradle/wrapper/gradle-wrapper.jar differ diff --git a/dd-smoke-tests/apm-tracing-disabled/application/gradle/wrapper/gradle-wrapper.properties b/dd-smoke-tests/apm-tracing-disabled/application/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000000..a4cf193f638 --- /dev/null +++ b/dd-smoke-tests/apm-tracing-disabled/application/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,8 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionSha256Sum=6f74b601422d6d6fc4e1f9a1ab6522f642c2fdcbc15ae33ebd30ba3d7198e854 +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.5-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/dd-smoke-tests/apm-tracing-disabled/application/gradlew b/dd-smoke-tests/apm-tracing-disabled/application/gradlew new file mode 100755 index 00000000000..965aff38453 --- /dev/null +++ b/dd-smoke-tests/apm-tracing-disabled/application/gradlew @@ -0,0 +1,183 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## 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='"-Xmx64m" "-Xms64m"' + +# 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 or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; 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=`expr $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" + +exec "$JAVACMD" "$@" diff --git a/dd-smoke-tests/apm-tracing-disabled/application/gradlew.bat b/dd-smoke-tests/apm-tracing-disabled/application/gradlew.bat new file mode 100644 index 00000000000..107acd32c4e --- /dev/null +++ b/dd-smoke-tests/apm-tracing-disabled/application/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@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 Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@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="-Xmx64m" "-Xms64m" + +@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 execute + +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 execute + +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 + +: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 %* + +: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 diff --git a/dd-smoke-tests/apm-tracing-disabled/application/settings.gradle b/dd-smoke-tests/apm-tracing-disabled/application/settings.gradle new file mode 100644 index 00000000000..b5f9a021357 --- /dev/null +++ b/dd-smoke-tests/apm-tracing-disabled/application/settings.gradle @@ -0,0 +1,32 @@ +pluginManagement { + repositories { + mavenLocal() + if (settings.hasProperty("gradlePluginProxy")) { + maven { + url settings["gradlePluginProxy"] + allowInsecureProtocol = true + } + } + if (settings.hasProperty("mavenRepositoryProxy")) { + maven { + url settings["mavenRepositoryProxy"] + allowInsecureProtocol = true + } + } + gradlePluginPortal() + mavenCentral() + } +} + +def isCI = providers.environmentVariable("CI").isPresent() + +if (isCI) { + def sharedRootDir = "$rootDir/../../../" + buildCache { + local { + directory = "$sharedRootDir/workspace/build-cache" + } + } +} + +rootProject.name='apm-tracing-disabled-smoketest' diff --git a/dd-smoke-tests/apm-tracing-disabled/src/main/java/datadog/smoketest/apmtracingdisabled/AppConfig.java b/dd-smoke-tests/apm-tracing-disabled/application/src/main/java/datadog/smoketest/apmtracingdisabled/AppConfig.java similarity index 100% rename from dd-smoke-tests/apm-tracing-disabled/src/main/java/datadog/smoketest/apmtracingdisabled/AppConfig.java rename to dd-smoke-tests/apm-tracing-disabled/application/src/main/java/datadog/smoketest/apmtracingdisabled/AppConfig.java diff --git a/dd-smoke-tests/apm-tracing-disabled/src/main/java/datadog/smoketest/apmtracingdisabled/Controller.java b/dd-smoke-tests/apm-tracing-disabled/application/src/main/java/datadog/smoketest/apmtracingdisabled/Controller.java similarity index 100% rename from dd-smoke-tests/apm-tracing-disabled/src/main/java/datadog/smoketest/apmtracingdisabled/Controller.java rename to dd-smoke-tests/apm-tracing-disabled/application/src/main/java/datadog/smoketest/apmtracingdisabled/Controller.java diff --git a/dd-smoke-tests/apm-tracing-disabled/src/main/java/datadog/smoketest/apmtracingdisabled/SpringbootApplication.java b/dd-smoke-tests/apm-tracing-disabled/application/src/main/java/datadog/smoketest/apmtracingdisabled/SpringbootApplication.java similarity index 100% rename from dd-smoke-tests/apm-tracing-disabled/src/main/java/datadog/smoketest/apmtracingdisabled/SpringbootApplication.java rename to dd-smoke-tests/apm-tracing-disabled/application/src/main/java/datadog/smoketest/apmtracingdisabled/SpringbootApplication.java diff --git a/dd-smoke-tests/apm-tracing-disabled/build.gradle b/dd-smoke-tests/apm-tracing-disabled/build.gradle index 638260752db..4fb376331f9 100644 --- a/dd-smoke-tests/apm-tracing-disabled/build.gradle +++ b/dd-smoke-tests/apm-tracing-disabled/build.gradle @@ -1,36 +1,63 @@ -import org.springframework.boot.gradle.tasks.bundling.BootJar +apply from: "$rootDir/gradle/java.gradle" -plugins { - id 'java' - id 'org.springframework.boot' version '2.7.15' - id 'io.spring.dependency-management' version '1.0.15.RELEASE' - id 'java-test-fixtures' -} +apply plugin: 'java-test-fixtures' -apply from: "$rootDir/gradle/java.gradle" -apply from: "$rootDir/gradle/spring-boot-plugin.gradle" description = 'ASM Standalone Billing Tests.' -java { - sourceCompatibility = '1.8' +def appDir = "$projectDir/application" +def appBuildDir = "$buildDir/application" +def isWindows = System.getProperty("os.name").toLowerCase().contains("win") +def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew' + +tasks.register('bootJar', Exec) { + workingDir appDir + environment += [ + "GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'", + "JAVA_HOME": getLazyJavaHomeFor(8) + ] + commandLine "$appDir/${gradlewCommand}", "bootJar", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", + "-PapiJar=${project(':dd-trace-api').tasks.jar.archiveFile.get()}" + + outputs.cacheIf { true } + + outputs.dir(appBuildDir) + .withPropertyName("applicationJar") + + inputs.files(fileTree(appDir) { + include '**/*' + exclude '.gradle/**' + }) + .withPropertyName("application") + .withPathSensitivity(PathSensitivity.RELATIVE) +} + +tasks.named('bootJar', Exec) { + dependsOn project(':dd-trace-api').tasks.named('jar') } dependencies { - implementation 'org.springframework.boot:spring-boot-starter-web' - implementation group: 'io.opentracing', name: 'opentracing-api', version: '0.32.0' - implementation group: 'io.opentracing', name: 'opentracing-util', version: '0.32.0' - implementation project(':dd-trace-api') testImplementation project(':dd-smoke-tests') testImplementation(testFixtures(project(":dd-smoke-tests:iast-util"))) } tasks.withType(Test).configureEach { - def bootJarTask = tasks.named('bootJar', BootJar) - dependsOn bootJarTask + dependsOn 'bootJar' jvmArgumentProviders.add(new CommandLineArgumentProvider() { @Override Iterable asArguments() { - return bootJarTask.map { ["-Ddatadog.smoketest.springboot.shadowJar.path=${it.archiveFile.get()}"] }.get() + return [ + "-Ddatadog.smoketest.springboot.shadowJar.path=$appBuildDir/libs/apm-tracing-disabled-smoketest.jar" + ] } }) } + +spotless { + java { + target "**/*.java" + } + + groovyGradle { + target '*.gradle', "**/*.gradle" + } +} diff --git a/dd-smoke-tests/datastreams/kafkaschemaregistry/build.gradle b/dd-smoke-tests/datastreams/kafkaschemaregistry/build.gradle index fe525e8a70e..502d39ba6f7 100644 --- a/dd-smoke-tests/datastreams/kafkaschemaregistry/build.gradle +++ b/dd-smoke-tests/datastreams/kafkaschemaregistry/build.gradle @@ -3,11 +3,9 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar plugins { id 'com.gradleup.shadow' id 'java' - id 'org.springframework.boot' version '2.6.3' } apply from: "$rootDir/gradle/java.gradle" -apply from: "$rootDir/gradle/spring-boot-plugin.gradle" description = 'Kafka Smoke Tests.' tasks.named("jar", Jar) { diff --git a/dd-smoke-tests/kafka-2/application/build.gradle b/dd-smoke-tests/kafka-2/application/build.gradle new file mode 100644 index 00000000000..f5ffc8e910c --- /dev/null +++ b/dd-smoke-tests/kafka-2/application/build.gradle @@ -0,0 +1,29 @@ +plugins { + id 'java' + id 'org.springframework.boot' version '2.7.15' + id 'io.spring.dependency-management' version '1.0.15.RELEASE' +} + +def sharedRootDir = "$rootDir/../../../" +def sharedConfigDirectory = "$sharedRootDir/gradle" +rootProject.ext.sharedConfigDirectory = sharedConfigDirectory + +apply from: "$sharedConfigDirectory/repositories.gradle" + +if (hasProperty('appBuildDir')) { + buildDir = property('appBuildDir') +} + +version = "" + +if (hasProperty('iastUtilJar')) { + dependencies { + implementation files(property('iastUtilJar')) + } +} + +dependencies { + implementation('org.springframework.boot:spring-boot-starter-web') + implementation('org.springframework.boot:spring-boot-starter-actuator') + implementation('org.springframework.kafka:spring-kafka') +} diff --git a/dd-smoke-tests/kafka-2/application/gradle/wrapper/gradle-wrapper.jar b/dd-smoke-tests/kafka-2/application/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000000..e708b1c023e Binary files /dev/null and b/dd-smoke-tests/kafka-2/application/gradle/wrapper/gradle-wrapper.jar differ diff --git a/dd-smoke-tests/kafka-2/application/gradle/wrapper/gradle-wrapper.properties b/dd-smoke-tests/kafka-2/application/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000000..a4cf193f638 --- /dev/null +++ b/dd-smoke-tests/kafka-2/application/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,8 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionSha256Sum=6f74b601422d6d6fc4e1f9a1ab6522f642c2fdcbc15ae33ebd30ba3d7198e854 +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.5-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/dd-smoke-tests/kafka-2/application/gradlew b/dd-smoke-tests/kafka-2/application/gradlew new file mode 100755 index 00000000000..965aff38453 --- /dev/null +++ b/dd-smoke-tests/kafka-2/application/gradlew @@ -0,0 +1,183 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## 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='"-Xmx64m" "-Xms64m"' + +# 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 or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; 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=`expr $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" + +exec "$JAVACMD" "$@" diff --git a/dd-smoke-tests/kafka-2/application/gradlew.bat b/dd-smoke-tests/kafka-2/application/gradlew.bat new file mode 100644 index 00000000000..107acd32c4e --- /dev/null +++ b/dd-smoke-tests/kafka-2/application/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@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 Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@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="-Xmx64m" "-Xms64m" + +@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 execute + +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 execute + +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 + +: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 %* + +: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 diff --git a/dd-smoke-tests/kafka-2/application/settings.gradle b/dd-smoke-tests/kafka-2/application/settings.gradle new file mode 100644 index 00000000000..68e9ddb0060 --- /dev/null +++ b/dd-smoke-tests/kafka-2/application/settings.gradle @@ -0,0 +1,32 @@ +pluginManagement { + repositories { + mavenLocal() + if (settings.hasProperty("gradlePluginProxy")) { + maven { + url settings["gradlePluginProxy"] + allowInsecureProtocol = true + } + } + if (settings.hasProperty("mavenRepositoryProxy")) { + maven { + url settings["mavenRepositoryProxy"] + allowInsecureProtocol = true + } + } + gradlePluginPortal() + mavenCentral() + } +} + +def isCI = providers.environmentVariable("CI").isPresent() + +if (isCI) { + def sharedRootDir = "$rootDir/../../../" + buildCache { + local { + directory = "$sharedRootDir/workspace/build-cache" + } + } +} + +rootProject.name='kafka-2-smoketest' diff --git a/dd-smoke-tests/kafka-2/src/main/java/datadog/smoketest/kafka/KafkaApplication.java b/dd-smoke-tests/kafka-2/application/src/main/java/datadog/smoketest/kafka/KafkaApplication.java similarity index 100% rename from dd-smoke-tests/kafka-2/src/main/java/datadog/smoketest/kafka/KafkaApplication.java rename to dd-smoke-tests/kafka-2/application/src/main/java/datadog/smoketest/kafka/KafkaApplication.java diff --git a/dd-smoke-tests/kafka-2/src/main/java/datadog/smoketest/kafka/iast/IastConfiguration.java b/dd-smoke-tests/kafka-2/application/src/main/java/datadog/smoketest/kafka/iast/IastConfiguration.java similarity index 100% rename from dd-smoke-tests/kafka-2/src/main/java/datadog/smoketest/kafka/iast/IastConfiguration.java rename to dd-smoke-tests/kafka-2/application/src/main/java/datadog/smoketest/kafka/iast/IastConfiguration.java diff --git a/dd-smoke-tests/kafka-2/src/main/java/datadog/smoketest/kafka/iast/IastController.java b/dd-smoke-tests/kafka-2/application/src/main/java/datadog/smoketest/kafka/iast/IastController.java similarity index 100% rename from dd-smoke-tests/kafka-2/src/main/java/datadog/smoketest/kafka/iast/IastController.java rename to dd-smoke-tests/kafka-2/application/src/main/java/datadog/smoketest/kafka/iast/IastController.java diff --git a/dd-smoke-tests/kafka-2/src/main/java/datadog/smoketest/kafka/iast/IastMessage.java b/dd-smoke-tests/kafka-2/application/src/main/java/datadog/smoketest/kafka/iast/IastMessage.java similarity index 100% rename from dd-smoke-tests/kafka-2/src/main/java/datadog/smoketest/kafka/iast/IastMessage.java rename to dd-smoke-tests/kafka-2/application/src/main/java/datadog/smoketest/kafka/iast/IastMessage.java diff --git a/dd-smoke-tests/kafka-2/build.gradle b/dd-smoke-tests/kafka-2/build.gradle index c947425a4ba..39cf19714ce 100644 --- a/dd-smoke-tests/kafka-2/build.gradle +++ b/dd-smoke-tests/kafka-2/build.gradle @@ -1,34 +1,62 @@ -import org.springframework.boot.gradle.tasks.bundling.BootJar +apply from: "$rootDir/gradle/java.gradle" -plugins { - id 'org.springframework.boot' version '2.7.15' - id 'io.spring.dependency-management' version '1.0.15.RELEASE' - id 'java-test-fixtures' -} +apply plugin: 'java-test-fixtures' -apply from: "$rootDir/gradle/java.gradle" -apply from: "$rootDir/gradle/spring-boot-plugin.gradle" description = 'Kafka 2.x Smoke Tests.' -dependencies { - implementation('org.springframework.boot:spring-boot-starter-web') - implementation('org.springframework.boot:spring-boot-starter-actuator') - implementation('org.springframework.kafka:spring-kafka') +def appDir = "$projectDir/application" +def appBuildDir = "$buildDir/application" +def isWindows = System.getProperty("os.name").toLowerCase().contains("win") +def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew' + +tasks.register('bootJar', Exec) { + workingDir appDir + environment += [ + "GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'", + "JAVA_HOME": getLazyJavaHomeFor(8) + ] + commandLine "$appDir/${gradlewCommand}", "bootJar", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", + "-PiastUtilJar=${project(':dd-smoke-tests:iast-util').tasks.jar.archiveFile.get()}" + + outputs.cacheIf { true } + + outputs.dir(appBuildDir) + .withPropertyName("applicationJar") - testImplementation('org.springframework.kafka:spring-kafka-test') + inputs.files(fileTree(appDir) { + include '**/*' + exclude '.gradle/**' + }) + .withPropertyName("application") + .withPathSensitivity(PathSensitivity.RELATIVE) +} + +tasks.named('bootJar', Exec) { + dependsOn project(':dd-smoke-tests:iast-util').tasks.named('jar') +} +dependencies { + testImplementation('org.springframework.kafka:spring-kafka-test:2.8.11') testImplementation project(':dd-smoke-tests') - implementation project(':dd-smoke-tests:iast-util') testImplementation(testFixtures(project(":dd-smoke-tests:iast-util"))) } tasks.withType(Test).configureEach { - def bootJarTask = tasks.named('bootJar', BootJar) - dependsOn bootJarTask + dependsOn 'bootJar' jvmArgumentProviders.add(new CommandLineArgumentProvider() { @Override Iterable asArguments() { - return bootJarTask.map { ["-Ddatadog.smoketest.springboot.shadowJar.path=${it.archiveFile.get()}"] }.get() + return ["-Ddatadog.smoketest.springboot.shadowJar.path=$appBuildDir/libs/kafka-2-smoketest.jar"] } }) } + +spotless { + java { + target "**/*.java" + } + + groovyGradle { + target '*.gradle', "**/*.gradle" + } +} diff --git a/dd-smoke-tests/kafka-3/application/.gitignore b/dd-smoke-tests/kafka-3/application/.gitignore index 1ec2c548b11..c676bce300c 100644 --- a/dd-smoke-tests/kafka-3/application/.gitignore +++ b/dd-smoke-tests/kafka-3/application/.gitignore @@ -1,6 +1,3 @@ -# Ignore all project specific gradle directories/files +# Ignore build artifacts .gradle -gradle build -gradlew -gradlew.bat diff --git a/dd-smoke-tests/kafka-3/application/gradle/wrapper/gradle-wrapper.jar b/dd-smoke-tests/kafka-3/application/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000000..e708b1c023e Binary files /dev/null and b/dd-smoke-tests/kafka-3/application/gradle/wrapper/gradle-wrapper.jar differ diff --git a/dd-smoke-tests/kafka-3/application/gradle/wrapper/gradle-wrapper.properties b/dd-smoke-tests/kafka-3/application/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000000..a4cf193f638 --- /dev/null +++ b/dd-smoke-tests/kafka-3/application/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,8 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionSha256Sum=6f74b601422d6d6fc4e1f9a1ab6522f642c2fdcbc15ae33ebd30ba3d7198e854 +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.5-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/dd-smoke-tests/kafka-3/application/gradlew b/dd-smoke-tests/kafka-3/application/gradlew new file mode 100755 index 00000000000..965aff38453 --- /dev/null +++ b/dd-smoke-tests/kafka-3/application/gradlew @@ -0,0 +1,183 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## 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='"-Xmx64m" "-Xms64m"' + +# 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 or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; 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=`expr $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" + +exec "$JAVACMD" "$@" diff --git a/dd-smoke-tests/kafka-3/application/gradlew.bat b/dd-smoke-tests/kafka-3/application/gradlew.bat new file mode 100644 index 00000000000..107acd32c4e --- /dev/null +++ b/dd-smoke-tests/kafka-3/application/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@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 Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@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="-Xmx64m" "-Xms64m" + +@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 execute + +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 execute + +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 + +: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 %* + +: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 diff --git a/dd-smoke-tests/kafka-3/build.gradle b/dd-smoke-tests/kafka-3/build.gradle index 0c92600de50..e0e929a2287 100644 --- a/dd-smoke-tests/kafka-3/build.gradle +++ b/dd-smoke-tests/kafka-3/build.gradle @@ -26,7 +26,7 @@ tasks.register('bootJar', Exec) { "GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'", "JAVA_HOME": getLazyJavaHomeFor(17) ] - commandLine "$rootDir/${gradlewCommand}", "bootJar", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir" + commandLine "$appDir/${gradlewCommand}", "bootJar", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir" outputs.cacheIf { true } diff --git a/dd-smoke-tests/openfeature/application/build.gradle b/dd-smoke-tests/openfeature/application/build.gradle new file mode 100644 index 00000000000..a74020164f9 --- /dev/null +++ b/dd-smoke-tests/openfeature/application/build.gradle @@ -0,0 +1,35 @@ +plugins { + id 'java' + id 'org.springframework.boot' version '2.7.15' + id 'io.spring.dependency-management' version '1.0.15.RELEASE' +} + +def sharedRootDir = "$rootDir/../../../" +def sharedConfigDirectory = "$sharedRootDir/gradle" +rootProject.ext.sharedConfigDirectory = sharedConfigDirectory + +apply from: "$sharedConfigDirectory/repositories.gradle" + +if (hasProperty('appBuildDir')) { + buildDir = property('appBuildDir') +} + +version = "" + +java { + sourceCompatibility = 11 + targetCompatibility = 11 +} + +if (hasProperty('featureFlaggingApiJar')) { + dependencies { + implementation files(property('featureFlaggingApiJar')) + } +} + +dependencies { + // OpenFeature SDK is an API dependency of feature-flagging-api but is not + // transitively resolved when the jar is passed as a files() dependency. + implementation 'dev.openfeature:sdk:1.20.1' + implementation 'org.springframework.boot:spring-boot-starter-web' +} diff --git a/dd-smoke-tests/openfeature/application/gradle/wrapper/gradle-wrapper.jar b/dd-smoke-tests/openfeature/application/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000000..e708b1c023e Binary files /dev/null and b/dd-smoke-tests/openfeature/application/gradle/wrapper/gradle-wrapper.jar differ diff --git a/dd-smoke-tests/openfeature/application/gradle/wrapper/gradle-wrapper.properties b/dd-smoke-tests/openfeature/application/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000000..a4cf193f638 --- /dev/null +++ b/dd-smoke-tests/openfeature/application/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,8 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionSha256Sum=6f74b601422d6d6fc4e1f9a1ab6522f642c2fdcbc15ae33ebd30ba3d7198e854 +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.5-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/dd-smoke-tests/openfeature/application/gradlew b/dd-smoke-tests/openfeature/application/gradlew new file mode 100755 index 00000000000..965aff38453 --- /dev/null +++ b/dd-smoke-tests/openfeature/application/gradlew @@ -0,0 +1,183 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## 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='"-Xmx64m" "-Xms64m"' + +# 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 or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; 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=`expr $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" + +exec "$JAVACMD" "$@" diff --git a/dd-smoke-tests/openfeature/application/gradlew.bat b/dd-smoke-tests/openfeature/application/gradlew.bat new file mode 100644 index 00000000000..107acd32c4e --- /dev/null +++ b/dd-smoke-tests/openfeature/application/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@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 Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@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="-Xmx64m" "-Xms64m" + +@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 execute + +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 execute + +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 + +: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 %* + +: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 diff --git a/dd-smoke-tests/openfeature/application/settings.gradle b/dd-smoke-tests/openfeature/application/settings.gradle new file mode 100644 index 00000000000..b326d9873f1 --- /dev/null +++ b/dd-smoke-tests/openfeature/application/settings.gradle @@ -0,0 +1,32 @@ +pluginManagement { + repositories { + mavenLocal() + if (settings.hasProperty("gradlePluginProxy")) { + maven { + url settings["gradlePluginProxy"] + allowInsecureProtocol = true + } + } + if (settings.hasProperty("mavenRepositoryProxy")) { + maven { + url settings["mavenRepositoryProxy"] + allowInsecureProtocol = true + } + } + gradlePluginPortal() + mavenCentral() + } +} + +def isCI = providers.environmentVariable("CI").isPresent() + +if (isCI) { + def sharedRootDir = "$rootDir/../../../" + buildCache { + local { + directory = "$sharedRootDir/workspace/build-cache" + } + } +} + +rootProject.name='openfeature-smoketest' diff --git a/dd-smoke-tests/openfeature/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java b/dd-smoke-tests/openfeature/application/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java similarity index 100% rename from dd-smoke-tests/openfeature/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java rename to dd-smoke-tests/openfeature/application/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java diff --git a/dd-smoke-tests/openfeature/src/main/java/datadog/smoketest/springboot/openfeature/OpenFeatureConfiguration.java b/dd-smoke-tests/openfeature/application/src/main/java/datadog/smoketest/springboot/openfeature/OpenFeatureConfiguration.java similarity index 100% rename from dd-smoke-tests/openfeature/src/main/java/datadog/smoketest/springboot/openfeature/OpenFeatureConfiguration.java rename to dd-smoke-tests/openfeature/application/src/main/java/datadog/smoketest/springboot/openfeature/OpenFeatureConfiguration.java diff --git a/dd-smoke-tests/openfeature/src/main/java/datadog/smoketest/springboot/openfeature/OpenFeatureController.java b/dd-smoke-tests/openfeature/application/src/main/java/datadog/smoketest/springboot/openfeature/OpenFeatureController.java similarity index 100% rename from dd-smoke-tests/openfeature/src/main/java/datadog/smoketest/springboot/openfeature/OpenFeatureController.java rename to dd-smoke-tests/openfeature/application/src/main/java/datadog/smoketest/springboot/openfeature/OpenFeatureController.java diff --git a/dd-smoke-tests/openfeature/build.gradle b/dd-smoke-tests/openfeature/build.gradle index a38696418ef..d943be32ae4 100644 --- a/dd-smoke-tests/openfeature/build.gradle +++ b/dd-smoke-tests/openfeature/build.gradle @@ -1,38 +1,63 @@ -import org.springframework.boot.gradle.tasks.bundling.BootJar - -plugins { - id 'java' - id 'org.springframework.boot' version '2.7.15' - id 'io.spring.dependency-management' version '1.0.15.RELEASE' -} - apply from: "$rootDir/gradle/java.gradle" -apply from: "$rootDir/gradle/spring-boot-plugin.gradle" + description = 'Open Feature provider Smoke Tests.' testJvmConstraints { minJavaVersion = JavaVersion.VERSION_11 } -tasks.named("compileJava", JavaCompile) { - configureCompiler(it, 11, JavaVersion.VERSION_11) +def appDir = "$projectDir/application" +def appBuildDir = "$buildDir/application" +def isWindows = System.getProperty("os.name").toLowerCase().contains("win") +def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew' + +tasks.register('bootJar', Exec) { + workingDir appDir + environment += [ + "GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'", + "JAVA_HOME": getLazyJavaHomeFor(11) + ] + commandLine "$appDir/${gradlewCommand}", "bootJar", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", + "-PfeatureFlaggingApiJar=${project(':products:feature-flagging:feature-flagging-api').tasks.jar.archiveFile.get()}" + + outputs.cacheIf { true } + + outputs.dir(appBuildDir) + .withPropertyName("applicationJar") + + inputs.files(fileTree(appDir) { + include '**/*' + exclude '.gradle/**' + }) + .withPropertyName("application") + .withPathSensitivity(PathSensitivity.RELATIVE) +} + +tasks.named('bootJar', Exec) { + dependsOn project(':products:feature-flagging:feature-flagging-api').tasks.named('jar') } dependencies { - implementation project(':products:feature-flagging:feature-flagging-api') - implementation 'org.springframework.boot:spring-boot-starter-web' - testImplementation project(':dd-smoke-tests') testImplementation project(':products:feature-flagging:feature-flagging-lib') } tasks.withType(Test).configureEach { - dependsOn "bootJar" - def bootJarTask = tasks.named('bootJar', BootJar) + dependsOn 'bootJar' jvmArgumentProviders.add(new CommandLineArgumentProvider() { @Override Iterable asArguments() { - return bootJarTask.map { ["-Ddatadog.smoketest.springboot.shadowJar.path=${it.archiveFile.get()}"] }.get() + return ["-Ddatadog.smoketest.springboot.shadowJar.path=$appBuildDir/libs/openfeature-smoketest.jar"] } }) } + +spotless { + java { + target "**/*.java" + } + + groovyGradle { + target '*.gradle', "**/*.gradle" + } +} diff --git a/dd-smoke-tests/spring-boot-2.7-webflux/application/.gitignore b/dd-smoke-tests/spring-boot-2.7-webflux/application/.gitignore index 1ec2c548b11..c676bce300c 100644 --- a/dd-smoke-tests/spring-boot-2.7-webflux/application/.gitignore +++ b/dd-smoke-tests/spring-boot-2.7-webflux/application/.gitignore @@ -1,6 +1,3 @@ -# Ignore all project specific gradle directories/files +# Ignore build artifacts .gradle -gradle build -gradlew -gradlew.bat diff --git a/dd-smoke-tests/spring-boot-2.7-webflux/application/gradle/wrapper/gradle-wrapper.jar b/dd-smoke-tests/spring-boot-2.7-webflux/application/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000000..e708b1c023e Binary files /dev/null and b/dd-smoke-tests/spring-boot-2.7-webflux/application/gradle/wrapper/gradle-wrapper.jar differ diff --git a/dd-smoke-tests/spring-boot-2.7-webflux/application/gradle/wrapper/gradle-wrapper.properties b/dd-smoke-tests/spring-boot-2.7-webflux/application/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000000..a4cf193f638 --- /dev/null +++ b/dd-smoke-tests/spring-boot-2.7-webflux/application/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,8 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionSha256Sum=6f74b601422d6d6fc4e1f9a1ab6522f642c2fdcbc15ae33ebd30ba3d7198e854 +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.5-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/dd-smoke-tests/spring-boot-2.7-webflux/application/gradlew b/dd-smoke-tests/spring-boot-2.7-webflux/application/gradlew new file mode 100755 index 00000000000..965aff38453 --- /dev/null +++ b/dd-smoke-tests/spring-boot-2.7-webflux/application/gradlew @@ -0,0 +1,183 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## 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='"-Xmx64m" "-Xms64m"' + +# 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 or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; 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=`expr $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" + +exec "$JAVACMD" "$@" diff --git a/dd-smoke-tests/spring-boot-2.7-webflux/application/gradlew.bat b/dd-smoke-tests/spring-boot-2.7-webflux/application/gradlew.bat new file mode 100644 index 00000000000..107acd32c4e --- /dev/null +++ b/dd-smoke-tests/spring-boot-2.7-webflux/application/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@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 Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@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="-Xmx64m" "-Xms64m" + +@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 execute + +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 execute + +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 + +: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 %* + +: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 diff --git a/dd-smoke-tests/spring-boot-2.7-webflux/build.gradle b/dd-smoke-tests/spring-boot-2.7-webflux/build.gradle index ec403dc3c20..a76e3066d06 100644 --- a/dd-smoke-tests/spring-boot-2.7-webflux/build.gradle +++ b/dd-smoke-tests/spring-boot-2.7-webflux/build.gradle @@ -18,7 +18,7 @@ tasks.register('webfluxBuild', Exec) { "GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'", "JAVA_HOME": getLazyJavaHomeFor(8) ] - commandLine "$rootDir/${gradlewCommand}", "bootJar", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", "-PapiJar=${project(':dd-trace-api').tasks.jar.archiveFile.get()}" + commandLine "$appDir/${gradlewCommand}", "bootJar", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", "-PapiJar=${project(':dd-trace-api').tasks.jar.archiveFile.get()}" outputs.cacheIf { true } diff --git a/dd-smoke-tests/spring-boot-3.0-native/application/.gitignore b/dd-smoke-tests/spring-boot-3.0-native/application/.gitignore index 1ec2c548b11..c676bce300c 100644 --- a/dd-smoke-tests/spring-boot-3.0-native/application/.gitignore +++ b/dd-smoke-tests/spring-boot-3.0-native/application/.gitignore @@ -1,6 +1,3 @@ -# Ignore all project specific gradle directories/files +# Ignore build artifacts .gradle -gradle build -gradlew -gradlew.bat diff --git a/dd-smoke-tests/spring-boot-3.0-native/application/gradle/wrapper/gradle-wrapper.jar b/dd-smoke-tests/spring-boot-3.0-native/application/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000000..e708b1c023e Binary files /dev/null and b/dd-smoke-tests/spring-boot-3.0-native/application/gradle/wrapper/gradle-wrapper.jar differ diff --git a/dd-smoke-tests/spring-boot-3.0-native/application/gradle/wrapper/gradle-wrapper.properties b/dd-smoke-tests/spring-boot-3.0-native/application/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000000..a4cf193f638 --- /dev/null +++ b/dd-smoke-tests/spring-boot-3.0-native/application/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,8 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionSha256Sum=6f74b601422d6d6fc4e1f9a1ab6522f642c2fdcbc15ae33ebd30ba3d7198e854 +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.5-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/dd-smoke-tests/spring-boot-3.0-native/application/gradlew b/dd-smoke-tests/spring-boot-3.0-native/application/gradlew new file mode 100755 index 00000000000..965aff38453 --- /dev/null +++ b/dd-smoke-tests/spring-boot-3.0-native/application/gradlew @@ -0,0 +1,183 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## 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='"-Xmx64m" "-Xms64m"' + +# 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 or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; 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=`expr $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" + +exec "$JAVACMD" "$@" diff --git a/dd-smoke-tests/spring-boot-3.0-native/application/gradlew.bat b/dd-smoke-tests/spring-boot-3.0-native/application/gradlew.bat new file mode 100644 index 00000000000..107acd32c4e --- /dev/null +++ b/dd-smoke-tests/spring-boot-3.0-native/application/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@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 Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@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="-Xmx64m" "-Xms64m" + +@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 execute + +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 execute + +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 + +: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 %* + +: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 diff --git a/dd-smoke-tests/spring-boot-3.0-native/build.gradle b/dd-smoke-tests/spring-boot-3.0-native/build.gradle index e0dda4c6db6..c61d62d010a 100644 --- a/dd-smoke-tests/spring-boot-3.0-native/build.gradle +++ b/dd-smoke-tests/spring-boot-3.0-native/build.gradle @@ -37,7 +37,7 @@ if (testGraalvmVersion >= 17) { 'NATIVE_IMAGE_DEPRECATED_BUILDER_SANITATION' : 'true' ] commandLine( - "$rootDir/${gradlewCommand}", + "$appDir/${gradlewCommand}", 'nativeCompile', '--no-daemon', '--max-workers=4', diff --git a/dd-smoke-tests/spring-boot-3.0-webflux/application/.gitignore b/dd-smoke-tests/spring-boot-3.0-webflux/application/.gitignore index 1ec2c548b11..c676bce300c 100644 --- a/dd-smoke-tests/spring-boot-3.0-webflux/application/.gitignore +++ b/dd-smoke-tests/spring-boot-3.0-webflux/application/.gitignore @@ -1,6 +1,3 @@ -# Ignore all project specific gradle directories/files +# Ignore build artifacts .gradle -gradle build -gradlew -gradlew.bat diff --git a/dd-smoke-tests/spring-boot-3.0-webflux/application/gradle/wrapper/gradle-wrapper.jar b/dd-smoke-tests/spring-boot-3.0-webflux/application/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000000..e708b1c023e Binary files /dev/null and b/dd-smoke-tests/spring-boot-3.0-webflux/application/gradle/wrapper/gradle-wrapper.jar differ diff --git a/dd-smoke-tests/spring-boot-3.0-webflux/application/gradle/wrapper/gradle-wrapper.properties b/dd-smoke-tests/spring-boot-3.0-webflux/application/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000000..a4cf193f638 --- /dev/null +++ b/dd-smoke-tests/spring-boot-3.0-webflux/application/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,8 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionSha256Sum=6f74b601422d6d6fc4e1f9a1ab6522f642c2fdcbc15ae33ebd30ba3d7198e854 +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.5-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/dd-smoke-tests/spring-boot-3.0-webflux/application/gradlew b/dd-smoke-tests/spring-boot-3.0-webflux/application/gradlew new file mode 100755 index 00000000000..965aff38453 --- /dev/null +++ b/dd-smoke-tests/spring-boot-3.0-webflux/application/gradlew @@ -0,0 +1,183 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## 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='"-Xmx64m" "-Xms64m"' + +# 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 or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; 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=`expr $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" + +exec "$JAVACMD" "$@" diff --git a/dd-smoke-tests/spring-boot-3.0-webflux/application/gradlew.bat b/dd-smoke-tests/spring-boot-3.0-webflux/application/gradlew.bat new file mode 100644 index 00000000000..107acd32c4e --- /dev/null +++ b/dd-smoke-tests/spring-boot-3.0-webflux/application/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@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 Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@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="-Xmx64m" "-Xms64m" + +@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 execute + +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 execute + +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 + +: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 %* + +: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 diff --git a/dd-smoke-tests/spring-boot-3.0-webflux/build.gradle b/dd-smoke-tests/spring-boot-3.0-webflux/build.gradle index 6138aef945d..28b12fbc45d 100644 --- a/dd-smoke-tests/spring-boot-3.0-webflux/build.gradle +++ b/dd-smoke-tests/spring-boot-3.0-webflux/build.gradle @@ -22,7 +22,7 @@ tasks.register('webfluxBuild30', Exec) { "GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'", "JAVA_HOME": getLazyJavaHomeFor(17) ] - commandLine "$rootDir/${gradlewCommand}", "bootJar", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", "-PapiJar=${project(':dd-trace-api').tasks.jar.archiveFile.get()}" + commandLine "$appDir/${gradlewCommand}", "bootJar", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", "-PapiJar=${project(':dd-trace-api').tasks.jar.archiveFile.get()}" outputs.cacheIf { true } diff --git a/dd-smoke-tests/spring-boot-3.0-webmvc/application/.gitignore b/dd-smoke-tests/spring-boot-3.0-webmvc/application/.gitignore index 1ec2c548b11..c676bce300c 100644 --- a/dd-smoke-tests/spring-boot-3.0-webmvc/application/.gitignore +++ b/dd-smoke-tests/spring-boot-3.0-webmvc/application/.gitignore @@ -1,6 +1,3 @@ -# Ignore all project specific gradle directories/files +# Ignore build artifacts .gradle -gradle build -gradlew -gradlew.bat diff --git a/dd-smoke-tests/spring-boot-3.0-webmvc/application/gradle/wrapper/gradle-wrapper.jar b/dd-smoke-tests/spring-boot-3.0-webmvc/application/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000000..e708b1c023e Binary files /dev/null and b/dd-smoke-tests/spring-boot-3.0-webmvc/application/gradle/wrapper/gradle-wrapper.jar differ diff --git a/dd-smoke-tests/spring-boot-3.0-webmvc/application/gradle/wrapper/gradle-wrapper.properties b/dd-smoke-tests/spring-boot-3.0-webmvc/application/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000000..a4cf193f638 --- /dev/null +++ b/dd-smoke-tests/spring-boot-3.0-webmvc/application/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,8 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionSha256Sum=6f74b601422d6d6fc4e1f9a1ab6522f642c2fdcbc15ae33ebd30ba3d7198e854 +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.5-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/dd-smoke-tests/spring-boot-3.0-webmvc/application/gradlew b/dd-smoke-tests/spring-boot-3.0-webmvc/application/gradlew new file mode 100755 index 00000000000..965aff38453 --- /dev/null +++ b/dd-smoke-tests/spring-boot-3.0-webmvc/application/gradlew @@ -0,0 +1,183 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## 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='"-Xmx64m" "-Xms64m"' + +# 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 or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; 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=`expr $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" + +exec "$JAVACMD" "$@" diff --git a/dd-smoke-tests/spring-boot-3.0-webmvc/application/gradlew.bat b/dd-smoke-tests/spring-boot-3.0-webmvc/application/gradlew.bat new file mode 100644 index 00000000000..107acd32c4e --- /dev/null +++ b/dd-smoke-tests/spring-boot-3.0-webmvc/application/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@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 Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@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="-Xmx64m" "-Xms64m" + +@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 execute + +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 execute + +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 + +: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 %* + +: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 diff --git a/dd-smoke-tests/spring-boot-3.0-webmvc/build.gradle b/dd-smoke-tests/spring-boot-3.0-webmvc/build.gradle index 46c00fbcec8..d6fbc30b1f6 100644 --- a/dd-smoke-tests/spring-boot-3.0-webmvc/build.gradle +++ b/dd-smoke-tests/spring-boot-3.0-webmvc/build.gradle @@ -22,7 +22,7 @@ tasks.register('webmvcBuild30', Exec) { "GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'", "JAVA_HOME": getLazyJavaHomeFor(17) ] - commandLine "$rootDir/${gradlewCommand}", "bootJar", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", "-PapiJar=${project(':dd-trace-api').tasks.jar.archiveFile.get()}" + commandLine "$appDir/${gradlewCommand}", "bootJar", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", "-PapiJar=${project(':dd-trace-api').tasks.jar.archiveFile.get()}" outputs.cacheIf { true } diff --git a/dd-smoke-tests/spring-boot-3.3-webmvc/application/.gitignore b/dd-smoke-tests/spring-boot-3.3-webmvc/application/.gitignore index 1ec2c548b11..c676bce300c 100644 --- a/dd-smoke-tests/spring-boot-3.3-webmvc/application/.gitignore +++ b/dd-smoke-tests/spring-boot-3.3-webmvc/application/.gitignore @@ -1,6 +1,3 @@ -# Ignore all project specific gradle directories/files +# Ignore build artifacts .gradle -gradle build -gradlew -gradlew.bat diff --git a/dd-smoke-tests/spring-boot-3.3-webmvc/application/gradle/wrapper/gradle-wrapper.jar b/dd-smoke-tests/spring-boot-3.3-webmvc/application/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000000..e708b1c023e Binary files /dev/null and b/dd-smoke-tests/spring-boot-3.3-webmvc/application/gradle/wrapper/gradle-wrapper.jar differ diff --git a/dd-smoke-tests/spring-boot-3.3-webmvc/application/gradle/wrapper/gradle-wrapper.properties b/dd-smoke-tests/spring-boot-3.3-webmvc/application/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000000..a4cf193f638 --- /dev/null +++ b/dd-smoke-tests/spring-boot-3.3-webmvc/application/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,8 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionSha256Sum=6f74b601422d6d6fc4e1f9a1ab6522f642c2fdcbc15ae33ebd30ba3d7198e854 +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.5-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/dd-smoke-tests/spring-boot-3.3-webmvc/application/gradlew b/dd-smoke-tests/spring-boot-3.3-webmvc/application/gradlew new file mode 100755 index 00000000000..965aff38453 --- /dev/null +++ b/dd-smoke-tests/spring-boot-3.3-webmvc/application/gradlew @@ -0,0 +1,183 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## 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='"-Xmx64m" "-Xms64m"' + +# 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 or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; 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=`expr $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" + +exec "$JAVACMD" "$@" diff --git a/dd-smoke-tests/spring-boot-3.3-webmvc/application/gradlew.bat b/dd-smoke-tests/spring-boot-3.3-webmvc/application/gradlew.bat new file mode 100644 index 00000000000..107acd32c4e --- /dev/null +++ b/dd-smoke-tests/spring-boot-3.3-webmvc/application/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@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 Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@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="-Xmx64m" "-Xms64m" + +@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 execute + +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 execute + +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 + +: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 %* + +: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 diff --git a/dd-smoke-tests/spring-boot-3.3-webmvc/build.gradle b/dd-smoke-tests/spring-boot-3.3-webmvc/build.gradle index 484ecfc5668..9bf982fab30 100644 --- a/dd-smoke-tests/spring-boot-3.3-webmvc/build.gradle +++ b/dd-smoke-tests/spring-boot-3.3-webmvc/build.gradle @@ -22,7 +22,7 @@ tasks.register('webmvcBuild3', Exec) { "GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'", "JAVA_HOME": getLazyJavaHomeFor(17) ] - commandLine "$rootDir/${gradlewCommand}", "bootJar", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", "-PapiJar=${project(':dd-trace-api').tasks.jar.archiveFile.get()}" + commandLine "$appDir/${gradlewCommand}", "bootJar", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", "-PapiJar=${project(':dd-trace-api').tasks.jar.archiveFile.get()}" outputs.cacheIf { true } diff --git a/dd-smoke-tests/springboot-freemarker/application/build.gradle b/dd-smoke-tests/springboot-freemarker/application/build.gradle new file mode 100644 index 00000000000..3a0220c4ca8 --- /dev/null +++ b/dd-smoke-tests/springboot-freemarker/application/build.gradle @@ -0,0 +1,26 @@ +plugins { + id 'java' + id 'org.springframework.boot' version '2.7.15' + id 'io.spring.dependency-management' version '1.0.15.RELEASE' +} + +def sharedRootDir = "$rootDir/../../../" +def sharedConfigDirectory = "$sharedRootDir/gradle" +rootProject.ext.sharedConfigDirectory = sharedConfigDirectory + +apply from: "$sharedConfigDirectory/repositories.gradle" + +if (hasProperty('appBuildDir')) { + buildDir = property('appBuildDir') +} + +version = "" + +java { + sourceCompatibility = '1.8' +} + +dependencies { + implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.5.18.RELEASE' + implementation group: 'org.freemarker', name: 'freemarker', version: '2.3.24-incubating' +} diff --git a/dd-smoke-tests/springboot-freemarker/application/gradle/wrapper/gradle-wrapper.jar b/dd-smoke-tests/springboot-freemarker/application/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000000..e708b1c023e Binary files /dev/null and b/dd-smoke-tests/springboot-freemarker/application/gradle/wrapper/gradle-wrapper.jar differ diff --git a/dd-smoke-tests/springboot-freemarker/application/gradle/wrapper/gradle-wrapper.properties b/dd-smoke-tests/springboot-freemarker/application/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000000..a4cf193f638 --- /dev/null +++ b/dd-smoke-tests/springboot-freemarker/application/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,8 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionSha256Sum=6f74b601422d6d6fc4e1f9a1ab6522f642c2fdcbc15ae33ebd30ba3d7198e854 +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.5-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/dd-smoke-tests/springboot-freemarker/application/gradlew b/dd-smoke-tests/springboot-freemarker/application/gradlew new file mode 100755 index 00000000000..965aff38453 --- /dev/null +++ b/dd-smoke-tests/springboot-freemarker/application/gradlew @@ -0,0 +1,183 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## 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='"-Xmx64m" "-Xms64m"' + +# 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 or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; 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=`expr $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" + +exec "$JAVACMD" "$@" diff --git a/dd-smoke-tests/springboot-freemarker/application/gradlew.bat b/dd-smoke-tests/springboot-freemarker/application/gradlew.bat new file mode 100644 index 00000000000..107acd32c4e --- /dev/null +++ b/dd-smoke-tests/springboot-freemarker/application/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@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 Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@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="-Xmx64m" "-Xms64m" + +@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 execute + +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 execute + +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 + +: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 %* + +: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 diff --git a/dd-smoke-tests/springboot-freemarker/application/settings.gradle b/dd-smoke-tests/springboot-freemarker/application/settings.gradle new file mode 100644 index 00000000000..f202c747c3e --- /dev/null +++ b/dd-smoke-tests/springboot-freemarker/application/settings.gradle @@ -0,0 +1,32 @@ +pluginManagement { + repositories { + mavenLocal() + if (settings.hasProperty("gradlePluginProxy")) { + maven { + url settings["gradlePluginProxy"] + allowInsecureProtocol = true + } + } + if (settings.hasProperty("mavenRepositoryProxy")) { + maven { + url settings["mavenRepositoryProxy"] + allowInsecureProtocol = true + } + } + gradlePluginPortal() + mavenCentral() + } +} + +def isCI = providers.environmentVariable("CI").isPresent() + +if (isCI) { + def sharedRootDir = "$rootDir/../../../" + buildCache { + local { + directory = "$sharedRootDir/workspace/build-cache" + } + } +} + +rootProject.name='springboot-freemarker-smoketest' diff --git a/dd-smoke-tests/springboot-freemarker/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java b/dd-smoke-tests/springboot-freemarker/application/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java similarity index 100% rename from dd-smoke-tests/springboot-freemarker/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java rename to dd-smoke-tests/springboot-freemarker/application/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java diff --git a/dd-smoke-tests/springboot-freemarker/src/main/java/datadog/smoketest/springboot/XssController.java b/dd-smoke-tests/springboot-freemarker/application/src/main/java/datadog/smoketest/springboot/XssController.java similarity index 100% rename from dd-smoke-tests/springboot-freemarker/src/main/java/datadog/smoketest/springboot/XssController.java rename to dd-smoke-tests/springboot-freemarker/application/src/main/java/datadog/smoketest/springboot/XssController.java diff --git a/dd-smoke-tests/springboot-freemarker/src/main/resources/templates/freemarker-2.3.24-insecure.ftlh b/dd-smoke-tests/springboot-freemarker/application/src/main/resources/templates/freemarker-2.3.24-insecure.ftlh similarity index 100% rename from dd-smoke-tests/springboot-freemarker/src/main/resources/templates/freemarker-2.3.24-insecure.ftlh rename to dd-smoke-tests/springboot-freemarker/application/src/main/resources/templates/freemarker-2.3.24-insecure.ftlh diff --git a/dd-smoke-tests/springboot-freemarker/src/main/resources/templates/freemarker-2.3.24-secure.ftlh b/dd-smoke-tests/springboot-freemarker/application/src/main/resources/templates/freemarker-2.3.24-secure.ftlh similarity index 100% rename from dd-smoke-tests/springboot-freemarker/src/main/resources/templates/freemarker-2.3.24-secure.ftlh rename to dd-smoke-tests/springboot-freemarker/application/src/main/resources/templates/freemarker-2.3.24-secure.ftlh diff --git a/dd-smoke-tests/springboot-freemarker/src/main/resources/templates/freemarker-2.3.9-insecure.ftlh b/dd-smoke-tests/springboot-freemarker/application/src/main/resources/templates/freemarker-2.3.9-insecure.ftlh similarity index 100% rename from dd-smoke-tests/springboot-freemarker/src/main/resources/templates/freemarker-2.3.9-insecure.ftlh rename to dd-smoke-tests/springboot-freemarker/application/src/main/resources/templates/freemarker-2.3.9-insecure.ftlh diff --git a/dd-smoke-tests/springboot-freemarker/src/main/resources/templates/freemarker-2.3.9-secure.ftlh b/dd-smoke-tests/springboot-freemarker/application/src/main/resources/templates/freemarker-2.3.9-secure.ftlh similarity index 100% rename from dd-smoke-tests/springboot-freemarker/src/main/resources/templates/freemarker-2.3.9-secure.ftlh rename to dd-smoke-tests/springboot-freemarker/application/src/main/resources/templates/freemarker-2.3.9-secure.ftlh diff --git a/dd-smoke-tests/springboot-freemarker/build.gradle b/dd-smoke-tests/springboot-freemarker/build.gradle index 57c7a4e9eb1..ab6cf36bbcf 100644 --- a/dd-smoke-tests/springboot-freemarker/build.gradle +++ b/dd-smoke-tests/springboot-freemarker/build.gradle @@ -1,35 +1,72 @@ -import org.springframework.boot.gradle.tasks.bundling.BootJar +apply from: "$rootDir/gradle/java.gradle" -plugins { - id 'java' - id 'org.springframework.boot' version '2.7.15' - id 'io.spring.dependency-management' version '1.0.15.RELEASE' - id 'java-test-fixtures' -} +apply plugin: 'java-test-fixtures' -apply from: "$rootDir/gradle/java.gradle" -apply from: "$rootDir/gradle/spring-boot-plugin.gradle" description = 'SpringBoot Freemarker Smoke Tests.' -java { - sourceCompatibility = '1.8' +def appDir = "$projectDir/application" +def appBuildDir = "$buildDir/application" +def isWindows = System.getProperty("os.name").toLowerCase().contains("win") +def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew' + +tasks.register('bootJar', Exec) { + workingDir appDir + environment += [ + "GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'", + "JAVA_HOME": getLazyJavaHomeFor(8) + ] + commandLine "$appDir/${gradlewCommand}", "bootJar", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir" + + outputs.cacheIf { true } + + outputs.dir(appBuildDir) + .withPropertyName("applicationJar") + + inputs.files(fileTree(appDir) { + include '**/*' + exclude '.gradle/**' + }) + .withPropertyName("application") + .withPathSensitivity(PathSensitivity.RELATIVE) } dependencies { - implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.5.18.RELEASE' - implementation group: 'org.freemarker', name: 'freemarker', version: '2.3.24-incubating' - testImplementation project(':dd-smoke-tests') testImplementation(testFixtures(project(":dd-smoke-tests:iast-util"))) } +// The XssController loads templates from the filesystem at "resources/main/templates" +// relative to the test's working directory (= this module's buildDir). Mirror the app's +// processed resources here so the path resolves correctly at runtime. +tasks.register('copyAppResources', Copy) { + dependsOn 'bootJar' + from "$appBuildDir/resources/main" + into "$buildDir/resources/main" +} + +// jar reads build/resources/main; declare the dependency so Gradle knows the ordering. +tasks.named('jar') { + dependsOn 'copyAppResources' +} + tasks.withType(Test).configureEach { - dependsOn "bootJar" - def bootJarTask = tasks.named('bootJar', BootJar) + dependsOn 'copyAppResources' jvmArgumentProviders.add(new CommandLineArgumentProvider() { @Override Iterable asArguments() { - return bootJarTask.map { ["-Ddatadog.smoketest.springboot.shadowJar.path=${it.archiveFile.get()}"] }.get() + return [ + "-Ddatadog.smoketest.springboot.shadowJar.path=$appBuildDir/libs/springboot-freemarker-smoketest.jar" + ] } }) } + +spotless { + java { + target "**/*.java" + } + + groovyGradle { + target '*.gradle', "**/*.gradle" + } +} diff --git a/dd-smoke-tests/springboot-java-11/application/build.gradle b/dd-smoke-tests/springboot-java-11/application/build.gradle new file mode 100644 index 00000000000..ea12bb0cdc4 --- /dev/null +++ b/dd-smoke-tests/springboot-java-11/application/build.gradle @@ -0,0 +1,31 @@ +plugins { + id 'java' + id 'org.springframework.boot' version '2.7.15' + id 'io.spring.dependency-management' version '1.0.15.RELEASE' +} + +def sharedRootDir = "$rootDir/../../../" +def sharedConfigDirectory = "$sharedRootDir/gradle" +rootProject.ext.sharedConfigDirectory = sharedConfigDirectory + +apply from: "$sharedConfigDirectory/repositories.gradle" + +if (hasProperty('appBuildDir')) { + buildDir = property('appBuildDir') +} + +version = "" + +java { + sourceCompatibility = 11 +} + +if (hasProperty('iastUtil11Jar')) { + dependencies { + implementation files(property('iastUtil11Jar')) + } +} + +dependencies { + implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.2.0.RELEASE' +} diff --git a/dd-smoke-tests/springboot-java-11/application/gradle/wrapper/gradle-wrapper.jar b/dd-smoke-tests/springboot-java-11/application/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000000..e708b1c023e Binary files /dev/null and b/dd-smoke-tests/springboot-java-11/application/gradle/wrapper/gradle-wrapper.jar differ diff --git a/dd-smoke-tests/springboot-java-11/application/gradle/wrapper/gradle-wrapper.properties b/dd-smoke-tests/springboot-java-11/application/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000000..a4cf193f638 --- /dev/null +++ b/dd-smoke-tests/springboot-java-11/application/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,8 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionSha256Sum=6f74b601422d6d6fc4e1f9a1ab6522f642c2fdcbc15ae33ebd30ba3d7198e854 +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.5-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/dd-smoke-tests/springboot-java-11/application/gradlew b/dd-smoke-tests/springboot-java-11/application/gradlew new file mode 100755 index 00000000000..965aff38453 --- /dev/null +++ b/dd-smoke-tests/springboot-java-11/application/gradlew @@ -0,0 +1,183 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## 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='"-Xmx64m" "-Xms64m"' + +# 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 or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; 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=`expr $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" + +exec "$JAVACMD" "$@" diff --git a/dd-smoke-tests/springboot-java-11/application/gradlew.bat b/dd-smoke-tests/springboot-java-11/application/gradlew.bat new file mode 100644 index 00000000000..107acd32c4e --- /dev/null +++ b/dd-smoke-tests/springboot-java-11/application/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@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 Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@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="-Xmx64m" "-Xms64m" + +@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 execute + +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 execute + +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 + +: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 %* + +: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 diff --git a/dd-smoke-tests/springboot-java-11/application/settings.gradle b/dd-smoke-tests/springboot-java-11/application/settings.gradle new file mode 100644 index 00000000000..9799114b822 --- /dev/null +++ b/dd-smoke-tests/springboot-java-11/application/settings.gradle @@ -0,0 +1,32 @@ +pluginManagement { + repositories { + mavenLocal() + if (settings.hasProperty("gradlePluginProxy")) { + maven { + url settings["gradlePluginProxy"] + allowInsecureProtocol = true + } + } + if (settings.hasProperty("mavenRepositoryProxy")) { + maven { + url settings["mavenRepositoryProxy"] + allowInsecureProtocol = true + } + } + gradlePluginPortal() + mavenCentral() + } +} + +def isCI = providers.environmentVariable("CI").isPresent() + +if (isCI) { + def sharedRootDir = "$rootDir/../../../" + buildCache { + local { + directory = "$sharedRootDir/workspace/build-cache" + } + } +} + +rootProject.name='springboot-java-11-smoketest' diff --git a/dd-smoke-tests/springboot-java-11/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java b/dd-smoke-tests/springboot-java-11/application/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java similarity index 100% rename from dd-smoke-tests/springboot-java-11/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java rename to dd-smoke-tests/springboot-java-11/application/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java diff --git a/dd-smoke-tests/springboot-java-11/build.gradle b/dd-smoke-tests/springboot-java-11/build.gradle index 029df98dbd8..3112f00c049 100644 --- a/dd-smoke-tests/springboot-java-11/build.gradle +++ b/dd-smoke-tests/springboot-java-11/build.gradle @@ -1,42 +1,66 @@ -import org.springframework.boot.gradle.tasks.bundling.BootJar - -plugins { - id 'java' - id 'org.springframework.boot' version '2.7.15' - id 'io.spring.dependency-management' version '1.0.15.RELEASE' - id 'java-test-fixtures' -} - apply from: "$rootDir/gradle/java.gradle" +apply plugin: 'java-test-fixtures' + testJvmConstraints { minJavaVersion = JavaVersion.VERSION_11 } -apply from: "$rootDir/gradle/spring-boot-plugin.gradle" description = 'SpringBoot Java 11 Smoke Tests.' -dependencies { - implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.2.0.RELEASE' +def appDir = "$projectDir/application" +def appBuildDir = "$buildDir/application" +def isWindows = System.getProperty("os.name").toLowerCase().contains("win") +def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew' - testImplementation project(':dd-smoke-tests') - testImplementation testFixtures(project(":dd-smoke-tests:iast-util:iast-util-11")) - testImplementation testFixtures(project(':dd-smoke-tests:iast-util')) +tasks.register('bootJar', Exec) { + workingDir appDir + environment += [ + "GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'", + "JAVA_HOME": getLazyJavaHomeFor(11) + ] + commandLine "$appDir/${gradlewCommand}", "bootJar", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", + "-PiastUtil11Jar=${project(':dd-smoke-tests:iast-util:iast-util-11').tasks.jar.archiveFile.get()}" + + outputs.cacheIf { true } + + outputs.dir(appBuildDir) + .withPropertyName("applicationJar") - implementation project(':dd-smoke-tests:iast-util:iast-util-11') + inputs.files(fileTree(appDir) { + include '**/*' + exclude '.gradle/**' + }) + .withPropertyName("application") + .withPathSensitivity(PathSensitivity.RELATIVE) } -tasks.named("compileJava", JavaCompile) { - configureCompiler(it, 11, JavaVersion.VERSION_11) +tasks.named('bootJar', Exec) { + dependsOn project(':dd-smoke-tests:iast-util:iast-util-11').tasks.named('jar') +} + +dependencies { + testImplementation project(':dd-smoke-tests') + testImplementation testFixtures(project(":dd-smoke-tests:iast-util:iast-util-11")) + testImplementation testFixtures(project(':dd-smoke-tests:iast-util')) } tasks.withType(Test).configureEach { - dependsOn "bootJar" - def bootJarTask = tasks.named('bootJar', BootJar) + dependsOn 'bootJar' jvmArgumentProviders.add(new CommandLineArgumentProvider() { @Override Iterable asArguments() { - return bootJarTask.map { ["-Ddatadog.smoketest.springboot.shadowJar.path=${it.archiveFile.get()}"] }.get() + return ["-Ddatadog.smoketest.springboot.shadowJar.path=$appBuildDir/libs/springboot-java-11-smoketest.jar"] } }) } + +spotless { + java { + target "**/*.java" + } + + groovyGradle { + target '*.gradle', "**/*.gradle" + } +} diff --git a/dd-smoke-tests/springboot-java-17/application/build.gradle b/dd-smoke-tests/springboot-java-17/application/build.gradle new file mode 100644 index 00000000000..413f24ce06d --- /dev/null +++ b/dd-smoke-tests/springboot-java-17/application/build.gradle @@ -0,0 +1,31 @@ +plugins { + id 'java' + id 'org.springframework.boot' version '2.7.15' + id 'io.spring.dependency-management' version '1.0.15.RELEASE' +} + +def sharedRootDir = "$rootDir/../../../" +def sharedConfigDirectory = "$sharedRootDir/gradle" +rootProject.ext.sharedConfigDirectory = sharedConfigDirectory + +apply from: "$sharedConfigDirectory/repositories.gradle" + +if (hasProperty('appBuildDir')) { + buildDir = property('appBuildDir') +} + +version = "" + +java { + sourceCompatibility = 17 +} + +if (hasProperty('iastUtil17Jar')) { + dependencies { + implementation files(property('iastUtil17Jar')) + } +} + +dependencies { + implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.2.0.RELEASE' +} diff --git a/dd-smoke-tests/springboot-java-17/application/gradle/wrapper/gradle-wrapper.jar b/dd-smoke-tests/springboot-java-17/application/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000000..e708b1c023e Binary files /dev/null and b/dd-smoke-tests/springboot-java-17/application/gradle/wrapper/gradle-wrapper.jar differ diff --git a/dd-smoke-tests/springboot-java-17/application/gradle/wrapper/gradle-wrapper.properties b/dd-smoke-tests/springboot-java-17/application/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000000..a4cf193f638 --- /dev/null +++ b/dd-smoke-tests/springboot-java-17/application/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,8 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionSha256Sum=6f74b601422d6d6fc4e1f9a1ab6522f642c2fdcbc15ae33ebd30ba3d7198e854 +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.5-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/dd-smoke-tests/springboot-java-17/application/gradlew b/dd-smoke-tests/springboot-java-17/application/gradlew new file mode 100755 index 00000000000..965aff38453 --- /dev/null +++ b/dd-smoke-tests/springboot-java-17/application/gradlew @@ -0,0 +1,183 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## 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='"-Xmx64m" "-Xms64m"' + +# 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 or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; 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=`expr $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" + +exec "$JAVACMD" "$@" diff --git a/dd-smoke-tests/springboot-java-17/application/gradlew.bat b/dd-smoke-tests/springboot-java-17/application/gradlew.bat new file mode 100644 index 00000000000..107acd32c4e --- /dev/null +++ b/dd-smoke-tests/springboot-java-17/application/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@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 Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@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="-Xmx64m" "-Xms64m" + +@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 execute + +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 execute + +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 + +: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 %* + +: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 diff --git a/dd-smoke-tests/springboot-java-17/application/settings.gradle b/dd-smoke-tests/springboot-java-17/application/settings.gradle new file mode 100644 index 00000000000..e0193c924d2 --- /dev/null +++ b/dd-smoke-tests/springboot-java-17/application/settings.gradle @@ -0,0 +1,32 @@ +pluginManagement { + repositories { + mavenLocal() + if (settings.hasProperty("gradlePluginProxy")) { + maven { + url settings["gradlePluginProxy"] + allowInsecureProtocol = true + } + } + if (settings.hasProperty("mavenRepositoryProxy")) { + maven { + url settings["mavenRepositoryProxy"] + allowInsecureProtocol = true + } + } + gradlePluginPortal() + mavenCentral() + } +} + +def isCI = providers.environmentVariable("CI").isPresent() + +if (isCI) { + def sharedRootDir = "$rootDir/../../../" + buildCache { + local { + directory = "$sharedRootDir/workspace/build-cache" + } + } +} + +rootProject.name='springboot-java-17-smoketest' diff --git a/dd-smoke-tests/springboot-java-17/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java b/dd-smoke-tests/springboot-java-17/application/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java similarity index 100% rename from dd-smoke-tests/springboot-java-17/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java rename to dd-smoke-tests/springboot-java-17/application/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java diff --git a/dd-smoke-tests/springboot-java-17/build.gradle b/dd-smoke-tests/springboot-java-17/build.gradle index cb878a92c7f..8db22c06133 100644 --- a/dd-smoke-tests/springboot-java-17/build.gradle +++ b/dd-smoke-tests/springboot-java-17/build.gradle @@ -1,42 +1,66 @@ -import org.springframework.boot.gradle.tasks.bundling.BootJar - -plugins { - id 'java' - id 'org.springframework.boot' version '2.7.15' - id 'io.spring.dependency-management' version '1.0.15.RELEASE' - id 'java-test-fixtures' -} - apply from: "$rootDir/gradle/java.gradle" +apply plugin: 'java-test-fixtures' + testJvmConstraints { minJavaVersion = JavaVersion.VERSION_17 } -apply from: "$rootDir/gradle/spring-boot-plugin.gradle" description = 'SpringBoot Java 17 Smoke Tests.' -dependencies { - implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.2.0.RELEASE' +def appDir = "$projectDir/application" +def appBuildDir = "$buildDir/application" +def isWindows = System.getProperty("os.name").toLowerCase().contains("win") +def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew' - testImplementation project(':dd-smoke-tests') - testImplementation testFixtures(project(":dd-smoke-tests:iast-util:iast-util-17")) - testImplementation testFixtures(project(':dd-smoke-tests:iast-util')) +tasks.register('bootJar', Exec) { + workingDir appDir + environment += [ + "GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'", + "JAVA_HOME": getLazyJavaHomeFor(17) + ] + commandLine "$appDir/${gradlewCommand}", "bootJar", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir", + "-PiastUtil17Jar=${project(':dd-smoke-tests:iast-util:iast-util-17').tasks.jar.archiveFile.get()}" + + outputs.cacheIf { true } + + outputs.dir(appBuildDir) + .withPropertyName("applicationJar") - implementation project(':dd-smoke-tests:iast-util:iast-util-17') + inputs.files(fileTree(appDir) { + include '**/*' + exclude '.gradle/**' + }) + .withPropertyName("application") + .withPathSensitivity(PathSensitivity.RELATIVE) } -tasks.named("compileJava", JavaCompile) { - configureCompiler(it, 17, JavaVersion.VERSION_17) +tasks.named('bootJar', Exec) { + dependsOn project(':dd-smoke-tests:iast-util:iast-util-17').tasks.named('jar') +} + +dependencies { + testImplementation project(':dd-smoke-tests') + testImplementation testFixtures(project(":dd-smoke-tests:iast-util:iast-util-17")) + testImplementation testFixtures(project(':dd-smoke-tests:iast-util')) } tasks.withType(Test).configureEach { - dependsOn "bootJar" - def bootJarTask = tasks.named('bootJar', BootJar) + dependsOn 'bootJar' jvmArgumentProviders.add(new CommandLineArgumentProvider() { @Override Iterable asArguments() { - return bootJarTask.map { ["-Ddatadog.smoketest.springboot.shadowJar.path=${it.archiveFile.get()}"] }.get() + return ["-Ddatadog.smoketest.springboot.shadowJar.path=$appBuildDir/libs/springboot-java-17-smoketest.jar"] } }) } + +spotless { + java { + target "**/*.java" + } + + groovyGradle { + target '*.gradle', "**/*.gradle" + } +} diff --git a/dd-smoke-tests/springboot-jetty-jsp/application/build.gradle b/dd-smoke-tests/springboot-jetty-jsp/application/build.gradle new file mode 100644 index 00000000000..4c68c426f93 --- /dev/null +++ b/dd-smoke-tests/springboot-jetty-jsp/application/build.gradle @@ -0,0 +1,37 @@ +plugins { + id 'java' + id 'war' + id 'org.springframework.boot' version '2.7.15' + id 'io.spring.dependency-management' version '1.0.15.RELEASE' +} + +def sharedRootDir = "$rootDir/../../../" +def sharedConfigDirectory = "$sharedRootDir/gradle" +rootProject.ext.sharedConfigDirectory = sharedConfigDirectory + +apply from: "$sharedConfigDirectory/repositories.gradle" + +if (hasProperty('appBuildDir')) { + buildDir = property('appBuildDir') +} + +version = "" + +java { + sourceCompatibility = '1.8' +} + +sourceSets { + main { + resources.srcDir("src/main/webapp") + } +} + +dependencies { + implementation 'org.springframework.boot:spring-boot-starter-web' + + runtimeOnly("javax.servlet:jstl") + runtimeOnly("org.apache.tomcat.embed:tomcat-embed-jasper") + + providedRuntime("org.springframework.boot:spring-boot-starter-jetty") +} diff --git a/dd-smoke-tests/springboot-jetty-jsp/application/gradle/wrapper/gradle-wrapper.jar b/dd-smoke-tests/springboot-jetty-jsp/application/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000000..e708b1c023e Binary files /dev/null and b/dd-smoke-tests/springboot-jetty-jsp/application/gradle/wrapper/gradle-wrapper.jar differ diff --git a/dd-smoke-tests/springboot-jetty-jsp/application/gradle/wrapper/gradle-wrapper.properties b/dd-smoke-tests/springboot-jetty-jsp/application/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000000..a4cf193f638 --- /dev/null +++ b/dd-smoke-tests/springboot-jetty-jsp/application/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,8 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionSha256Sum=6f74b601422d6d6fc4e1f9a1ab6522f642c2fdcbc15ae33ebd30ba3d7198e854 +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.5-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/dd-smoke-tests/springboot-jetty-jsp/application/gradlew b/dd-smoke-tests/springboot-jetty-jsp/application/gradlew new file mode 100755 index 00000000000..965aff38453 --- /dev/null +++ b/dd-smoke-tests/springboot-jetty-jsp/application/gradlew @@ -0,0 +1,183 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## 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='"-Xmx64m" "-Xms64m"' + +# 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 or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; 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=`expr $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" + +exec "$JAVACMD" "$@" diff --git a/dd-smoke-tests/springboot-jetty-jsp/application/gradlew.bat b/dd-smoke-tests/springboot-jetty-jsp/application/gradlew.bat new file mode 100644 index 00000000000..107acd32c4e --- /dev/null +++ b/dd-smoke-tests/springboot-jetty-jsp/application/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@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 Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@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="-Xmx64m" "-Xms64m" + +@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 execute + +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 execute + +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 + +: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 %* + +: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 diff --git a/dd-smoke-tests/springboot-jetty-jsp/application/settings.gradle b/dd-smoke-tests/springboot-jetty-jsp/application/settings.gradle new file mode 100644 index 00000000000..a2890a26aa3 --- /dev/null +++ b/dd-smoke-tests/springboot-jetty-jsp/application/settings.gradle @@ -0,0 +1,32 @@ +pluginManagement { + repositories { + mavenLocal() + if (settings.hasProperty("gradlePluginProxy")) { + maven { + url settings["gradlePluginProxy"] + allowInsecureProtocol = true + } + } + if (settings.hasProperty("mavenRepositoryProxy")) { + maven { + url settings["mavenRepositoryProxy"] + allowInsecureProtocol = true + } + } + gradlePluginPortal() + mavenCentral() + } +} + +def isCI = providers.environmentVariable("CI").isPresent() + +if (isCI) { + def sharedRootDir = "$rootDir/../../../" + buildCache { + local { + directory = "$sharedRootDir/workspace/build-cache" + } + } +} + +rootProject.name='springboot-jetty-jsp-smoketest' diff --git a/dd-smoke-tests/springboot-jetty-jsp/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java b/dd-smoke-tests/springboot-jetty-jsp/application/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java similarity index 100% rename from dd-smoke-tests/springboot-jetty-jsp/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java rename to dd-smoke-tests/springboot-jetty-jsp/application/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java diff --git a/dd-smoke-tests/springboot-jetty-jsp/src/main/java/datadog/smoketest/springboot/ViewController.java b/dd-smoke-tests/springboot-jetty-jsp/application/src/main/java/datadog/smoketest/springboot/ViewController.java similarity index 100% rename from dd-smoke-tests/springboot-jetty-jsp/src/main/java/datadog/smoketest/springboot/ViewController.java rename to dd-smoke-tests/springboot-jetty-jsp/application/src/main/java/datadog/smoketest/springboot/ViewController.java diff --git a/dd-smoke-tests/springboot-jetty-jsp/src/main/resources/application.properties b/dd-smoke-tests/springboot-jetty-jsp/application/src/main/resources/application.properties similarity index 100% rename from dd-smoke-tests/springboot-jetty-jsp/src/main/resources/application.properties rename to dd-smoke-tests/springboot-jetty-jsp/application/src/main/resources/application.properties diff --git a/dd-smoke-tests/springboot-jetty-jsp/src/main/webapp/WEB-INF/jsp/test_xss.jsp b/dd-smoke-tests/springboot-jetty-jsp/application/src/main/webapp/WEB-INF/jsp/test_xss.jsp similarity index 100% rename from dd-smoke-tests/springboot-jetty-jsp/src/main/webapp/WEB-INF/jsp/test_xss.jsp rename to dd-smoke-tests/springboot-jetty-jsp/application/src/main/webapp/WEB-INF/jsp/test_xss.jsp diff --git a/dd-smoke-tests/springboot-jetty-jsp/build.gradle b/dd-smoke-tests/springboot-jetty-jsp/build.gradle index d8fdc4fbab4..612fbba25e6 100644 --- a/dd-smoke-tests/springboot-jetty-jsp/build.gradle +++ b/dd-smoke-tests/springboot-jetty-jsp/build.gradle @@ -1,47 +1,56 @@ -import org.springframework.boot.gradle.tasks.bundling.BootWar - -plugins { - id 'java' - id 'war' - id 'org.springframework.boot' version '2.7.15' - id 'io.spring.dependency-management' version '1.0.15.RELEASE' - id 'java-test-fixtures' -} - apply from: "$rootDir/gradle/java.gradle" -apply from: "$rootDir/gradle/spring-boot-plugin.gradle" -description = 'SpringBoot Jetty JSP Smoke Tests.' -java { - sourceCompatibility = '1.8' -} +apply plugin: 'java-test-fixtures' -sourceSets { - main { - resources.srcDir("src/main/webapp") - } +description = 'SpringBoot Jetty JSP Smoke Tests.' + +def appDir = "$projectDir/application" +def appBuildDir = "$buildDir/application" +def isWindows = System.getProperty("os.name").toLowerCase().contains("win") +def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew' + +tasks.register('bootWar', Exec) { + workingDir appDir + environment += [ + "GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'", + "JAVA_HOME": getLazyJavaHomeFor(8) + ] + commandLine "$appDir/${gradlewCommand}", "war", "bootWar", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir" + + outputs.cacheIf { true } + + outputs.dir(appBuildDir) + .withPropertyName("applicationWar") + + inputs.files(fileTree(appDir) { + include '**/*' + exclude '.gradle/**' + }) + .withPropertyName("application") + .withPathSensitivity(PathSensitivity.RELATIVE) } dependencies { - implementation 'org.springframework.boot:spring-boot-starter-web' - - runtimeOnly("javax.servlet:jstl") - runtimeOnly("org.apache.tomcat.embed:tomcat-embed-jasper") - - providedRuntime("org.springframework.boot:spring-boot-starter-jetty") - testImplementation project(':dd-smoke-tests') testImplementation(testFixtures(project(":dd-smoke-tests:iast-util"))) } tasks.withType(Test).configureEach { - dependsOn "war", "bootWar" - + dependsOn 'bootWar' jvmArgumentProviders.add(new CommandLineArgumentProvider() { @Override Iterable asArguments() { - def bootWarTask = tasks.named('bootWar', BootWar).get() - return ["-Ddatadog.smoketest.springboot.war.path=${bootWarTask.archiveFile.get().getAsFile()}"] + return ["-Ddatadog.smoketest.springboot.war.path=$appBuildDir/libs/springboot-jetty-jsp-smoketest.war"] } }) } + +spotless { + java { + target "**/*.java" + } + + groovyGradle { + target '*.gradle', "**/*.gradle" + } +} diff --git a/dd-smoke-tests/springboot-jpa/application/build.gradle b/dd-smoke-tests/springboot-jpa/application/build.gradle new file mode 100644 index 00000000000..a38bb884c1d --- /dev/null +++ b/dd-smoke-tests/springboot-jpa/application/build.gradle @@ -0,0 +1,30 @@ +plugins { + id 'java' + id 'war' + id 'org.springframework.boot' version '2.6.0' +} + +apply plugin: 'io.spring.dependency-management' + +def sharedRootDir = "$rootDir/../../../" +def sharedConfigDirectory = "$sharedRootDir/gradle" +rootProject.ext.sharedConfigDirectory = sharedConfigDirectory + +apply from: "$sharedConfigDirectory/repositories.gradle" + +if (hasProperty('appBuildDir')) { + buildDir = property('appBuildDir') +} + +version = "" + +dependencies { + implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + implementation 'org.apache.tomcat.embed:tomcat-embed-jasper' + implementation 'javax.servlet:jstl:1.2' + implementation 'com.h2database:h2:2.1.214' + + compileOnly 'org.projectlombok:lombok:1.18.34' + annotationProcessor 'org.projectlombok:lombok:1.18.34' +} diff --git a/dd-smoke-tests/springboot-jpa/application/gradle/wrapper/gradle-wrapper.jar b/dd-smoke-tests/springboot-jpa/application/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000000..e708b1c023e Binary files /dev/null and b/dd-smoke-tests/springboot-jpa/application/gradle/wrapper/gradle-wrapper.jar differ diff --git a/dd-smoke-tests/springboot-jpa/application/gradle/wrapper/gradle-wrapper.properties b/dd-smoke-tests/springboot-jpa/application/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000000..a4cf193f638 --- /dev/null +++ b/dd-smoke-tests/springboot-jpa/application/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,8 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionSha256Sum=6f74b601422d6d6fc4e1f9a1ab6522f642c2fdcbc15ae33ebd30ba3d7198e854 +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.5-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/dd-smoke-tests/springboot-jpa/application/gradlew b/dd-smoke-tests/springboot-jpa/application/gradlew new file mode 100755 index 00000000000..965aff38453 --- /dev/null +++ b/dd-smoke-tests/springboot-jpa/application/gradlew @@ -0,0 +1,183 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## 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='"-Xmx64m" "-Xms64m"' + +# 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 or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; 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=`expr $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" + +exec "$JAVACMD" "$@" diff --git a/dd-smoke-tests/springboot-jpa/application/gradlew.bat b/dd-smoke-tests/springboot-jpa/application/gradlew.bat new file mode 100644 index 00000000000..107acd32c4e --- /dev/null +++ b/dd-smoke-tests/springboot-jpa/application/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@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 Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@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="-Xmx64m" "-Xms64m" + +@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 execute + +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 execute + +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 + +: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 %* + +: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 diff --git a/dd-smoke-tests/springboot-jpa/application/settings.gradle b/dd-smoke-tests/springboot-jpa/application/settings.gradle new file mode 100644 index 00000000000..6ba5b1b29bb --- /dev/null +++ b/dd-smoke-tests/springboot-jpa/application/settings.gradle @@ -0,0 +1,32 @@ +pluginManagement { + repositories { + mavenLocal() + if (settings.hasProperty("gradlePluginProxy")) { + maven { + url settings["gradlePluginProxy"] + allowInsecureProtocol = true + } + } + if (settings.hasProperty("mavenRepositoryProxy")) { + maven { + url settings["mavenRepositoryProxy"] + allowInsecureProtocol = true + } + } + gradlePluginPortal() + mavenCentral() + } +} + +def isCI = providers.environmentVariable("CI").isPresent() + +if (isCI) { + def sharedRootDir = "$rootDir/../../../" + buildCache { + local { + directory = "$sharedRootDir/workspace/build-cache" + } + } +} + +rootProject.name='springboot-jpa-smoketest' diff --git a/dd-smoke-tests/springboot-jpa/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java b/dd-smoke-tests/springboot-jpa/application/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java similarity index 100% rename from dd-smoke-tests/springboot-jpa/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java rename to dd-smoke-tests/springboot-jpa/application/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java diff --git a/dd-smoke-tests/springboot-jpa/src/main/java/datadog/smoketest/springboot/controller/LibraryController.java b/dd-smoke-tests/springboot-jpa/application/src/main/java/datadog/smoketest/springboot/controller/LibraryController.java similarity index 100% rename from dd-smoke-tests/springboot-jpa/src/main/java/datadog/smoketest/springboot/controller/LibraryController.java rename to dd-smoke-tests/springboot-jpa/application/src/main/java/datadog/smoketest/springboot/controller/LibraryController.java diff --git a/dd-smoke-tests/springboot-jpa/src/main/java/datadog/smoketest/springboot/entity/Author.java b/dd-smoke-tests/springboot-jpa/application/src/main/java/datadog/smoketest/springboot/entity/Author.java similarity index 100% rename from dd-smoke-tests/springboot-jpa/src/main/java/datadog/smoketest/springboot/entity/Author.java rename to dd-smoke-tests/springboot-jpa/application/src/main/java/datadog/smoketest/springboot/entity/Author.java diff --git a/dd-smoke-tests/springboot-jpa/src/main/java/datadog/smoketest/springboot/entity/Book.java b/dd-smoke-tests/springboot-jpa/application/src/main/java/datadog/smoketest/springboot/entity/Book.java similarity index 100% rename from dd-smoke-tests/springboot-jpa/src/main/java/datadog/smoketest/springboot/entity/Book.java rename to dd-smoke-tests/springboot-jpa/application/src/main/java/datadog/smoketest/springboot/entity/Book.java diff --git a/dd-smoke-tests/springboot-jpa/src/main/java/datadog/smoketest/springboot/entity/Library.java b/dd-smoke-tests/springboot-jpa/application/src/main/java/datadog/smoketest/springboot/entity/Library.java similarity index 100% rename from dd-smoke-tests/springboot-jpa/src/main/java/datadog/smoketest/springboot/entity/Library.java rename to dd-smoke-tests/springboot-jpa/application/src/main/java/datadog/smoketest/springboot/entity/Library.java diff --git a/dd-smoke-tests/springboot-jpa/src/main/java/datadog/smoketest/springboot/entity/Owner.java b/dd-smoke-tests/springboot-jpa/application/src/main/java/datadog/smoketest/springboot/entity/Owner.java similarity index 100% rename from dd-smoke-tests/springboot-jpa/src/main/java/datadog/smoketest/springboot/entity/Owner.java rename to dd-smoke-tests/springboot-jpa/application/src/main/java/datadog/smoketest/springboot/entity/Owner.java diff --git a/dd-smoke-tests/springboot-jpa/src/main/java/datadog/smoketest/springboot/filter/SessionVisitorFilter.java b/dd-smoke-tests/springboot-jpa/application/src/main/java/datadog/smoketest/springboot/filter/SessionVisitorFilter.java similarity index 100% rename from dd-smoke-tests/springboot-jpa/src/main/java/datadog/smoketest/springboot/filter/SessionVisitorFilter.java rename to dd-smoke-tests/springboot-jpa/application/src/main/java/datadog/smoketest/springboot/filter/SessionVisitorFilter.java diff --git a/dd-smoke-tests/springboot-jpa/src/main/java/datadog/smoketest/springboot/service/LibraryService.java b/dd-smoke-tests/springboot-jpa/application/src/main/java/datadog/smoketest/springboot/service/LibraryService.java similarity index 100% rename from dd-smoke-tests/springboot-jpa/src/main/java/datadog/smoketest/springboot/service/LibraryService.java rename to dd-smoke-tests/springboot-jpa/application/src/main/java/datadog/smoketest/springboot/service/LibraryService.java diff --git a/dd-smoke-tests/springboot-jpa/src/main/resources/application.yml b/dd-smoke-tests/springboot-jpa/application/src/main/resources/application.yml similarity index 100% rename from dd-smoke-tests/springboot-jpa/src/main/resources/application.yml rename to dd-smoke-tests/springboot-jpa/application/src/main/resources/application.yml diff --git a/dd-smoke-tests/springboot-jpa/src/main/webapp/WEB-INF/jsp/update.jsp b/dd-smoke-tests/springboot-jpa/application/src/main/webapp/WEB-INF/jsp/update.jsp similarity index 100% rename from dd-smoke-tests/springboot-jpa/src/main/webapp/WEB-INF/jsp/update.jsp rename to dd-smoke-tests/springboot-jpa/application/src/main/webapp/WEB-INF/jsp/update.jsp diff --git a/dd-smoke-tests/springboot-jpa/build.gradle b/dd-smoke-tests/springboot-jpa/build.gradle index af9c22ff235..6c2470801cb 100644 --- a/dd-smoke-tests/springboot-jpa/build.gradle +++ b/dd-smoke-tests/springboot-jpa/build.gradle @@ -1,40 +1,43 @@ -import org.springframework.boot.gradle.tasks.bundling.BootWar - -plugins { - id 'java' - id 'war' - id 'org.springframework.boot' version '2.6.0' -} - -apply plugin: 'io.spring.dependency-management' apply from: "$rootDir/gradle/java.gradle" -apply from: "$rootDir/gradle/spring-boot-plugin.gradle" + description = 'SpringBoot JPA Smoke Tests.' -dependencies { - implementation 'org.springframework.boot:spring-boot-starter-web' - implementation 'org.springframework.boot:spring-boot-starter-data-jpa' - implementation 'org.apache.tomcat.embed:tomcat-embed-jasper' - implementation 'javax.servlet:jstl:1.2' - implementation 'com.h2database:h2:2.1.214' +def appDir = "$projectDir/application" +def appBuildDir = "$buildDir/application" +def isWindows = System.getProperty("os.name").toLowerCase().contains("win") +def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew' + +tasks.register('bootWar', Exec) { + workingDir appDir + environment += [ + "GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'", + "JAVA_HOME": getLazyJavaHomeFor(8) + ] + commandLine "$appDir/${gradlewCommand}", "bootWar", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir" + + outputs.cacheIf { true } + + outputs.dir(appBuildDir) + .withPropertyName("applicationWar") + + inputs.files(fileTree(appDir) { + include '**/*' + exclude '.gradle/**' + }) + .withPropertyName("application") + .withPathSensitivity(PathSensitivity.RELATIVE) +} +dependencies { testImplementation project(':dd-smoke-tests') - - compileOnly 'org.projectlombok:lombok:1.18.34' - annotationProcessor 'org.projectlombok:lombok:1.18.34' - - testCompileOnly 'org.projectlombok:lombok:1.18.34' - testAnnotationProcessor 'org.projectlombok:lombok:1.18.34' } tasks.withType(Test).configureEach { - dependsOn "bootWar" - + dependsOn 'bootWar' jvmArgumentProviders.add(new CommandLineArgumentProvider() { @Override Iterable asArguments() { - def bootWarTask = tasks.named('bootWar', BootWar).get() - return ["-Ddatadog.smoketest.springboot.bootWar.path=${bootWarTask.archiveFile.get()}"] + return ["-Ddatadog.smoketest.springboot.bootWar.path=$appBuildDir/libs/springboot-jpa-smoketest.war"] } }) } @@ -42,3 +45,13 @@ tasks.withType(Test).configureEach { tasks.withType(GroovyCompile).configureEach { configureCompiler(it, 8) } + +spotless { + java { + target "**/*.java" + } + + groovyGradle { + target '*.gradle', "**/*.gradle" + } +} diff --git a/dd-smoke-tests/springboot-thymeleaf/application/build.gradle b/dd-smoke-tests/springboot-thymeleaf/application/build.gradle new file mode 100644 index 00000000000..77f8e57d848 --- /dev/null +++ b/dd-smoke-tests/springboot-thymeleaf/application/build.gradle @@ -0,0 +1,26 @@ +plugins { + id 'java' + id 'org.springframework.boot' version '2.7.15' + id 'io.spring.dependency-management' version '1.0.15.RELEASE' +} + +def sharedRootDir = "$rootDir/../../../" +def sharedConfigDirectory = "$sharedRootDir/gradle" +rootProject.ext.sharedConfigDirectory = sharedConfigDirectory + +apply from: "$sharedConfigDirectory/repositories.gradle" + +if (hasProperty('appBuildDir')) { + buildDir = property('appBuildDir') +} + +version = "" + +java { + sourceCompatibility = '1.8' +} + +dependencies { + implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' +} diff --git a/dd-smoke-tests/springboot-thymeleaf/application/gradle/wrapper/gradle-wrapper.jar b/dd-smoke-tests/springboot-thymeleaf/application/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000000..e708b1c023e Binary files /dev/null and b/dd-smoke-tests/springboot-thymeleaf/application/gradle/wrapper/gradle-wrapper.jar differ diff --git a/dd-smoke-tests/springboot-thymeleaf/application/gradle/wrapper/gradle-wrapper.properties b/dd-smoke-tests/springboot-thymeleaf/application/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000000..a4cf193f638 --- /dev/null +++ b/dd-smoke-tests/springboot-thymeleaf/application/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,8 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionSha256Sum=6f74b601422d6d6fc4e1f9a1ab6522f642c2fdcbc15ae33ebd30ba3d7198e854 +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.5-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/dd-smoke-tests/springboot-thymeleaf/application/gradlew b/dd-smoke-tests/springboot-thymeleaf/application/gradlew new file mode 100755 index 00000000000..965aff38453 --- /dev/null +++ b/dd-smoke-tests/springboot-thymeleaf/application/gradlew @@ -0,0 +1,183 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## 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='"-Xmx64m" "-Xms64m"' + +# 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 or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; 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=`expr $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" + +exec "$JAVACMD" "$@" diff --git a/dd-smoke-tests/springboot-thymeleaf/application/gradlew.bat b/dd-smoke-tests/springboot-thymeleaf/application/gradlew.bat new file mode 100644 index 00000000000..107acd32c4e --- /dev/null +++ b/dd-smoke-tests/springboot-thymeleaf/application/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@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 Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@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="-Xmx64m" "-Xms64m" + +@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 execute + +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 execute + +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 + +: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 %* + +: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 diff --git a/dd-smoke-tests/springboot-thymeleaf/application/settings.gradle b/dd-smoke-tests/springboot-thymeleaf/application/settings.gradle new file mode 100644 index 00000000000..ab2f4d42f90 --- /dev/null +++ b/dd-smoke-tests/springboot-thymeleaf/application/settings.gradle @@ -0,0 +1,32 @@ +pluginManagement { + repositories { + mavenLocal() + if (settings.hasProperty("gradlePluginProxy")) { + maven { + url settings["gradlePluginProxy"] + allowInsecureProtocol = true + } + } + if (settings.hasProperty("mavenRepositoryProxy")) { + maven { + url settings["mavenRepositoryProxy"] + allowInsecureProtocol = true + } + } + gradlePluginPortal() + mavenCentral() + } +} + +def isCI = providers.environmentVariable("CI").isPresent() + +if (isCI) { + def sharedRootDir = "$rootDir/../../../" + buildCache { + local { + directory = "$sharedRootDir/workspace/build-cache" + } + } +} + +rootProject.name='springboot-thymeleaf-smoketest' diff --git a/dd-smoke-tests/springboot-thymeleaf/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java b/dd-smoke-tests/springboot-thymeleaf/application/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java similarity index 100% rename from dd-smoke-tests/springboot-thymeleaf/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java rename to dd-smoke-tests/springboot-thymeleaf/application/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java diff --git a/dd-smoke-tests/springboot-thymeleaf/src/main/java/datadog/smoketest/springboot/XssController.java b/dd-smoke-tests/springboot-thymeleaf/application/src/main/java/datadog/smoketest/springboot/XssController.java similarity index 100% rename from dd-smoke-tests/springboot-thymeleaf/src/main/java/datadog/smoketest/springboot/XssController.java rename to dd-smoke-tests/springboot-thymeleaf/application/src/main/java/datadog/smoketest/springboot/XssController.java diff --git a/dd-smoke-tests/springboot-thymeleaf/src/main/resources/templates/utext.html b/dd-smoke-tests/springboot-thymeleaf/application/src/main/resources/templates/utext.html similarity index 100% rename from dd-smoke-tests/springboot-thymeleaf/src/main/resources/templates/utext.html rename to dd-smoke-tests/springboot-thymeleaf/application/src/main/resources/templates/utext.html diff --git a/dd-smoke-tests/springboot-thymeleaf/build.gradle b/dd-smoke-tests/springboot-thymeleaf/build.gradle index 7de0a0833e5..0389460b668 100644 --- a/dd-smoke-tests/springboot-thymeleaf/build.gradle +++ b/dd-smoke-tests/springboot-thymeleaf/build.gradle @@ -1,35 +1,58 @@ -import org.springframework.boot.gradle.tasks.bundling.BootJar +apply from: "$rootDir/gradle/java.gradle" -plugins { - id 'java' - id 'org.springframework.boot' version '2.7.15' - id 'io.spring.dependency-management' version '1.0.15.RELEASE' - id 'java-test-fixtures' -} +apply plugin: 'java-test-fixtures' -apply from: "$rootDir/gradle/java.gradle" -apply from: "$rootDir/gradle/spring-boot-plugin.gradle" description = 'SpringBoot thymeleaf 3 Smoke Tests.' -java { - sourceCompatibility = '1.8' +def appDir = "$projectDir/application" +def appBuildDir = "$buildDir/application" +def isWindows = System.getProperty("os.name").toLowerCase().contains("win") +def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew' + +tasks.register('bootJar', Exec) { + workingDir appDir + environment += [ + "GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'", + "JAVA_HOME": getLazyJavaHomeFor(8) + ] + commandLine "$appDir/${gradlewCommand}", "bootJar", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir" + + outputs.cacheIf { true } + + outputs.dir(appBuildDir) + .withPropertyName("applicationJar") + + inputs.files(fileTree(appDir) { + include '**/*' + exclude '.gradle/**' + }) + .withPropertyName("application") + .withPathSensitivity(PathSensitivity.RELATIVE) } dependencies { - implementation 'org.springframework.boot:spring-boot-starter-web' - implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' - testImplementation project(':dd-smoke-tests') testImplementation(testFixtures(project(":dd-smoke-tests:iast-util"))) } tasks.withType(Test).configureEach { - dependsOn "bootJar" - def bootJarTask = tasks.named('bootJar', BootJar) + dependsOn 'bootJar' jvmArgumentProviders.add(new CommandLineArgumentProvider() { @Override Iterable asArguments() { - return bootJarTask.map { ["-Ddatadog.smoketest.springboot.shadowJar.path=${it.archiveFile.get()}"] }.get() + return [ + "-Ddatadog.smoketest.springboot.shadowJar.path=$appBuildDir/libs/springboot-thymeleaf-smoketest.jar" + ] } }) } + +spotless { + java { + target "**/*.java" + } + + groovyGradle { + target '*.gradle', "**/*.gradle" + } +} diff --git a/dd-smoke-tests/springboot-tomcat-jsp/application/build.gradle b/dd-smoke-tests/springboot-tomcat-jsp/application/build.gradle new file mode 100644 index 00000000000..8632e7afc64 --- /dev/null +++ b/dd-smoke-tests/springboot-tomcat-jsp/application/build.gradle @@ -0,0 +1,37 @@ +plugins { + id 'java' + id 'war' + id 'org.springframework.boot' version '2.7.15' + id 'io.spring.dependency-management' version '1.0.15.RELEASE' +} + +def sharedRootDir = "$rootDir/../../../" +def sharedConfigDirectory = "$sharedRootDir/gradle" +rootProject.ext.sharedConfigDirectory = sharedConfigDirectory + +apply from: "$sharedConfigDirectory/repositories.gradle" + +if (hasProperty('appBuildDir')) { + buildDir = property('appBuildDir') +} + +version = "" + +java { + sourceCompatibility = '1.8' +} + +sourceSets { + main { + resources.srcDir("src/main/webapp") + } +} + +dependencies { + implementation 'org.springframework.boot:spring-boot-starter-web' + + runtimeOnly("javax.servlet:jstl") + runtimeOnly("org.apache.tomcat.embed:tomcat-embed-jasper") + + providedRuntime("org.springframework.boot:spring-boot-starter-tomcat") +} diff --git a/dd-smoke-tests/springboot-tomcat-jsp/application/gradle/wrapper/gradle-wrapper.jar b/dd-smoke-tests/springboot-tomcat-jsp/application/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000000..e708b1c023e Binary files /dev/null and b/dd-smoke-tests/springboot-tomcat-jsp/application/gradle/wrapper/gradle-wrapper.jar differ diff --git a/dd-smoke-tests/springboot-tomcat-jsp/application/gradle/wrapper/gradle-wrapper.properties b/dd-smoke-tests/springboot-tomcat-jsp/application/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000000..a4cf193f638 --- /dev/null +++ b/dd-smoke-tests/springboot-tomcat-jsp/application/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,8 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionSha256Sum=6f74b601422d6d6fc4e1f9a1ab6522f642c2fdcbc15ae33ebd30ba3d7198e854 +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.5-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/dd-smoke-tests/springboot-tomcat-jsp/application/gradlew b/dd-smoke-tests/springboot-tomcat-jsp/application/gradlew new file mode 100755 index 00000000000..965aff38453 --- /dev/null +++ b/dd-smoke-tests/springboot-tomcat-jsp/application/gradlew @@ -0,0 +1,183 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## 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='"-Xmx64m" "-Xms64m"' + +# 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 or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; 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=`expr $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" + +exec "$JAVACMD" "$@" diff --git a/dd-smoke-tests/springboot-tomcat-jsp/application/gradlew.bat b/dd-smoke-tests/springboot-tomcat-jsp/application/gradlew.bat new file mode 100644 index 00000000000..107acd32c4e --- /dev/null +++ b/dd-smoke-tests/springboot-tomcat-jsp/application/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@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 Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@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="-Xmx64m" "-Xms64m" + +@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 execute + +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 execute + +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 + +: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 %* + +: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 diff --git a/dd-smoke-tests/springboot-tomcat-jsp/application/settings.gradle b/dd-smoke-tests/springboot-tomcat-jsp/application/settings.gradle new file mode 100644 index 00000000000..bb366810698 --- /dev/null +++ b/dd-smoke-tests/springboot-tomcat-jsp/application/settings.gradle @@ -0,0 +1,32 @@ +pluginManagement { + repositories { + mavenLocal() + if (settings.hasProperty("gradlePluginProxy")) { + maven { + url settings["gradlePluginProxy"] + allowInsecureProtocol = true + } + } + if (settings.hasProperty("mavenRepositoryProxy")) { + maven { + url settings["mavenRepositoryProxy"] + allowInsecureProtocol = true + } + } + gradlePluginPortal() + mavenCentral() + } +} + +def isCI = providers.environmentVariable("CI").isPresent() + +if (isCI) { + def sharedRootDir = "$rootDir/../../../" + buildCache { + local { + directory = "$sharedRootDir/workspace/build-cache" + } + } +} + +rootProject.name='springboot-tomcat-jsp-smoketest' diff --git a/dd-smoke-tests/springboot-tomcat-jsp/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java b/dd-smoke-tests/springboot-tomcat-jsp/application/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java similarity index 100% rename from dd-smoke-tests/springboot-tomcat-jsp/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java rename to dd-smoke-tests/springboot-tomcat-jsp/application/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java diff --git a/dd-smoke-tests/springboot-tomcat-jsp/src/main/java/datadog/smoketest/springboot/ViewController.java b/dd-smoke-tests/springboot-tomcat-jsp/application/src/main/java/datadog/smoketest/springboot/ViewController.java similarity index 100% rename from dd-smoke-tests/springboot-tomcat-jsp/src/main/java/datadog/smoketest/springboot/ViewController.java rename to dd-smoke-tests/springboot-tomcat-jsp/application/src/main/java/datadog/smoketest/springboot/ViewController.java diff --git a/dd-smoke-tests/springboot-tomcat-jsp/src/main/resources/application.properties b/dd-smoke-tests/springboot-tomcat-jsp/application/src/main/resources/application.properties similarity index 100% rename from dd-smoke-tests/springboot-tomcat-jsp/src/main/resources/application.properties rename to dd-smoke-tests/springboot-tomcat-jsp/application/src/main/resources/application.properties diff --git a/dd-smoke-tests/springboot-tomcat-jsp/src/main/webapp/WEB-INF/jsp/test_xss.jsp b/dd-smoke-tests/springboot-tomcat-jsp/application/src/main/webapp/WEB-INF/jsp/test_xss.jsp similarity index 100% rename from dd-smoke-tests/springboot-tomcat-jsp/src/main/webapp/WEB-INF/jsp/test_xss.jsp rename to dd-smoke-tests/springboot-tomcat-jsp/application/src/main/webapp/WEB-INF/jsp/test_xss.jsp diff --git a/dd-smoke-tests/springboot-tomcat-jsp/build.gradle b/dd-smoke-tests/springboot-tomcat-jsp/build.gradle index 224274ece2a..1e2af9ea717 100644 --- a/dd-smoke-tests/springboot-tomcat-jsp/build.gradle +++ b/dd-smoke-tests/springboot-tomcat-jsp/build.gradle @@ -1,47 +1,56 @@ -import org.springframework.boot.gradle.tasks.bundling.BootWar - -plugins { - id 'java' - id 'war' - id 'org.springframework.boot' version '2.7.15' - id 'io.spring.dependency-management' version '1.0.15.RELEASE' - id 'java-test-fixtures' -} - apply from: "$rootDir/gradle/java.gradle" -apply from: "$rootDir/gradle/spring-boot-plugin.gradle" -description = 'SpringBoot Tomcat JSP Smoke Tests.' -java { - sourceCompatibility = '1.8' -} +apply plugin: 'java-test-fixtures' -sourceSets { - main { - resources.srcDir("src/main/webapp") - } +description = 'SpringBoot Tomcat JSP Smoke Tests.' + +def appDir = "$projectDir/application" +def appBuildDir = "$buildDir/application" +def isWindows = System.getProperty("os.name").toLowerCase().contains("win") +def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew' + +tasks.register('bootWar', Exec) { + workingDir appDir + environment += [ + "GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'", + "JAVA_HOME": getLazyJavaHomeFor(8) + ] + commandLine "$appDir/${gradlewCommand}", "war", "bootWar", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir" + + outputs.cacheIf { true } + + outputs.dir(appBuildDir) + .withPropertyName("applicationWar") + + inputs.files(fileTree(appDir) { + include '**/*' + exclude '.gradle/**' + }) + .withPropertyName("application") + .withPathSensitivity(PathSensitivity.RELATIVE) } dependencies { - implementation 'org.springframework.boot:spring-boot-starter-web' - - runtimeOnly("javax.servlet:jstl") - runtimeOnly("org.apache.tomcat.embed:tomcat-embed-jasper") - - providedRuntime("org.springframework.boot:spring-boot-starter-tomcat") - testImplementation project(':dd-smoke-tests') testImplementation(testFixtures(project(":dd-smoke-tests:iast-util"))) } tasks.withType(Test).configureEach { - dependsOn "war", "bootWar" - + dependsOn 'bootWar' jvmArgumentProviders.add(new CommandLineArgumentProvider() { @Override Iterable asArguments() { - def bootWarTask = tasks.named('bootWar', BootWar).get() - return ["-Ddatadog.smoketest.springboot.war.path=${bootWarTask.archiveFile.get().getAsFile()}"] + return ["-Ddatadog.smoketest.springboot.war.path=$appBuildDir/libs/springboot-tomcat-jsp-smoketest.war"] } }) } + +spotless { + java { + target "**/*.java" + } + + groovyGradle { + target '*.gradle', "**/*.gradle" + } +} diff --git a/dd-smoke-tests/springboot-tomcat/application/build.gradle b/dd-smoke-tests/springboot-tomcat/application/build.gradle new file mode 100644 index 00000000000..5d1b73a7518 --- /dev/null +++ b/dd-smoke-tests/springboot-tomcat/application/build.gradle @@ -0,0 +1,83 @@ +plugins { + id 'war' + id 'org.springframework.boot' version '2.5.12' +} + +def sharedRootDir = "$rootDir/../../../" +def sharedConfigDirectory = "$sharedRootDir/gradle" +rootProject.ext.sharedConfigDirectory = sharedConfigDirectory + +apply from: "$sharedConfigDirectory/repositories.gradle" + +if (hasProperty('appBuildDir')) { + buildDir = property('appBuildDir') +} + +version = "" + +ext { + serverName = 'tomcat' + serverModule = 'tomcat-9' + serverVersion = '9.0.117' + serverExtension = 'zip' +} + +repositories { + ivy { + url = 'https://dlcdn.apache.org' + patternLayout { + artifact '/[organisation]/[module]/v[revision]/bin/apache-[organisation]-[revision].[ext]' + } + metadataSources { + it.artifact() + } + } +} + +configurations { + serverFile { + extendsFrom implementation + canBeResolved = true + } +} + +dependencies { + // uses the ivy repository url to download the tomcat server + // organisation = serverName, revision = serverVersion, module = serverModule, ext = serverExtension + serverFile "${serverName}:${serverModule}:${serverVersion}@${serverExtension}" + + implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.5.12' + providedRuntime group: 'org.springframework.boot', name: 'spring-boot-starter-tomcat', version: '2.5.12' +} + +tasks.register("unzip", Copy) { + def zipFileNamePrefix = "tomcat" + def serverZipTree = providers.provider { + // eager access + def zipPath = project.configurations.serverFile.find { + it.name.startsWith(zipFileNamePrefix) + } + if (zipPath == null) { + throw new GradleException("Can't find server zip file that starts with: " + zipFileNamePrefix) + } + zipTree(zipPath) + } + + from serverZipTree + into layout.buildDirectory + + // When tests are disabled this would still be run, so disable this manually + onlyIf { !project.rootProject.hasProperty("skipTests") } +} + +tasks.named('bootWar') { + dependsOn 'unzip' +} + +tasks.named('bootWarMainClassName') { + dependsOn 'unzip' +} + +tasks.named('war') { + dependsOn 'unzip' +} diff --git a/dd-smoke-tests/springboot-tomcat/application/gradle/wrapper/gradle-wrapper.jar b/dd-smoke-tests/springboot-tomcat/application/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000000..e708b1c023e Binary files /dev/null and b/dd-smoke-tests/springboot-tomcat/application/gradle/wrapper/gradle-wrapper.jar differ diff --git a/dd-smoke-tests/springboot-tomcat/application/gradle/wrapper/gradle-wrapper.properties b/dd-smoke-tests/springboot-tomcat/application/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000000..a4cf193f638 --- /dev/null +++ b/dd-smoke-tests/springboot-tomcat/application/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,8 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionSha256Sum=6f74b601422d6d6fc4e1f9a1ab6522f642c2fdcbc15ae33ebd30ba3d7198e854 +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.5-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/dd-smoke-tests/springboot-tomcat/application/gradlew b/dd-smoke-tests/springboot-tomcat/application/gradlew new file mode 100755 index 00000000000..965aff38453 --- /dev/null +++ b/dd-smoke-tests/springboot-tomcat/application/gradlew @@ -0,0 +1,183 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## 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='"-Xmx64m" "-Xms64m"' + +# 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 or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; 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=`expr $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" + +exec "$JAVACMD" "$@" diff --git a/dd-smoke-tests/springboot-tomcat/application/gradlew.bat b/dd-smoke-tests/springboot-tomcat/application/gradlew.bat new file mode 100644 index 00000000000..107acd32c4e --- /dev/null +++ b/dd-smoke-tests/springboot-tomcat/application/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@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 Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@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="-Xmx64m" "-Xms64m" + +@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 execute + +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 execute + +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 + +: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 %* + +: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 diff --git a/dd-smoke-tests/springboot-tomcat/application/settings.gradle b/dd-smoke-tests/springboot-tomcat/application/settings.gradle new file mode 100644 index 00000000000..ae63395506c --- /dev/null +++ b/dd-smoke-tests/springboot-tomcat/application/settings.gradle @@ -0,0 +1,32 @@ +pluginManagement { + repositories { + mavenLocal() + if (settings.hasProperty("gradlePluginProxy")) { + maven { + url settings["gradlePluginProxy"] + allowInsecureProtocol = true + } + } + if (settings.hasProperty("mavenRepositoryProxy")) { + maven { + url settings["mavenRepositoryProxy"] + allowInsecureProtocol = true + } + } + gradlePluginPortal() + mavenCentral() + } +} + +def isCI = providers.environmentVariable("CI").isPresent() + +if (isCI) { + def sharedRootDir = "$rootDir/../../../" + buildCache { + local { + directory = "$sharedRootDir/workspace/build-cache" + } + } +} + +rootProject.name='springboot-tomcat-smoketest' diff --git a/dd-smoke-tests/springboot-tomcat/src/main/java/datadog/smoketest/springboot/SpringbootTomcatApplication.java b/dd-smoke-tests/springboot-tomcat/application/src/main/java/datadog/smoketest/springboot/SpringbootTomcatApplication.java similarity index 100% rename from dd-smoke-tests/springboot-tomcat/src/main/java/datadog/smoketest/springboot/SpringbootTomcatApplication.java rename to dd-smoke-tests/springboot-tomcat/application/src/main/java/datadog/smoketest/springboot/SpringbootTomcatApplication.java diff --git a/dd-smoke-tests/springboot-tomcat/src/main/java/datadog/smoketest/springboot/controller/TestSuite.java b/dd-smoke-tests/springboot-tomcat/application/src/main/java/datadog/smoketest/springboot/controller/TestSuite.java similarity index 100% rename from dd-smoke-tests/springboot-tomcat/src/main/java/datadog/smoketest/springboot/controller/TestSuite.java rename to dd-smoke-tests/springboot-tomcat/application/src/main/java/datadog/smoketest/springboot/controller/TestSuite.java diff --git a/dd-smoke-tests/springboot-tomcat/src/main/java/datadog/smoketest/springboot/controller/ViewController.java b/dd-smoke-tests/springboot-tomcat/application/src/main/java/datadog/smoketest/springboot/controller/ViewController.java similarity index 100% rename from dd-smoke-tests/springboot-tomcat/src/main/java/datadog/smoketest/springboot/controller/ViewController.java rename to dd-smoke-tests/springboot-tomcat/application/src/main/java/datadog/smoketest/springboot/controller/ViewController.java diff --git a/dd-smoke-tests/springboot-tomcat/src/main/resources/application.properties b/dd-smoke-tests/springboot-tomcat/application/src/main/resources/application.properties similarity index 100% rename from dd-smoke-tests/springboot-tomcat/src/main/resources/application.properties rename to dd-smoke-tests/springboot-tomcat/application/src/main/resources/application.properties diff --git a/dd-smoke-tests/springboot-tomcat/build.gradle b/dd-smoke-tests/springboot-tomcat/build.gradle index 14d0705eeca..a3968b48a23 100644 --- a/dd-smoke-tests/springboot-tomcat/build.gradle +++ b/dd-smoke-tests/springboot-tomcat/build.gradle @@ -1,126 +1,60 @@ -import org.springframework.boot.gradle.tasks.bundling.BootWar - -plugins { - id 'war' - id 'org.springframework.boot' version '2.5.12' -} - -ext { - serverName = 'tomcat' - serverModule = 'tomcat-9' - serverVersion = '9.0.117' - serverExtension = 'zip' -} - apply from: "$rootDir/gradle/java.gradle" -apply from: "$rootDir/gradle/spring-boot-plugin.gradle" -description = 'SpringBoot Tomcat Smoke Tests.' -repositories { - ivy { - url = 'https://dlcdn.apache.org' - patternLayout { - artifact '/[organisation]/[module]/v[revision]/bin/apache-[organisation]-[revision].[ext]' - } - metadataSources { - it.artifact() - } - } -} +description = 'SpringBoot Tomcat Smoke Tests.' -configurations { - serverFile { - extendsFrom implementation - canBeResolved = true - } -} +def appDir = "$projectDir/application" +def appBuildDir = "$buildDir/application" +def isWindows = System.getProperty("os.name").toLowerCase().contains("win") +def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew' -dependencies { - // uses the ivy repository url to download the tomcat server - // organisation = serverName, revision = serverVersion, module = serverModule, ext = serverExtension - serverFile "${serverName}:${serverModule}:${serverVersion}@${serverExtension}" +def serverName = 'tomcat' +def serverVersion = '9.0.117' - testImplementation project(':dd-smoke-tests') -} +tasks.register('bootWar', Exec) { + workingDir appDir + environment += [ + "GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'", + "JAVA_HOME": getLazyJavaHomeFor(8) + ] + commandLine "$appDir/${gradlewCommand}", "bootWar", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir" -tasks.register("unzip", Copy) { - def zipFileNamePrefix = "tomcat" - def serverZipTree = providers.provider { - // eager access - def zipPath = project.configurations.serverFile.find { - it.name.startsWith(zipFileNamePrefix) - } - if (zipPath == null) { - throw new GradleException("Can't find server zip file that starts with: " + zipFileNamePrefix) - } - zipTree(zipPath) - } + outputs.cacheIf { true } - from serverZipTree - into layout.buildDirectory + outputs.dir(appBuildDir) + .withPropertyName("applicationWar") - // When tests are disabled this would still be run, so disable this manually - onlyIf { !project.rootProject.hasProperty("skipTests") } + inputs.files(fileTree(appDir) { + include '**/*' + exclude '.gradle/**' + }) + .withPropertyName("application") + .withPathSensitivity(PathSensitivity.RELATIVE) } dependencies { - implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.5.12' - providedRuntime group: 'org.springframework.boot', name: 'spring-boot-starter-tomcat', version: '2.5.12' - testImplementation group: 'commons-io', name: 'commons-io', version: '2.11.0' testImplementation project(':dd-smoke-tests') -} - -tasks.named('sourcesJar') { - dependsOn 'unzip' -} - -tasks.named('javadocJar') { - dependsOn 'unzip' -} - -tasks.named('bootWar') { - dependsOn 'unzip' -} - -tasks.named('bootWarMainClassName') { - dependsOn 'unzip' -} - -tasks.named('war') { - dependsOn 'unzip' -} - -tasks.named('javadocJar') { - dependsOn 'unzip' -} - -tasks.named('sourcesJar') { - dependsOn 'unzip' -} - -tasks.named('forbiddenApisMain') { - dependsOn 'unzip' -} - -tasks.named('spotbugsMain') { - dependsOn 'unzip' -} - -tasks.matching({it.name.startsWith('compileTest')}).configureEach { - dependsOn 'war', 'bootWar', 'unzip' + testImplementation group: 'commons-io', name: 'commons-io', version: '2.11.0' } tasks.withType(Test).configureEach { - dependsOn "war", "bootWar", "unzip" - + dependsOn 'bootWar' jvmArgumentProviders.add(new CommandLineArgumentProvider() { @Override Iterable asArguments() { - def bootWarTask = tasks.named('bootWar', BootWar).get() return [ - "-Ddatadog.smoketest.springboot.war.path=${bootWarTask.archiveFile.get().getAsFile()}", - "-Ddatadog.smoketest.tomcatDir=${layout.buildDirectory.get()}/apache-${serverName}-${serverVersion}" + "-Ddatadog.smoketest.springboot.war.path=$appBuildDir/libs/springboot-tomcat-smoketest.war", + "-Ddatadog.smoketest.tomcatDir=$appBuildDir/apache-${serverName}-${serverVersion}" ] } }) } + +spotless { + java { + target "**/*.java" + } + + groovyGradle { + target '*.gradle', "**/*.gradle" + } +} diff --git a/dd-smoke-tests/springboot-velocity/application/build.gradle b/dd-smoke-tests/springboot-velocity/application/build.gradle new file mode 100644 index 00000000000..49a85dacc10 --- /dev/null +++ b/dd-smoke-tests/springboot-velocity/application/build.gradle @@ -0,0 +1,25 @@ +plugins { + id 'java' + id 'org.springframework.boot' version '2.7.15' + id 'io.spring.dependency-management' version '1.0.15.RELEASE' +} + +def sharedRootDir = "$rootDir/../../../" +def sharedConfigDirectory = "$sharedRootDir/gradle" +rootProject.ext.sharedConfigDirectory = sharedConfigDirectory + +apply from: "$sharedConfigDirectory/repositories.gradle" + +if (hasProperty('appBuildDir')) { + buildDir = property('appBuildDir') +} + +version = "" + +dependencies { + implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.5.18.RELEASE' + implementation group: 'org.apache.velocity', name: 'velocity', version: '1.5' + implementation(group: 'org.apache.velocity', name: 'velocity-tools', version: '1.3') { + exclude group: 'javax.servlet', module: 'servlet-api' + } +} diff --git a/dd-smoke-tests/springboot-velocity/application/gradle/wrapper/gradle-wrapper.jar b/dd-smoke-tests/springboot-velocity/application/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000000..e708b1c023e Binary files /dev/null and b/dd-smoke-tests/springboot-velocity/application/gradle/wrapper/gradle-wrapper.jar differ diff --git a/dd-smoke-tests/springboot-velocity/application/gradle/wrapper/gradle-wrapper.properties b/dd-smoke-tests/springboot-velocity/application/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000000..a4cf193f638 --- /dev/null +++ b/dd-smoke-tests/springboot-velocity/application/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,8 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionSha256Sum=6f74b601422d6d6fc4e1f9a1ab6522f642c2fdcbc15ae33ebd30ba3d7198e854 +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.5-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/dd-smoke-tests/springboot-velocity/application/gradlew b/dd-smoke-tests/springboot-velocity/application/gradlew new file mode 100755 index 00000000000..965aff38453 --- /dev/null +++ b/dd-smoke-tests/springboot-velocity/application/gradlew @@ -0,0 +1,183 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## 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='"-Xmx64m" "-Xms64m"' + +# 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 or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; 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=`expr $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" + +exec "$JAVACMD" "$@" diff --git a/dd-smoke-tests/springboot-velocity/application/gradlew.bat b/dd-smoke-tests/springboot-velocity/application/gradlew.bat new file mode 100644 index 00000000000..107acd32c4e --- /dev/null +++ b/dd-smoke-tests/springboot-velocity/application/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@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 Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@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="-Xmx64m" "-Xms64m" + +@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 execute + +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 execute + +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 + +: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 %* + +: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 diff --git a/dd-smoke-tests/springboot-velocity/application/settings.gradle b/dd-smoke-tests/springboot-velocity/application/settings.gradle new file mode 100644 index 00000000000..25cc17e8703 --- /dev/null +++ b/dd-smoke-tests/springboot-velocity/application/settings.gradle @@ -0,0 +1,32 @@ +pluginManagement { + repositories { + mavenLocal() + if (settings.hasProperty("gradlePluginProxy")) { + maven { + url settings["gradlePluginProxy"] + allowInsecureProtocol = true + } + } + if (settings.hasProperty("mavenRepositoryProxy")) { + maven { + url settings["mavenRepositoryProxy"] + allowInsecureProtocol = true + } + } + gradlePluginPortal() + mavenCentral() + } +} + +def isCI = providers.environmentVariable("CI").isPresent() + +if (isCI) { + def sharedRootDir = "$rootDir/../../../" + buildCache { + local { + directory = "$sharedRootDir/workspace/build-cache" + } + } +} + +rootProject.name='springboot-velocity-smoketest' diff --git a/dd-smoke-tests/springboot-velocity/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java b/dd-smoke-tests/springboot-velocity/application/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java similarity index 100% rename from dd-smoke-tests/springboot-velocity/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java rename to dd-smoke-tests/springboot-velocity/application/src/main/java/datadog/smoketest/springboot/SpringbootApplication.java diff --git a/dd-smoke-tests/springboot-velocity/src/main/java/datadog/smoketest/springboot/XssController.java b/dd-smoke-tests/springboot-velocity/application/src/main/java/datadog/smoketest/springboot/XssController.java similarity index 100% rename from dd-smoke-tests/springboot-velocity/src/main/java/datadog/smoketest/springboot/XssController.java rename to dd-smoke-tests/springboot-velocity/application/src/main/java/datadog/smoketest/springboot/XssController.java diff --git a/dd-smoke-tests/springboot-velocity/src/main/resources/templates/velocity-insecure.vm b/dd-smoke-tests/springboot-velocity/application/src/main/resources/templates/velocity-insecure.vm similarity index 100% rename from dd-smoke-tests/springboot-velocity/src/main/resources/templates/velocity-insecure.vm rename to dd-smoke-tests/springboot-velocity/application/src/main/resources/templates/velocity-insecure.vm diff --git a/dd-smoke-tests/springboot-velocity/src/main/resources/templates/velocity-secure.vm b/dd-smoke-tests/springboot-velocity/application/src/main/resources/templates/velocity-secure.vm similarity index 100% rename from dd-smoke-tests/springboot-velocity/src/main/resources/templates/velocity-secure.vm rename to dd-smoke-tests/springboot-velocity/application/src/main/resources/templates/velocity-secure.vm diff --git a/dd-smoke-tests/springboot-velocity/build.gradle b/dd-smoke-tests/springboot-velocity/build.gradle index 76881a53bc1..b169b5f424f 100644 --- a/dd-smoke-tests/springboot-velocity/build.gradle +++ b/dd-smoke-tests/springboot-velocity/build.gradle @@ -1,34 +1,70 @@ -import org.springframework.boot.gradle.tasks.bundling.BootJar +apply from: "$rootDir/gradle/java.gradle" -plugins { - id 'java' - id 'org.springframework.boot' version '2.7.15' - id 'io.spring.dependency-management' version '1.0.15.RELEASE' - id 'java-test-fixtures' -} +apply plugin: 'java-test-fixtures' -apply from: "$rootDir/gradle/java.gradle" -apply from: "$rootDir/gradle/spring-boot-plugin.gradle" description = 'SpringBoot Velocity Smoke Tests.' -dependencies { - implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.5.18.RELEASE' - implementation group: 'org.apache.velocity', name: 'velocity', version: '1.5' - implementation(group: 'org.apache.velocity', name: 'velocity-tools', version: '1.3') { - exclude group: 'javax.servlet', module: 'servlet-api' - } +def appDir = "$projectDir/application" +def appBuildDir = "$buildDir/application" +def isWindows = System.getProperty("os.name").toLowerCase().contains("win") +def gradlewCommand = isWindows ? 'gradlew.bat' : 'gradlew' + +tasks.register('bootJar', Exec) { + workingDir appDir + environment += [ + "GRADLE_OPTS": "-Dorg.gradle.jvmargs='-Xmx512M'", + "JAVA_HOME": getLazyJavaHomeFor(8) + ] + commandLine "$appDir/${gradlewCommand}", "bootJar", "--no-daemon", "--max-workers=4", "-PappBuildDir=$appBuildDir" + + outputs.cacheIf { true } + + outputs.dir(appBuildDir) + .withPropertyName("applicationJar") + + inputs.files(fileTree(appDir) { + include '**/*' + exclude '.gradle/**' + }) + .withPropertyName("application") + .withPathSensitivity(PathSensitivity.RELATIVE) +} +dependencies { testImplementation project(':dd-smoke-tests') testImplementation(testFixtures(project(":dd-smoke-tests:iast-util"))) } +// The XssController loads templates from the filesystem at "resources/main/templates" +// relative to the test's working directory (= this module's buildDir). Mirror the app's +// processed resources here so the path resolves correctly at runtime. +tasks.register('copyAppResources', Copy) { + dependsOn 'bootJar' + from "$appBuildDir/resources/main" + into "$buildDir/resources/main" +} + +// jar reads build/resources/main; declare the dependency so Gradle knows the ordering. +tasks.named('jar') { + dependsOn 'copyAppResources' +} + tasks.withType(Test).configureEach { - dependsOn "bootJar" - def bootJarTask = tasks.named('bootJar', BootJar) + dependsOn 'copyAppResources' jvmArgumentProviders.add(new CommandLineArgumentProvider() { @Override Iterable asArguments() { - return bootJarTask.map { ["-Ddatadog.smoketest.springboot.shadowJar.path=${it.archiveFile.get()}"] }.get() + return ["-Ddatadog.smoketest.springboot.shadowJar.path=$appBuildDir/libs/springboot-velocity-smoketest.jar"] } }) } + +spotless { + java { + target "**/*.java" + } + + groovyGradle { + target '*.gradle', "**/*.gradle" + } +}