Skip to content

Commit a4856e0

Browse files
committed
feat(build): support JDK 21+ on Gradle 9.1
1 parent 982425f commit a4856e0

13 files changed

Lines changed: 295 additions & 61 deletions

File tree

actuator/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ test {
3333

3434
jacocoTestReport {
3535
reports {
36-
xml.enabled = true
37-
html.enabled = true
36+
xml.required.set(true)
37+
html.required.set(true)
3838
}
3939
getExecutionData().setFrom(fileTree('../framework/build/jacoco').include("**.exec"))
4040
afterEvaluate {

build.gradle

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ allprojects {
1111
ext {
1212
springVersion = "5.3.39"
1313
errorproneVersion = "2.42.0"
14+
lombokVersion = "1.18.42"
1415
}
1516
}
1617
def arch = System.getProperty("os.arch").toLowerCase(Locale.ROOT)
@@ -59,12 +60,14 @@ subprojects {
5960
apply plugin: "jacoco"
6061
apply plugin: "maven-publish"
6162

62-
sourceCompatibility = JavaVersion.VERSION_1_8
63-
targetCompatibility = JavaVersion.current()
63+
java {
64+
sourceCompatibility = JavaVersion.VERSION_1_8
65+
targetCompatibility = JavaVersion.VERSION_1_8
66+
}
6467

6568
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
6669
jacoco {
67-
toolVersion = "0.8.12" // see https://www.jacoco.org/jacoco/trunk/doc/changes.html
70+
toolVersion = "0.8.15" // see https://www.jacoco.org/jacoco/trunk/doc/changes.html
6871
}
6972

7073
buildscript {
@@ -76,7 +79,7 @@ subprojects {
7679
}
7780
}
7881
dependencies {
79-
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.9.1'
82+
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.9.6'
8083
classpath "gradle.plugin.com.github.johnrengelman:shadow:7.1.2"
8184
}
8285
}
@@ -101,10 +104,10 @@ subprojects {
101104
implementation group: 'joda-time', name: 'joda-time', version: '2.3'
102105
implementation group: 'org.bouncycastle', name: 'bcprov-jdk18on', version: '1.84'
103106

104-
compileOnly 'org.projectlombok:lombok:1.18.34'
105-
annotationProcessor 'org.projectlombok:lombok:1.18.34'
106-
testCompileOnly 'org.projectlombok:lombok:1.18.34'
107-
testAnnotationProcessor 'org.projectlombok:lombok:1.18.34'
107+
compileOnly "org.projectlombok:lombok:${lombokVersion}"
108+
annotationProcessor "org.projectlombok:lombok:${lombokVersion}"
109+
testCompileOnly "org.projectlombok:lombok:${lombokVersion}"
110+
testAnnotationProcessor "org.projectlombok:lombok:${lombokVersion}"
108111

109112
// https://www.oracle.com/java/technologies/javase/11-relnote-issues.html#JDK-8190378
110113
implementation group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2'
@@ -115,6 +118,8 @@ subprojects {
115118
testImplementation group: 'junit', name: 'junit', version: '4.13.2'
116119
testImplementation "org.mockito:mockito-core:4.11.0"
117120
testImplementation "org.mockito:mockito-inline:4.11.0"
121+
testImplementation "net.bytebuddy:byte-buddy:1.17.7"
122+
testImplementation "net.bytebuddy:byte-buddy-agent:1.17.7"
118123
}
119124
if (project.name != 'protocol' && project.name != 'errorprone'
120125
&& javaVersion.isJava11Compatible()) {
@@ -138,7 +143,7 @@ subprojects {
138143
}
139144

140145
task sourcesJar(type: Jar, dependsOn: classes) {
141-
classifier = "sources"
146+
archiveClassifier = "sources"
142147
from sourceSets.main.allSource
143148
duplicatesStrategy = DuplicatesStrategy.INCLUDE // allow duplicates
144149
}

chainbase/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ test {
4242
jacocoTestReport {
4343
dependsOn(processResources) // explicit_dependency
4444
reports {
45-
xml.enabled = true
46-
html.enabled = true
45+
xml.required.set(true)
46+
html.required.set(true)
4747
}
4848
getExecutionData().setFrom(fileTree('../framework/build/jacoco').include("**.exec"))
4949
afterEvaluate {

common/build.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
version '1.0.0'
22

3+
def aspectjVersion = '1.9.25'
34

45
dependencies {
56
api group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.18.6' // https://github.com/FasterXML/jackson-databind/issues/3627
@@ -12,9 +13,9 @@ dependencies {
1213
api group: 'io.prometheus', name: 'simpleclient_hotspot', version: '0.15.0'
1314
// https://openjdk.org/jeps/396, JEP 396: Strongly Encapsulate JDK Internals by Default
1415
// https://eclipse.dev/aspectj/doc/latest/release/JavaVersionCompatibility.html
15-
api 'org.aspectj:aspectjrt:1.9.8'
16-
api 'org.aspectj:aspectjweaver:1.9.8'
17-
api 'org.aspectj:aspectjtools:1.9.8'
16+
api "org.aspectj:aspectjrt:${aspectjVersion}"
17+
api "org.aspectj:aspectjweaver:${aspectjVersion}"
18+
api "org.aspectj:aspectjtools:${aspectjVersion}"
1819
api group: 'com.github.tronprotocol', name: 'libp2p', version: 'release-v2.2.8-SNAPSHOT',{
1920
//api group: 'io.github.tronprotocol', name: 'libp2p', version: '2.2.7',{
2021
exclude group: 'io.grpc', module: 'grpc-context'

consensus/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ test {
3232

3333
jacocoTestReport {
3434
reports {
35-
xml.enabled = true
36-
html.enabled = true
35+
xml.required.set(true)
36+
html.required.set(true)
3737
}
3838
getExecutionData().setFrom(fileTree('../framework/build/jacoco').include("**.exec"))
3939
afterEvaluate {

crypto/build.gradle

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
version '1.0.0'
22

3-
sourceCompatibility = 1.8
3+
java {
4+
sourceCompatibility = JavaVersion.VERSION_1_8
5+
}
46

57
repositories {
68
mavenCentral()
@@ -12,8 +14,8 @@ dependencies {
1214

1315
jacocoTestReport {
1416
reports {
15-
xml.enabled = true
16-
html.enabled = true
17+
xml.required.set(true)
18+
html.required.set(true)
1719
}
1820
getExecutionData().setFrom(fileTree('../framework/build/jacoco').include("**.exec"))
1921
afterEvaluate {

framework/build.gradle

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
plugins {
2-
id "org.gradle.test-retry" version "1.5.9"
2+
id "org.gradle.test-retry" version "1.6.5"
33
id "org.sonarqube" version "2.6"
4-
id "com.gorylenko.gradle-git-properties" version "2.4.1"
4+
id "com.gorylenko.gradle-git-properties" version "4.0.1"
55
}
66

77
gitProperties.failOnNoGitDirectory = false;
8+
tasks.named('generateGitProperties') {
9+
doNotTrackState('The task snapshots .git, which may contain non-regular fsmonitor IPC files.')
10+
}
811

912
apply plugin: 'application'
1013
apply plugin: 'checkstyle'
1114

12-
mainClassName = 'org.tron.program.FullNode'
15+
application {
16+
mainClass = 'org.tron.program.FullNode'
17+
}
1318

1419
def versions = [
1520
checkstyle: '8.7',
@@ -95,7 +100,7 @@ tasks.matching { it instanceof Test }.all {
95100
}
96101

97102
if (project.hasProperty("mainClass")) {
98-
mainClassName = mainClass
103+
application.mainClass = mainClass
99104
}
100105

101106
run {
@@ -167,17 +172,17 @@ tasks.register('testWithRocksDb', Test) {
167172

168173
jacocoTestReport {
169174
reports {
170-
xml.enabled true
171-
csv.enabled false
172-
html.destination file("${buildDir}/jacocoHtml")
175+
xml.required.set(true)
176+
csv.required.set(false)
177+
html.outputLocation.set(file("${buildDir}/jacocoHtml"))
173178
}
174179
getExecutionData().setFrom(fileTree('../framework/build/jacoco').include("**.exec"))
175180
}
176181

177182
def binaryRelease(taskName, jarName, mainClass) {
178183
return tasks.create("${taskName}", Jar) {
179-
baseName = jarName
180-
version = null
184+
archiveBaseName.set(jarName)
185+
archiveVersion.set("")
181186
from(sourceSets.main.output) {
182187
include "/**"
183188
}
@@ -212,7 +217,7 @@ def createScript(project, mainClass, name) {
212217
unixStartScriptGenerator.template = resources.text.fromFile('../gradle/unixStartScript.txt')
213218
windowsStartScriptGenerator.template = resources.text.fromFile('../gradle/windowsStartScript.txt')
214219
outputDir = new File(project.buildDir, 'scripts')
215-
mainClassName = mainClass
220+
getMainClass().set(mainClass)
216221
applicationName = name
217222
classpath = project.tasks[JavaPlugin.JAR_TASK_NAME].outputs.files + project.configurations.runtimeClasspath
218223
// defaultJvmOpts = ['-XX:+UseConcMarkSweepGC',
@@ -225,23 +230,34 @@ def createScript(project, mainClass, name) {
225230
// ]
226231
}
227232
project.tasks[name].dependsOn(project.jar)
228-
project.applicationDistribution.with {
233+
project.distributions.main.contents {
229234
into("bin") {
230-
from(project.tasks[name])
231-
fileMode = 0755
235+
from(project.tasks[name]) {
236+
filePermissions {
237+
unix("rwxr-xr-x")
238+
}
239+
}
232240
}
233241
}
234242
}
235-
applicationDistribution.from(rootProject.archInfo.VMOptions) {
236-
into "bin"
243+
distributions {
244+
main {
245+
contents {
246+
from(rootProject.archInfo.VMOptions) {
247+
into "bin"
248+
}
249+
}
250+
}
237251
}
238252
//distZip {
239253
// doLast {
240254
// file("$destinationDir/$archiveName").renameTo("$destinationDir/"+'java-tron-'+version+'-bin.zip')
241255
// }
242256
//}
243257
configurations.archives.artifacts.removeAll { it.type == 'tar' }
244-
applicationName = 'java-tron'
258+
application {
259+
applicationName = 'java-tron'
260+
}
245261
startScripts.enabled = false
246262
run.enabled = false
247263
tasks.distTar.enabled = false

framework/src/test/java/org/tron/core/jsonrpc/JsonrpcServiceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1487,7 +1487,7 @@ public void testWeb3ClientVersion() {
14871487
try {
14881488
String[] versions = tronJsonRpc.web3ClientVersion().split("/");
14891489
String javaVersion = versions[versions.length - 1];
1490-
Assert.assertTrue("Java1.8".equals(javaVersion) || "Java17".equals(javaVersion));
1490+
Assert.assertEquals("Java" + System.getProperty("java.specification.version"), javaVersion);
14911491
} catch (Exception e) {
14921492
Assert.fail();
14931493
}

0 commit comments

Comments
 (0)