Skip to content
Open
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
90 changes: 83 additions & 7 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
workflow_dispatch:
inputs:
job:
description: 'Job to run: all / macos / ubuntu / rockylinux / debian11'
description: 'Job to run: all / macos / ubuntu / ubuntu-jdk21 / rockylinux / debian11'
required: false
default: 'all'

Expand All @@ -29,7 +29,7 @@ jobs:
fail-fast: false
matrix:
include:
- java: '17'
- java: '21'
runner: macos-26
arch: aarch64

Expand Down Expand Up @@ -102,8 +102,61 @@ jobs:
java -jar "$JAR" db archive -h
java -jar "$JAR" keystore --help

build-ubuntu-jdk21:
name: Build ubuntu24 (JDK 21 / ${{ matrix.arch }})
if: ${{ github.event_name == 'pull_request' || inputs.job == 'all' || inputs.job == 'ubuntu-jdk21' }}
runs-on: ${{ matrix.runner }}
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
arch: x86_64
- runner: ubuntu-24.04-arm
arch: aarch64

steps:
- uses: actions/checkout@v5

- name: Set up JDK 21
uses: actions/setup-java@v5
with:
java-version: '21'
distribution: 'temurin'

- name: Check Java version
run: java -version

- name: Cache Gradle packages
uses: actions/cache@v5
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ubuntu24-jdk21-${{ matrix.arch }}-gradle-${{ hashFiles('**/*.gradle', '**/gradle-wrapper.properties') }}
restore-keys: ubuntu24-jdk21-${{ matrix.arch }}-gradle-

- name: Build
run: ./gradlew clean build --no-daemon

- name: Toolkit jar smoke test
run: |
set -e
JAR=plugins/build/libs/Toolkit.jar
java -jar "$JAR" help
java -jar "$JAR" db --help
java -jar "$JAR" db archive -h
java -jar "$JAR" keystore --help

# ARM64 already runs the suite on RocksDB; x86_64 defaults to LevelDB, so
# cover the x86 RocksDB pin (5.15.10) on JDK 21 explicitly.
- name: Test with RocksDB engine
if: ${{ matrix.arch == 'x86_64' }}
run: ./gradlew :framework:testWithRocksDb --no-daemon

docker-build-rockylinux:
name: Build rockylinux (JDK 8 / x86_64)
name: Build rockylinux (JDK 17 / x86_64)
if: ${{ github.event_name == 'pull_request' || inputs.job == 'all' || inputs.job == 'rockylinux' }}
runs-on: ubuntu-latest
timeout-minutes: 60
Expand All @@ -117,17 +170,40 @@ jobs:
LC_ALL: en_US.UTF-8

steps:
- name: Install dependencies (Rocky 8 + JDK8)
- name: Install dependencies (Rocky 8 + JDK17)
run: |
set -euxo pipefail
dnf -y install java-1.8.0-openjdk-devel git wget unzip which jq bc curl glibc-langpack-en
dnf -y install java-17-openjdk-devel git wget unzip which jq bc curl glibc-langpack-en
dnf -y groupinstall "Development Tools"

# "Development Tools" drags in java-1.8.0-openjdk-headless, and RHEL's
# alternatives priorities prefer the 1.8 family, so `java` would point
# at a JRE without javac. Pin JDK 17 explicitly.
- name: Force JDK 17 as default java
run: |
set -euxo pipefail
JAVA17_HOME="$(readlink -f /etc/alternatives/java_sdk_17)"
echo "JAVA_HOME=${JAVA17_HOME}" >> "$GITHUB_ENV"
echo "${JAVA17_HOME}/bin" >> "$GITHUB_PATH"

- name: Checkout code
uses: actions/checkout@v5

- name: Check Java version
run: java -version
- name: Verify JDK 17
run: |
set -euxo pipefail
printf 'JAVA_HOME=%s\n' "${JAVA_HOME}"
command -v java
command -v javac
test -x "${JAVA_HOME}/bin/java"
test -x "${JAVA_HOME}/bin/javac"

java_version="$(java -version 2>&1)"
javac_version="$(javac -version 2>&1)"
printf '%s\n' "${java_version}"
printf '%s\n' "${javac_version}"
printf '%s\n' "${java_version}" | grep -Eq 'version "17([.]|")'
printf '%s\n' "${javac_version}" | grep -Eq '^javac 17([.]|$)'

- name: Cache Gradle
uses: actions/cache@v5
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ ringstate.*
shareddata.*

# protobuf generated classes
src/main/gen
src/main/java/org/tron/core/bftconsensus
src/test/java/org/tron/consensus2
src/main/java/META-INF/
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ TRON is building the foundational infrastructure for the decentralized internet
Before building java-tron, make sure you have:
- Hardware with at least 4 CPU cores, 16 GB RAM, 10 GB free disk space for a smooth compilation process.
- Operating system: `Linux` or `macOS` (`Windows` is not supported).
- Git and correct JDK (version `8` or `17`) installed based on your CPU architecture.
- Git and a supported JDK: version `8` or newer on x86_64, or version `17` or newer on ARM64. The build output remains compatible with Java 8.

There are two ways to install the required dependencies:

Expand All @@ -49,7 +49,7 @@ There are two ways to install the required dependencies:
chmod +x install_dependencies.sh
./install_dependencies.sh
```
> **Note**: For production-grade stability with JDK 8 on x86_64 architecture, Oracle JDK 8 is strongly recommended (the script installs OpenJDK 8).
> **Note**: Existing compatible JDK installations are preserved. If Java is missing or too old, the script installs OpenJDK 8 on x86_64 or OpenJDK 17 on ARM64.

- **Option 2: Manual installation**

Expand Down
4 changes: 2 additions & 2 deletions actuator/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ test {

jacocoTestReport {
reports {
xml.enabled = true
html.enabled = true
xml.required = true
html.required = true
}
getExecutionData().setFrom(fileTree('../framework/build/jacoco').include("**.exec"))
afterEvaluate {
Expand Down
64 changes: 44 additions & 20 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,15 @@ ext.archInfo = [
// https://github.com/grpc/grpc-java/pull/11371 , 1.64.x is not supported CentOS 7.
ProtocGenVersion: isArm64 || isMac ? rootProject.grpcVersion : '1.60.0'
],
VMOptions: isArm64 ? "${rootDir}/gradle/jdk17/java-tron.vmoptions" : "${rootDir}/gradle/java-tron.vmoptions"
VMOptions: javaVersion.isCompatibleWith(JavaVersion.VERSION_17)
? "${rootDir}/gradle/jdk17/java-tron.vmoptions"
: "${rootDir}/gradle/java-tron.vmoptions"
Comment thread
halibobo1205 marked this conversation as resolved.
]

if (!archInfo.java.is(archInfo.requires.JavaVersion)) {
throw new GradleException("Java ${archInfo.requires.JavaVersion} is required for ${archInfo.name}. Detected version ${archInfo.java}")
if (!archInfo.java.isCompatibleWith(archInfo.requires.JavaVersion)) {
throw new GradleException(
"Java ${archInfo.requires.JavaVersion} or newer is required for ${archInfo.name}. "
+ "Detected version ${archInfo.java}")
}

println "Building for architecture: ${archInfo.name}, Java version: ${archInfo.java}"
Expand All @@ -61,33 +65,44 @@ subprojects {
apply plugin: "jacoco"
apply plugin: "maven-publish"

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.current()
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
if (project.name != 'errorprone' && javaVersion.isJava9Compatible()) {
options.release.set(8)
}
}
jacoco {
toolVersion = "0.8.12" // see https://www.jacoco.org/jacoco/trunk/doc/changes.html
toolVersion = "0.8.15" // see https://www.jacoco.org/jacoco/trunk/doc/changes.html
}
// jacocoTestReport reads this project's class and resource output; declare
// the edge explicitly so Gradle 8 task validation holds even when 'test'
// is excluded from the graph (e.g. ./gradlew build -x test).
jacocoTestReport.dependsOn(classes)

buildscript {
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url = 'https://jitpack.io' }
maven {
url "https://plugins.gradle.org/m2/"
url = "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.9.1'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.9.6'
classpath "gradle.plugin.com.github.johnrengelman:shadow:7.1.2"
}
}

repositories {
mavenLocal()
mavenCentral()
maven { url 'https://repo.spring.io/plugins-release' }
maven { url 'https://jitpack.io' }
maven { url = 'https://repo.spring.io/plugins-release' }
maven { url = 'https://jitpack.io' }
}

dependencies {
Expand All @@ -103,10 +118,10 @@ subprojects {
implementation group: 'joda-time', name: 'joda-time', version: '2.3'
implementation group: 'org.bouncycastle', name: 'bcprov-jdk18on', version: '1.84'

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'
compileOnly 'org.projectlombok:lombok:1.18.46'
annotationProcessor 'org.projectlombok:lombok:1.18.46'
testCompileOnly 'org.projectlombok:lombok:1.18.46'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.46'

// https://www.oracle.com/java/technologies/javase/11-relnote-issues.html#JDK-8190378
implementation group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2'
Expand All @@ -115,11 +130,20 @@ subprojects {
annotationProcessor group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2'

testImplementation group: 'junit', name: 'junit', version: '4.13.2'
testImplementation "org.mockito:mockito-core:4.11.0"
testImplementation "org.mockito:mockito-inline:4.11.0"
// mockito 4.11 pulls byte-buddy 1.12.19, which cannot instrument
// class-file version 65; exclude it and declare a JDK 21-capable
// version directly.
testImplementation("org.mockito:mockito-core:4.11.0") {
exclude group: 'net.bytebuddy'
}
testImplementation("org.mockito:mockito-inline:4.11.0") {
exclude group: 'net.bytebuddy'
}
testImplementation "net.bytebuddy:byte-buddy:1.17.7"
testImplementation "net.bytebuddy:byte-buddy-agent:1.17.7"
}
if (project.name != 'protocol' && project.name != 'errorprone'
&& javaVersion.isJava11Compatible()) {
&& javaVersion.isCompatibleWith(JavaVersion.VERSION_17)) {
apply plugin: 'net.ltgt.errorprone'
dependencies {
errorprone "com.google.errorprone:error_prone_core:${errorproneVersion}"
Expand All @@ -140,7 +164,7 @@ subprojects {
}

task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
archiveClassifier = "sources"
from sourceSets.main.allSource
duplicatesStrategy = DuplicatesStrategy.INCLUDE // allow duplicates
}
Expand Down
4 changes: 2 additions & 2 deletions chainbase/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ test {
jacocoTestReport {
dependsOn(processResources) // explicit_dependency
reports {
xml.enabled = true
html.enabled = true
xml.required = true
html.required = true
}
getExecutionData().setFrom(fileTree('../framework/build/jacoco').include("**.exec"))
afterEvaluate {
Expand Down
16 changes: 9 additions & 7 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ plugins {
id 'java'
}

version '1.0.0'
version = '1.0.0'

sourceCompatibility = 1.8
java {
sourceCompatibility = JavaVersion.VERSION_1_8
}


dependencies {
Expand All @@ -18,9 +20,9 @@ dependencies {
api group: 'io.prometheus', name: 'simpleclient_hotspot', version: '0.15.0'
// https://openjdk.org/jeps/396, JEP 396: Strongly Encapsulate JDK Internals by Default
// https://eclipse.dev/aspectj/doc/latest/release/JavaVersionCompatibility.html
api 'org.aspectj:aspectjrt:1.9.8'
api 'org.aspectj:aspectjweaver:1.9.8'
api 'org.aspectj:aspectjtools:1.9.8'
api 'org.aspectj:aspectjrt:1.9.25'
api 'org.aspectj:aspectjweaver:1.9.25'
// aspectjtools 1.9.25 requires JDK 17 and is not used by java-tron.
api group: 'io.github.tronprotocol', name: 'libp2p', version: '2.2.9',{
exclude group: 'io.grpc', module: 'grpc-context'
exclude group: 'io.grpc', module: 'grpc-core'
Expand All @@ -44,8 +46,8 @@ dependencies {

jacocoTestReport {
reports {
xml.enabled = true
html.enabled = true
xml.required = true
html.required = true
}
getExecutionData().setFrom(fileTree('../framework/build/jacoco').include("**.exec"))
afterEvaluate {
Expand Down
3 changes: 1 addition & 2 deletions common/src/main/java/org/tron/core/exception/TronError.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ public enum ErrCode {
RATE_LIMITER_INIT(1),
SOLID_NODE_INIT(0),
PARAMETER_INIT(1),
ACTUATOR_REGISTER(1),
JDK_VERSION(1);
ACTUATOR_REGISTER(1);

private final int code;

Expand Down
4 changes: 2 additions & 2 deletions consensus/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ test {

jacocoTestReport {
reports {
xml.enabled = true
html.enabled = true
xml.required = true
html.required = true
}
getExecutionData().setFrom(fileTree('../framework/build/jacoco').include("**.exec"))
afterEvaluate {
Expand Down
10 changes: 6 additions & 4 deletions crypto/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ plugins {
id 'java'
}

version '1.0.0'
version = '1.0.0'

sourceCompatibility = 1.8
java {
sourceCompatibility = JavaVersion.VERSION_1_8
}

repositories {
mavenCentral()
Expand All @@ -16,8 +18,8 @@ dependencies {

jacocoTestReport {
reports {
xml.enabled = true
html.enabled = true
xml.required = true
html.required = true
}
getExecutionData().setFrom(fileTree('../framework/build/jacoco').include("**.exec"))
afterEvaluate {
Expand Down
Loading
Loading