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

feature(build): update gradle from 4.0 to 6.3 #745

Open
wants to merge 9 commits into
base: release_v4.7.6
Choose a base branch
from
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
95 changes: 50 additions & 45 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,22 @@ sourceCompatibility = 1.8
targetCompatibility = JavaVersion.VERSION_1_8
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

compileJava.options*.compilerArgs = [
"-Xlint:serial", "-Xlint:varargs", "-Xlint:classfile", "-Xlint:dep-ann",
"-Xlint:divzero", "-Xlint:empty", "-Xlint:finally", "-Xlint:overrides",
"-Xlint:path", "-Xlint:static", "-Xlint:try", "-Xlint:fallthrough",
"-Xlint:deprecation", "-Xlint:unchecked", "-Xlint:-options"
]
//compileJava.options*.compilerArgs = [
// "-Xlint:serial", "-Xlint:varargs", "-Xlint:classfile", "-Xlint:dep-ann",
// "-Xlint:divzero", "-Xlint:empty", "-Xlint:finally", "-Xlint:overrides",
// "-Xlint:path", "-Xlint:static", "-Xlint:try", "-Xlint:fallthrough",
// "-Xlint:deprecation", "-Xlint:unchecked", "-Xlint:-options"
//]

repositories {
mavenLocal()
mavenCentral()
maven { url 'https://jitpack.io' }
}

def protobufVersion = "3.25.5"
def grpcVersion = "1.60.0"

sourceSets {
main {
proto {
Expand All @@ -33,8 +36,8 @@ sourceSets {
srcDir 'src/main/java'
}
}

}

buildscript {
repositories {
mavenLocal()
Expand All @@ -43,59 +46,57 @@ buildscript {
}
mavenCentral()
}
ext {
projectVersion = '1.3.0-RELEASE'
grpcVersion = '1.60.0'
protobufVersion = '3.21.12'
protobufGradlePluginVersion = '0.8.0'
}

dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.3'
classpath "gradle.plugin.com.liferay:gradle-plugins-node:4.3.0"
classpath 'com.github.jengelman.gradle.plugins:shadow:5.2.0'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.12'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In line 51, this version is 7.1.2 in java-tron.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which dependency ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

classpath "gradle.plugin.com.github.johnrengelman:shadow:7.1.2" . This version of Shadow supports Gradle 7.0+ only. So 5.2.0 is available.

classpath "gradle.plugin.com.liferay:gradle-plugins-node:7.0.2"
}
}

task wrapper(type: Wrapper) {
gradleVersion = '3.3'
}

dependencies {
compile group: 'junit', name: 'junit', version: '4.13.2'
compile group: 'com.beust', name: 'jcommander', version: '1.82'
implementation group: 'junit', name: 'junit', version: '4.13.2'
implementation group: 'com.beust', name: 'jcommander', version: '1.82'
//compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
compile group: 'org.slf4j', name: 'jcl-over-slf4j', version: '1.7.25'
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.13'

// google grpc
compile group: 'io.grpc', name: 'grpc-netty', version: "${grpcVersion}"
compile group: 'io.grpc', name: 'grpc-protobuf', version: "${grpcVersion}"
compile group: 'io.grpc', name: 'grpc-stub', version: "${grpcVersion}"

compile group: 'com.googlecode.protobuf-java-format', name: 'protobuf-java-format', version: '1.4'
compile group: 'org.bouncycastle', name: 'bcprov-jdk18on', version: '1.78.1'
compile group: 'com.typesafe', name: 'config', version: '1.3.2'
compile "org.apache.commons:commons-lang3:3.14.0"
compile group: 'com.google.api.grpc', name: 'googleapis-common-protos', version: '0.0.3'
compile 'com.alibaba:fastjson:1.2.83'

compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.16.1'
compile group: 'org.projectlombok', name: 'lombok', version: '1.18.2'

compile group: 'org.jline', name: 'jline', version: '3.25.0'
compile 'io.github.tronprotocol:zksnark-java-sdk:1.0.0'
implementation group: 'org.slf4j', name: 'jcl-over-slf4j', version: '1.7.25'
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.13'

// grpc
implementation group: 'io.grpc', name: 'grpc-netty', version: grpcVersion
implementation group: 'io.grpc', name: 'grpc-protobuf', version: grpcVersion
implementation group: 'io.grpc', name: 'grpc-stub', version: grpcVersion

// google protobuf
implementation group: 'com.google.protobuf', name: 'protobuf-java', version: protobufVersion
implementation group: 'com.google.protobuf', name: 'protobuf-java-util', version: protobufVersion

implementation group: 'com.google.code.gson', name: 'gson', version: '2.11.0'

implementation group: 'com.googlecode.protobuf-java-format', name: 'protobuf-java-format', version: '1.4'
implementation group: 'org.bouncycastle', name: 'bcprov-jdk18on', version: '1.78.1'
implementation group: 'com.typesafe', name: 'config', version: '1.3.2'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.14.0'
implementation group: 'com.alibaba', name: 'fastjson', version: '1.2.83'
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.16.1'

compileOnly 'org.projectlombok:lombok:1.18.24'
annotationProcessor 'org.projectlombok:lombok:1.18.24'
testCompileOnly 'org.projectlombok:lombok:1.18.24'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.24'

implementation group: 'org.jline', name: 'jline', version: '3.25.0'
implementation group: 'io.github.tronprotocol', name: 'zksnark-java-sdk', version: '1.0.0'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's best to keep these upgraded versions consistent with Java tron.

Copy link
Contributor Author

@317787106 317787106 Sep 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version of grpc、protobuf is same as that used in java-tron. Other dependency is not very important. jline and zksnark-java-sdk is not changed.

}

protobuf {
generatedFilesBaseDir = "$projectDir/src/"
generatedFilesBaseDir = "$projectDir/src"
protoc {
artifact = "com.google.protobuf:protoc:${protobufVersion}"

artifact = "com.google.protobuf:protoc:$protobufVersion"
}
plugins {
grpc {
artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
artifact = "io.grpc:protoc-gen-grpc-java:$grpcVersion"
}
}
generateProtoTasks {
Expand All @@ -114,6 +115,10 @@ protobuf {
}
}

clean.doFirst {
delete "src/main/gen"
}

run {
standardInput = System.in
mainClassName = 'org.tron.walletcli.Client'
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use ./gradlew wrapper --gradle-version=6.3 ?

5 changes: 3 additions & 2 deletions src/main/java/org/tron/keystore/StringUtils.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ public static boolean isContains(char[] a, char[] b) {
if (ArrayUtils.isEmpty(a) || ArrayUtils.isEmpty(b)) {
return false;
}

int alen = a.length;
int blen = b.length;

if (alen < blen) {
return false;
}
for (int i = 0; i < alen; i++) {
if (alen - i < blen) {
return false;
Expand Down
11 changes: 10 additions & 1 deletion src/test/java/org/tron/keystore/StringUtilsTest.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

public class StringUtilsTest {


@Test
public void isCharEqual() {
char[] a = "aaaaaa".toCharArray();
Expand All @@ -30,6 +29,16 @@ public void isContains() {
char[] b = "ghijkl".toCharArray();
char[] c = "defghi".toCharArray();
char[] d = "abcdefghijkl".toCharArray();
char[] empty = "".toCharArray();

char[] longarr = "xxxxxxxx123xxxxxxxxx".toCharArray();
char[] shortarr = "123".toCharArray();
Assert.assertFalse(StringUtils.isContains(shortarr, longarr));
Assert.assertTrue(StringUtils.isContains(longarr, shortarr));

Assert.assertFalse(StringUtils.isContains(empty, d));
Assert.assertFalse(StringUtils.isContains(d, empty));

Assert.assertTrue(StringUtils.isContains(d, d));
Assert.assertTrue(StringUtils.isContains(d, a));
Assert.assertTrue(StringUtils.isContains(d, b));
Expand Down