Skip to content

Commit 2aea5e9

Browse files
committed
build: upgrade to Gradle 9.2.1 and enable Java 21 build support
Upgrades the project to use Gradle 9.2.1, allowing the build to run on Java 21 environments while maintaining Java 8 bytecode compatibility. Key changes: - Upgrade Gradle Wrapper to 9.2.1. - Update CI workflows to use Java 21. - Set `options.release = 8` to ensure Java 8 compatibility (replaces obsolete source/target compatibility). - content: upgrade `shadow` plugin to 9.3.1 and `nexus-publish` to 2.0.0. - Fix Gradle 9 deprecation warnings (property assignment syntax). - Fix `ShadowRelocation` task compatibility with new Gradle API. - Bump Gradle version to 8.5 in some test code incompatible with 9. - Make smoke tests (event, access) self-contained and directory-agnostic, removing the need for 'gradlew testClasses' during test installation.
1 parent 8f757a2 commit 2aea5e9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+307
-2250
lines changed

.github/workflows/build-and-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
- uses: actions/checkout@v4
1010
- uses: actions/setup-java@v4
1111
with:
12-
java-version: '17'
12+
java-version: '21'
1313
distribution: 'temurin'
1414

1515
- name: Setup Gradle
@@ -33,7 +33,7 @@ jobs:
3333
test-suite:
3434
strategy:
3535
matrix:
36-
java: ['17', '11', '8']
36+
java: ['21', '17', '11', '8']
3737
runs-on: ubuntu-latest
3838
name: Run test suite with Java ${{ matrix.java }}
3939
needs: build-and-check

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
persist-credentials: false
3131
- uses: actions/setup-java@v5
3232
with:
33-
java-version: "17"
33+
java-version: "21"
3434
distribution: "temurin"
3535
cache: gradle
3636
- name: Setup node

agent/bin/test_install

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,3 @@ for d in build/fixtures/*; do
99
./mvnw package -quiet -DskipTests -Dcheckstyle.skip=true -Dspring-javaformat.skip=true
1010
cd -
1111
done
12-
13-
../gradlew testClasses

agent/bin/test_projects

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
#!/usr/bin/env bash
22

3-
fixture_dir=$PWD/build/fixtures
3+
set -eo pipefail
4+
5+
AGENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
6+
7+
cd "${AGENT_DIR}"
8+
49
mkdir -p build/fixtures
510

11+
# shellcheck source=../test/helper.bash
612
source "test/helper.bash"
7-
export ANNOTATION_JAR="$(find_annotation_jar)"
13+
ANNOTATION_JAR="$(find_annotation_jar)"
14+
export ANNOTATION_JAR
815

9-
function install_petclinic (
16+
function install_petclinic() {
1017
local repo="$1"; shift
1118
local ref=${1:-main}
12-
local pkg="$(basename $repo)"
19+
local pkg
20+
pkg="$(basename "$repo")"
1321

1422
if [[ -d "build/fixtures/${pkg}" ]]; then
1523
echo "Fixture already exists: ${pkg}"
@@ -43,7 +51,7 @@ function install_petclinic (
4351

4452

4553
cd ../../..
46-
)
54+
}
4755

4856
function install_scala_test_app {
4957
if [[ -d "test/scala/play-samples" ]]; then
@@ -53,14 +61,13 @@ function install_scala_test_app {
5361
cd test/scala
5462
rm -rf play-samples
5563
local branch=3.0.x
56-
case "${JAVA_VERSION}" in
57-
1.8*)
58-
branch=2.8.x
59-
;;
60-
11.*)
61-
branch=2.9.x
62-
;;
63-
esac
64+
if is_java 17; then
65+
branch=3.0.x
66+
elif is_java 11; then
67+
branch=2.9.x
68+
else
69+
branch=2.8.x
70+
fi
6471
git clone --no-checkout https://github.com/playframework/play-samples.git --depth 1 --branch $branch
6572
cd play-samples
6673
git sparse-checkout set play-scala-rest-api-example
@@ -69,20 +76,16 @@ function install_scala_test_app {
6976
cd ../../..
7077
}
7178

72-
case "${JAVA_VERSION}" in
73-
1.8*|11.*)
74-
install_petclinic "land-of-apps/spring-petclinic" old-java-support
75-
;;
76-
17.*)
77-
# The spring-petclinic main branch now requires Java 25. This is the last commit that supports Java 17.
78-
install_petclinic "spring-projects/spring-petclinic" "3aa79e3944ab1b626288f5d0629e61643ab8fb4a"
79-
install_petclinic "spring-petclinic/spring-framework-petclinic"
80-
;;
81-
*) # For Java 25+
82-
install_petclinic "spring-projects/spring-petclinic" "main"
83-
install_petclinic "spring-petclinic/spring-framework-petclinic"
84-
;;
85-
esac
79+
if is_java 25; then
80+
install_petclinic "spring-projects/spring-petclinic" "main"
81+
install_petclinic "spring-petclinic/spring-framework-petclinic"
82+
elif is_java 17; then
83+
# The spring-petclinic main branch now requires Java 25. This is the last commit that supports Java 17.
84+
install_petclinic "spring-projects/spring-petclinic" "3aa79e3944ab1b626288f5d0629e61643ab8fb4a"
85+
install_petclinic "spring-petclinic/spring-framework-petclinic"
86+
else
87+
install_petclinic "land-of-apps/spring-petclinic" old-java-support
88+
fi
8689

8790
patch -N -p1 -d build/fixtures/spring-petclinic < test/petclinic/pom.patch
8891

agent/bin/test_run

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ set -x
1515
# * just doing bats -r test doesn't discover a setup_suite.bash file correctly. http_client uses
1616
# one, so it needs to be run separately
1717

18-
bats -r test/!(http_client)
19-
bats -r test/http_client
18+
bats -r test/!(http_client)/
19+
bats -r test/http_client/

agent/build.gradle

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ plugins {
1414
}
1515

1616
repositories {
17-
jcenter()
1817
mavenCentral()
1918
}
2019

@@ -75,6 +74,7 @@ dependencies {
7574
testImplementation 'org.junit.jupiter:junit-jupiter'
7675
testImplementation 'org.junit.jupiter:junit-jupiter-params'
7776
testImplementation 'org.junit.vintage:junit-vintage-engine'
77+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
7878

7979
testImplementation 'com.github.stefanbirkner:system-rules:1.19.0'
8080
testImplementation 'com.github.stefanbirkner:system-lambda:1.2.1'
@@ -85,8 +85,7 @@ dependencies {
8585
}
8686

8787
compileJava {
88-
sourceCompatibility = '1.8'
89-
targetCompatibility = '1.8'
88+
options.release = 8
9089
}
9190

9291
jar {
@@ -97,11 +96,11 @@ jar {
9796
}
9897
}
9998

100-
apply plugin: 'com.github.johnrengelman.shadow'
99+
apply plugin: 'com.gradleup.shadow'
101100

102101
shadowJar {
103-
baseName = 'appmap'
104-
classifier = ''
102+
archiveBaseName = 'appmap'
103+
archiveClassifier = ''
105104
minimize() {
106105
// tinylog computes the dependencies it needs at runtime, so don't exclude
107106
// anything.
@@ -162,6 +161,7 @@ test {
162161
dependsOn cleanTest
163162
exclude 'com/appland/appmap/integration/**'
164163
// systemProperty "appmap.log.level", "debug"
164+
jvmArgs '--add-opens', 'java.base/java.lang=ALL-UNNAMED'
165165
}
166166

167167
task relocateShadowJar(type: ShadowRelocation) {
@@ -179,16 +179,16 @@ tasks.shadowJar.dependsOn tasks.relocateShadowJar
179179

180180
jacocoTestReport {
181181
reports {
182-
xml.enabled false
183-
csv.enabled false
184-
html.enabled true
182+
xml.required = false
183+
csv.required = false
184+
html.required = true
185185
}
186186
}
187187

188188
// extra artifacts used in publishing
189189
task sourcesJar(type: Jar) {
190190
from sourceSets.main.allJava
191-
classifier = 'sources'
191+
archiveClassifier = 'sources'
192192
}
193193

194194
// for some reason this block generates empty Javadoc
@@ -198,7 +198,7 @@ javadoc {
198198
}
199199

200200
task mockJavadocJar(type: Jar) {
201-
classifier = 'javadoc'
201+
archiveClassifier = 'javadoc'
202202
from javadoc.destinationDir
203203
}
204204

@@ -212,8 +212,8 @@ publishing {
212212

213213
// 1. coordinates (parameterized)
214214

215-
groupId publishGroupId
216-
artifactId publishArtifactId
215+
groupId = publishGroupId
216+
artifactId = publishArtifactId
217217

218218
// version defined globally
219219

@@ -271,4 +271,4 @@ if (project.hasProperty("signingKey")) {
271271
}
272272
}
273273

274-
tasks.publishToMavenLocal.dependsOn(check, integrationTest)
274+
tasks.publishToMavenLocal.dependsOn(check, integrationTest)

agent/test/access/MyClass.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package access;
2+
3+
public class MyClass {
4+
public void myMethod() {
5+
// do nothing
6+
}
7+
8+
public void callNonPublic() {
9+
myPackageMethod();
10+
myPrivateMethod();
11+
}
12+
13+
String myPackageMethod() {
14+
return "package method";
15+
}
16+
17+
private String myPrivateMethod() {
18+
return "private method";
19+
}
20+
}

agent/test/access/RecordPackage.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
package access;
2+
13
import java.io.IOException;
24
import java.io.OutputStreamWriter;
35

46
import com.appland.appmap.record.Recorder;
57
import com.appland.appmap.record.Recording;
6-
import com.appland.appmap.test.fixture.MyClass;
78

89
public class RecordPackage {
910
public static void main(String[] argv) {

agent/test/access/access.bats

100644100755
Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ load '../helper'
44

55
sep="$JAVA_PATH_SEPARATOR"
66
AGENT_JAR="$(find_agent_jar)"
7-
wd=$(getcwd)
8-
test_cp="${wd}/test/access${sep}${wd}/build/classes/java/test"
7+
8+
# Resolves to .../agent/test
9+
TEST_DIR="$(dirname "$BATS_TEST_DIRNAME")"
10+
11+
# test_cp must include 'test' (for access package) and 'test/access' (for default package)
12+
test_cp="${TEST_DIR}${sep}${TEST_DIR}/access"
913
java_cmd="java -javaagent:'${AGENT_JAR}' -cp '${test_cp}'"
1014

1115
setup() {
12-
javac -cp "${AGENT_JAR}${sep}${test_cp}" test/access/*.java
13-
14-
cd test/access
16+
cd "$BATS_TEST_DIRNAME" || exit
17+
javac -cp "${AGENT_JAR}" -sourcepath "$TEST_DIR" ./*.java
1518
_configure_logging
1619
}
1720

@@ -22,7 +25,7 @@ setup() {
2225
# functionaly it enables is pretty useless, though, so it seems harmless to
2326
# hijack it.
2427
@test "testProtected" {
25-
local cmd="${java_cmd} RecordPackage"
28+
local cmd="${java_cmd} access.RecordPackage"
2629
[[ $BATS_VERBOSE_RUN == 1 ]] && echo "cmd: $cmd" >&3
2730

2831
# Exactly 4 events means that MyClass.myPrivateMethod was not recorded
@@ -31,7 +34,7 @@ setup() {
3134
}
3235

3336
@test "testPrivate" {
34-
local cmd="${java_cmd} -Dappmap.record.private=true RecordPackage"
37+
local cmd="${java_cmd} -Dappmap.record.private=true access.RecordPackage"
3538
[[ $BATS_VERBOSE_RUN == 1 ]] && echo "cmd: $cmd" >&3
3639

3740
# 6 events means that both myPackageMethod and myPrivateMethod were recorded
@@ -40,15 +43,15 @@ setup() {
4043
}
4144

4245
@test "outside git repo" {
43-
cp -v "$(_top_level)/agent/appmap.yml" "$BATS_TEST_TMPDIR"/.
46+
cp -v "appmap.yml" "$BATS_TEST_TMPDIR"/.
4447
cd "$BATS_TEST_TMPDIR"
4548

4649
# sanity check
4750
run git rev-parse --show-top-level
4851
assert_output -p 'not a git repository'
4952
assert_failure
5053

51-
local cmd="${java_cmd} RecordPackage"
54+
local cmd="${java_cmd} access.RecordPackage"
5255
[[ $BATS_VERBOSE_RUN == 1 ]] && echo "cmd: $cmd" >&3
5356
run bash -c "eval \"$cmd\" 2>/dev/null"
5457
assert_success

agent/test/access/appmap.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
name: test-access
22
packages:
3-
- path: com.appland.appmap.test.fixture
3+
- path: access
44
- path: HelloWorld

0 commit comments

Comments
 (0)