1+ buildscript {
2+ def isModern = JavaVersion . current() >= JavaVersion . VERSION_25
3+ project. ext {
4+ useJakarta = isModern
5+ springBootVersion = isModern ? ' 3.1.4' : ' 2.7.0'
6+ javaVersion = isModern ? JavaVersion . VERSION_17 : JavaVersion . VERSION_1_8
7+ }
8+
9+ repositories {
10+ mavenCentral()
11+ }
12+ dependencies {
13+ classpath " org.springframework.boot:spring-boot-gradle-plugin:${ project.springBootVersion} "
14+ }
15+ }
16+
117plugins {
2- id ' org.springframework.boot' version ' 2.7.0'
3- id ' io.spring.dependency-management' version ' 1.0.11.RELEASE'
18+ id ' io.spring.dependency-management' version ' 1.1.7'
419 id ' java'
520}
621
22+ apply plugin : ' org.springframework.boot'
23+
724group = ' com.example'
825version = ' 0.0.1-SNAPSHOT'
9- sourceCompatibility = ' 1.8'
1026
11- // suppress warnings about source compatibility
12- tasks . withType( JavaCompile ) {
13- options . compilerArgs << ' -Xlint:-options '
27+ java {
28+ sourceCompatibility = javaVersion
29+ targetCompatibility = javaVersion
1430}
1531
1632repositories {
@@ -22,10 +38,26 @@ dependencies {
2238 runtimeOnly ' com.h2database:h2'
2339 runtimeOnly ' com.oracle.database.jdbc:ojdbc8:21.9.0.0'
2440 testImplementation ' org.springframework.boot:spring-boot-starter-test'
41+ testRuntimeOnly ' org.junit.platform:junit-platform-launcher'
2542}
2643
2744def appmapJar = " $System . env . AGENT_JAR "
2845
46+ // Spring boot 3.x uses Jakarta EE namespaces
47+ task transformSources (type : Copy ) {
48+ from ' src/main/java'
49+ into " $buildDir /generated-sources/transformed"
50+
51+ if (useJakarta) {
52+ filter { line ->
53+ line. replaceAll(' javax.persistence' , ' jakarta.persistence' )
54+ }
55+ }
56+ }
57+
58+ sourceSets. main. java. srcDirs = [transformSources. destinationDir]
59+ compileJava. dependsOn transformSources
60+
2961test {
3062 useJUnitPlatform()
3163 if (System . env. ORACLE_URL ) {
0 commit comments