Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use captureFileFingerprints for Maven extension 1.21 #27

Merged
merged 2 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions develocity-maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ spec:
# Enforce URL
enforceUrl:
default: 'true'
# Capture goal input files, only set if no Develocity extension is already present
captureGoalInputFiles:
# Capture file fingerprints, only set if no Develocity extension is already present
captureFileFingerprints:
default: 'true'
# Will not inject the Develocity Maven extension if an extension with provided coordinates is found.
# Expected format 'groupId:artifactId(:version)'
Expand All @@ -36,7 +36,7 @@ spec:
mavenExtensionVersion=$[[ inputs.mavenExtensionVersion ]]
allowUntrustedServer=$[[ inputs.allowUntrustedServer ]]
enforceUrl=$[[ inputs.enforceUrl ]]
captureGoalInputFiles=$[[ inputs.captureGoalInputFiles ]]
captureFileFingerprints=$[[ inputs.captureFileFingerprints ]]
customMavenExtensionCoordinates=$[[ inputs.mavenExtensionCustomCoordinates ]]
customCcudCoordinates=$[[ inputs.ccudExtensionCustomCoordinates ]]
url=$[[ inputs.url ]]
Expand Down Expand Up @@ -107,9 +107,9 @@ spec:
then
mavenOpts="${mavenOpts} -Dgradle.enterprise.url=${url} -Ddevelocity.url=${url}"
fi
if [[ "${appliedCustomDv}" = "false" && ("${captureGoalInputFiles}" = "true" || "${captureGoalInputFiles}" = "false") ]]
if [[ "${appliedCustomDv}" = "false" && ("${captureFileFingerprints}" = "true" || "${captureFileFingerprints}" = "false") ]]
then
mavenOpts="${mavenOpts} -Dgradle.scan.captureGoalInputFiles=${captureGoalInputFiles}"
mavenOpts="${mavenOpts} -Ddevelocity.scan.captureFileFingerprints=${captureFileFingerprints} -Dgradle.scan.captureGoalInputFiles=${captureFileFingerprints}"
fi
local existingMavenOpts=$(if [ ! -z "$MAVEN_OPTS" ]; then echo "${MAVEN_OPTS} "; else echo ''; fi)
export MAVEN_OPTS=${existingMavenOpts}${mavenOpts}
Expand Down
111 changes: 61 additions & 50 deletions test_maven.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ function test_detectExtension_detected() {
</extension>
</extensions>
EOF
setupVars

local result=$(detectExtension "${projDir}" "com.gradle:develocity-maven-extension")

Expand Down Expand Up @@ -117,6 +118,7 @@ function test_detectExtension_multiple_detected() {
</extension>
</extensions>
EOF
setupVars

local result=$(detectExtension "${projDir}" "com.gradle:develocity-maven-extension")

Expand All @@ -136,6 +138,7 @@ function test_detectExtension_notDetected() {
</extension>
</extensions>
EOF
setupVars

local result=$(detectExtension "${projDir}" "com.gradle:develocity-maven-extension")

Expand All @@ -150,6 +153,7 @@ function test_detectExtension_notDetected_junk() {
<foo>
</foo>
EOF
setupVars

local result=$(detectExtension "${projDir}" "com.gradle:develocity-maven-extension")

Expand All @@ -159,6 +163,7 @@ EOF

function test_detectExtension_unexisting() {
local projDir=$(setupProject)
setupVars

local result=$(detectExtension "${projDir}" "com.gradle:develocity-maven-extension")

Expand All @@ -178,6 +183,7 @@ function test_detectDvExtension_non_existing() {
</extension>
</extensions>
EOF
setupVars

local result=$(detectDvExtension "${projDir}")
echo "test_detectDvExtension_non_existing: ${result}"
Expand All @@ -201,8 +207,9 @@ function test_detectDvExtension_custom() {
</extension>
</extensions>
EOF
setupVars

local customMavenExtensionCoordinates="com.foo:bar:1.0"
customMavenExtensionCoordinates="com.foo:bar:1.0"
local result=$(detectDvExtension "${projDir}")
echo "test_detectDvExtension_custom: ${result}"
assert "${result}" "true"
Expand All @@ -225,6 +232,7 @@ function test_detectDvExtension_GradleEnterprise() {
</extension>
</extensions>
EOF
setupVars

local result=$(detectDvExtension "${projDir}")
echo "test_detectDvExtension_GradleEnterprise: ${result}"
Expand All @@ -243,6 +251,7 @@ function test_detectDvExtension_Develocity() {
</extension>
</extensions>
EOF
setupVars

local result=$(detectDvExtension "${projDir}")
echo "test_detectDvExtension_Develocity: ${result}"
Expand All @@ -251,26 +260,23 @@ EOF

function test_inject_develocity_for_maven() {
local projDir=$(setupProject)
allowUntrustedServer=false
url=https://localhost
MAVEN_OPTS=""
setupVars

injectDevelocityForMaven "${projDir}"

echo "test_inject_develocity_for_maven: ${MAVEN_OPTS}"
assert "${MAVEN_OPTS}" "-Dmaven.ext.class.path=/path/to/develocity-maven-extension.jar:/path/to/common-custom-user-data-maven-extension.jar -Dgradle.scan.uploadInBackground=false -Ddevelocity.uploadInBackground=false -Dgradle.enterprise.allowUntrustedServer=false -Ddevelocity.allowUntrustedServer=false -Dgradle.enterprise.url=https://localhost -Ddevelocity.url=https://localhost"
assert "${MAVEN_OPTS}" "-Dmaven.ext.class.path=/path/to/develocity-maven-extension.jar:/path/to/common-custom-user-data-maven-extension.jar -Dgradle.scan.uploadInBackground=false -Ddevelocity.uploadInBackground=false -Dgradle.enterprise.allowUntrustedServer=false -Ddevelocity.allowUntrustedServer=false -Dgradle.enterprise.url=https://localhost -Ddevelocity.url=https://localhost -Ddevelocity.scan.captureFileFingerprints=true -Dgradle.scan.captureGoalInputFiles=true"
}

function test_inject_develocity_for_maven_existing_maven_opts() {
local projDir=$(setupProject)
allowUntrustedServer=false
url=https://localhost
setupVars
MAVEN_OPTS="-Dfoo=bar"

injectDevelocityForMaven "${projDir}"

echo "test_inject_develocity_for_maven_existing_maven_opts: ${MAVEN_OPTS}"
assert "${MAVEN_OPTS}" "-Dfoo=bar -Dmaven.ext.class.path=/path/to/develocity-maven-extension.jar:/path/to/common-custom-user-data-maven-extension.jar -Dgradle.scan.uploadInBackground=false -Ddevelocity.uploadInBackground=false -Dgradle.enterprise.allowUntrustedServer=false -Ddevelocity.allowUntrustedServer=false -Dgradle.enterprise.url=https://localhost -Ddevelocity.url=https://localhost"
assert "${MAVEN_OPTS}" "-Dfoo=bar -Dmaven.ext.class.path=/path/to/develocity-maven-extension.jar:/path/to/common-custom-user-data-maven-extension.jar -Dgradle.scan.uploadInBackground=false -Ddevelocity.uploadInBackground=false -Dgradle.enterprise.allowUntrustedServer=false -Ddevelocity.allowUntrustedServer=false -Dgradle.enterprise.url=https://localhost -Ddevelocity.url=https://localhost -Ddevelocity.scan.captureFileFingerprints=true -Dgradle.scan.captureGoalInputFiles=true"
}

function test_inject_develocity_for_maven_existing_extension() {
Expand All @@ -285,11 +291,9 @@ function test_inject_develocity_for_maven_existing_extension() {
</extension>
</extensions>
EOF
allowUntrustedServer=false
setupVars
customMavenExtensionCoordinates="org.apache.maven.extensions:maven-enforcer-extension"
url=https://localhost
enforceUrl=false
MAVEN_OPTS=""

injectDevelocityForMaven "${projDir}"

Expand All @@ -309,10 +313,8 @@ function test_inject_develocity_for_maven_existing_extension_enforceUrl() {
</extension>
</extensions>
EOF
allowUntrustedServer=false
setupVars
customMavenExtensionCoordinates="org.apache.maven.extensions:maven-enforcer-extension"
url=https://localhost
MAVEN_OPTS=""
enforceUrl=true

injectDevelocityForMaven "${projDir}"
Expand All @@ -333,17 +335,14 @@ function test_inject_develocity_for_maven_existing_ccud_extension() {
</extension>
</extensions>
EOF
allowUntrustedServer=false
customMavenExtensionCoordinates=""
setupVars
customCcudCoordinates="org.apache.maven.extensions:maven-enforcer-extension"
url=https://localhost
enforceUrl=false
MAVEN_OPTS=""

injectDevelocityForMaven "${projDir}"

echo "test_inject_develocity_for_maven_existing_ccud_extension: ${MAVEN_OPTS}"
assert "${MAVEN_OPTS}" "-Dmaven.ext.class.path=/path/to/develocity-maven-extension.jar -Dgradle.scan.uploadInBackground=false -Ddevelocity.uploadInBackground=false -Dgradle.enterprise.allowUntrustedServer=false -Ddevelocity.allowUntrustedServer=false"
assert "${MAVEN_OPTS}" "-Dmaven.ext.class.path=/path/to/develocity-maven-extension.jar -Dgradle.scan.uploadInBackground=false -Ddevelocity.uploadInBackground=false -Dgradle.enterprise.allowUntrustedServer=false -Ddevelocity.allowUntrustedServer=false -Ddevelocity.scan.captureFileFingerprints=true -Dgradle.scan.captureGoalInputFiles=true"
}

function test_inject_develocity_for_maven_existing_default_ccud_extension() {
Expand All @@ -358,17 +357,13 @@ function test_inject_develocity_for_maven_existing_default_ccud_extension() {
</extension>
</extensions>
EOF
allowUntrustedServer=false
customMavenExtensionCoordinates=""
customCcudCoordinates=""
url=https://localhost
setupVars
enforceUrl=false
MAVEN_OPTS=""

injectDevelocityForMaven "${projDir}"

echo "test_inject_develocity_for_maven_existing_default_ccud_extension: ${MAVEN_OPTS}"
assert "${MAVEN_OPTS}" "-Dmaven.ext.class.path=/path/to/develocity-maven-extension.jar -Dgradle.scan.uploadInBackground=false -Ddevelocity.uploadInBackground=false -Dgradle.enterprise.allowUntrustedServer=false -Ddevelocity.allowUntrustedServer=false"
assert "${MAVEN_OPTS}" "-Dmaven.ext.class.path=/path/to/develocity-maven-extension.jar -Dgradle.scan.uploadInBackground=false -Ddevelocity.uploadInBackground=false -Dgradle.enterprise.allowUntrustedServer=false -Ddevelocity.allowUntrustedServer=false -Ddevelocity.scan.captureFileFingerprints=true -Dgradle.scan.captureGoalInputFiles=true"
}

function test_inject_develocity_for_maven_existing_ccud_extension_enforceUrl() {
Expand All @@ -383,17 +378,14 @@ function test_inject_develocity_for_maven_existing_ccud_extension_enforceUrl() {
</extension>
</extensions>
EOF
allowUntrustedServer=false
customMavenExtensionCoordinates=""
setupVars
customCcudCoordinates="org.apache.maven.extensions:maven-enforcer-extension"
url=https://localhost
enforceUrl=true
MAVEN_OPTS=""

injectDevelocityForMaven "${projDir}"

echo "test_inject_develocity_for_maven_existing_ccud_extension_enforceUrl: ${MAVEN_OPTS}"
assert "${MAVEN_OPTS}" "-Dmaven.ext.class.path=/path/to/develocity-maven-extension.jar -Dgradle.scan.uploadInBackground=false -Ddevelocity.uploadInBackground=false -Dgradle.enterprise.allowUntrustedServer=false -Ddevelocity.allowUntrustedServer=false -Dgradle.enterprise.url=https://localhost -Ddevelocity.url=https://localhost"
assert "${MAVEN_OPTS}" "-Dmaven.ext.class.path=/path/to/develocity-maven-extension.jar -Dgradle.scan.uploadInBackground=false -Ddevelocity.uploadInBackground=false -Dgradle.enterprise.allowUntrustedServer=false -Ddevelocity.allowUntrustedServer=false -Dgradle.enterprise.url=https://localhost -Ddevelocity.url=https://localhost -Ddevelocity.scan.captureFileFingerprints=true -Dgradle.scan.captureGoalInputFiles=true"
}

function test_inject_develocity_for_maven_existing_dv_and_ccud_extension_enforceUrl() {
Expand All @@ -413,43 +405,49 @@ function test_inject_develocity_for_maven_existing_dv_and_ccud_extension_enforce
</extension>
</extensions>
EOF
allowUntrustedServer=false
setupVars
customMavenExtensionCoordinates="org.foo:bar-extension"
customCcudCoordinates="org.apache.maven.extensions:maven-enforcer-extension"
url=https://localhost
enforceUrl=true
MAVEN_OPTS=""

injectDevelocityForMaven "${projDir}"

echo "test_inject_develocity_for_maven_existing_dv_and_ccud_extension_enforceUrl: ${MAVEN_OPTS}"
assert "${MAVEN_OPTS}" "-Dgradle.scan.uploadInBackground=false -Ddevelocity.uploadInBackground=false -Dgradle.enterprise.allowUntrustedServer=false -Ddevelocity.allowUntrustedServer=false -Dgradle.enterprise.url=https://localhost -Ddevelocity.url=https://localhost"
}

function test_inject_capture_goal_input_files_true_old() {
local projDir=$(setupProject)
setupVars
captureFileFingerprints=true
mavenExtensionVersion="1.20.1"

injectDevelocityForMaven "${projDir}"

echo "test_inject_capture_goal_input_files_true_old: ${MAVEN_OPTS}"
assert "${MAVEN_OPTS}" "-Dmaven.ext.class.path=/path/to/develocity-maven-extension.jar:/path/to/common-custom-user-data-maven-extension.jar -Dgradle.scan.uploadInBackground=false -Ddevelocity.uploadInBackground=false -Dgradle.enterprise.allowUntrustedServer=false -Ddevelocity.allowUntrustedServer=false -Dgradle.enterprise.url=https://localhost -Ddevelocity.url=https://localhost -Ddevelocity.scan.captureFileFingerprints=true -Dgradle.scan.captureGoalInputFiles=true"
}

function test_inject_capture_goal_input_files_true() {
local projDir=$(setupProject)
allowUntrustedServer=false
url=https://localhost
captureGoalInputFiles=true
MAVEN_OPTS=""
setupVars
captureFileFingerprints=true

injectDevelocityForMaven "${projDir}"

echo "test_inject_capture_goal_input_files_true: ${MAVEN_OPTS}"
assert "${MAVEN_OPTS}" "-Dmaven.ext.class.path=/path/to/develocity-maven-extension.jar:/path/to/common-custom-user-data-maven-extension.jar -Dgradle.scan.uploadInBackground=false -Ddevelocity.uploadInBackground=false -Dgradle.enterprise.allowUntrustedServer=false -Ddevelocity.allowUntrustedServer=false -Dgradle.enterprise.url=https://localhost -Ddevelocity.url=https://localhost -Dgradle.scan.captureGoalInputFiles=true"
assert "${MAVEN_OPTS}" "-Dmaven.ext.class.path=/path/to/develocity-maven-extension.jar:/path/to/common-custom-user-data-maven-extension.jar -Dgradle.scan.uploadInBackground=false -Ddevelocity.uploadInBackground=false -Dgradle.enterprise.allowUntrustedServer=false -Ddevelocity.allowUntrustedServer=false -Dgradle.enterprise.url=https://localhost -Ddevelocity.url=https://localhost -Ddevelocity.scan.captureFileFingerprints=true -Dgradle.scan.captureGoalInputFiles=true"
}

function test_inject_capture_goal_input_files_false() {
local projDir=$(setupProject)
allowUntrustedServer=false
url=https://localhost
captureGoalInputFiles=false
MAVEN_OPTS=""
setupVars
captureFileFingerprints=false

injectDevelocityForMaven "${projDir}"

echo "test_inject_capture_goal_input_files_false: ${MAVEN_OPTS}"
assert "${MAVEN_OPTS}" "-Dmaven.ext.class.path=/path/to/develocity-maven-extension.jar:/path/to/common-custom-user-data-maven-extension.jar -Dgradle.scan.uploadInBackground=false -Ddevelocity.uploadInBackground=false -Dgradle.enterprise.allowUntrustedServer=false -Ddevelocity.allowUntrustedServer=false -Dgradle.enterprise.url=https://localhost -Ddevelocity.url=https://localhost -Dgradle.scan.captureGoalInputFiles=false"
assert "${MAVEN_OPTS}" "-Dmaven.ext.class.path=/path/to/develocity-maven-extension.jar:/path/to/common-custom-user-data-maven-extension.jar -Dgradle.scan.uploadInBackground=false -Ddevelocity.uploadInBackground=false -Dgradle.enterprise.allowUntrustedServer=false -Ddevelocity.allowUntrustedServer=false -Dgradle.enterprise.url=https://localhost -Ddevelocity.url=https://localhost -Ddevelocity.scan.captureFileFingerprints=false -Dgradle.scan.captureGoalInputFiles=false"
}

function test_inject_capture_goal_input_files_existing_ext() {
Expand All @@ -464,13 +462,9 @@ function test_inject_capture_goal_input_files_existing_ext() {
</extension>
</extensions>
EOF
allowUntrustedServer=false
customMavenExtensionCoordinates=""
customCcudCoordinates=""
url=https://localhost
MAVEN_OPTS=""
setupVars
enforceUrl=false
captureGoalInputFiles=false
captureFileFingerprints=false

injectDevelocityForMaven "${projDir}"

Expand All @@ -486,12 +480,28 @@ function setupProject() {
echo "${projDir}"
}

function setupVars() {
# Set the vars to default
MAVEN_OPTS=""
ccudMavenExtensionVersion=""
mavenRepo=""
mavenExtensionVersion="1.21"
allowUntrustedServer="false"
enforceUrl="true"
captureFileFingerprints="true"
customMavenExtensionCoordinates=""
customCcudCoordinates=""
url="https://localhost"
}


function assert() {
local val=$1
local expected=$2
if [ ! "${val}" = "${expected}" ]
then
echo "${val} not equal to expected ${expected}"
echo "Not equal to expected"
diff <(echo "${val}" ) <(echo "${expected}")
exit 1
fi
}
Expand Down Expand Up @@ -538,6 +548,7 @@ test_inject_develocity_for_maven_existing_ccud_extension
test_inject_develocity_for_maven_existing_default_ccud_extension
test_inject_develocity_for_maven_existing_ccud_extension_enforceUrl
test_inject_develocity_for_maven_existing_dv_and_ccud_extension_enforceUrl
test_inject_capture_goal_input_files_true_old
test_inject_capture_goal_input_files_true
test_inject_capture_goal_input_files_false
test_inject_capture_goal_input_files_existing_ext
Loading