forked from tronprotocol/java-tron
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
167 lines (147 loc) · 6.13 KB
/
build.gradle
File metadata and controls
167 lines (147 loc) · 6.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
import org.gradle.nativeplatform.platform.internal.Architectures
import org.gradle.internal.os.OperatingSystem
allprojects {
version = "1.0.0"
apply plugin: "java-library"
ext {
springVersion = "5.3.39"
}
}
def arch = System.getProperty("os.arch").toLowerCase()
def javaVersion = JavaVersion.current()
def isArm64 = Architectures.AARCH64.isAlias(arch)
def archSource = isArm64 ? "arm" : "x86"
def isMac = OperatingSystem.current().isMacOsX()
ext.archInfo = [
name : arch,
java : javaVersion,
isArm64 : isArm64,
sourceSets: [
main: [
java: [
srcDirs: ["src/main/java/common", "src/main/java/${archSource}"]
]
],
test: [
java: [
srcDirs: ["src/test/java"]
]
]
],
requires: [
JavaVersion: isArm64 ? JavaVersion.VERSION_17 : JavaVersion.VERSION_1_8,
RocksdbVersion: isArm64 ? '9.7.4' : '5.15.10',
// https://github.com/grpc/grpc-java/issues/7690
// https://github.com/grpc/grpc-java/pull/12319, Add support for macOS aarch64 with universal binary
// https://github.com/grpc/grpc-java/pull/11371 , 1.64.x is not supported CentOS 7.
ProtocGenVersion: isArm64 && isMac ? '1.76.0' : '1.60.0'
],
VMOptions: isArm64 ? "${rootDir}/gradle/jdk17/java-tron.vmoptions" : "${rootDir}/gradle/java-tron.vmoptions"
]
if (!archInfo.java.is(archInfo.requires.JavaVersion)) {
throw new GradleException("Java ${archInfo.requires.JavaVersion} is required for ${archInfo.name}. Detected version ${archInfo.java}")
}
println "Building for architecture: ${archInfo.name}, Java version: ${archInfo.java}"
subprojects {
apply plugin: "jacoco"
apply plugin: "maven-publish"
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.current()
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
jacoco {
toolVersion = "0.8.12" // see https://www.jacoco.org/jacoco/trunk/doc/changes.html
}
buildscript {
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.9.1'
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' }
}
dependencies {
implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
implementation group: 'org.slf4j', name: 'jcl-over-slf4j', version: '1.7.25'
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.13'
implementation "com.google.code.findbugs:jsr305:3.0.0"
implementation group: 'org.springframework', name: 'spring-context', version: "${springVersion}"
implementation "org.apache.commons:commons-lang3:3.4"
implementation group: 'org.apache.commons', name: 'commons-math', version: '2.2'
implementation "org.apache.commons:commons-collections4:4.1"
implementation group: 'joda-time', name: 'joda-time', version: '2.3'
implementation group: 'org.bouncycastle', name: 'bcprov-jdk18on', version: '1.79'
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'
// 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'
// for json-rpc, see https://github.com/briandilley/jsonrpc4j/issues/278
implementation group: 'javax.jws', name: 'javax.jws-api', version: '1.1'
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"
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
duplicatesStrategy = DuplicatesStrategy.INCLUDE // allow duplicates
}
tasks.withType(AbstractArchiveTask) {
preserveFileTimestamps = false
reproducibleFileOrder = true
duplicatesStrategy = DuplicatesStrategy.INCLUDE // allow duplicates
}
tasks.withType(Test).configureEach {
// https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html#org.gradle.api.tasks.testing.Test:environment
environment 'CI', 'true'
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
configurations.configureEach {
resolutionStrategy {
eachDependency { details ->
if (details.requested.group == 'com.google.guava' &&
details.requested.name == 'guava') {
def requestedVersion = details.requested.version
if (requestedVersion.matches(/.*-android$/)) {
def jreVersion = requestedVersion.replaceAll(/-android$/, '-jre')
details.useVersion(jreVersion)
details.because("Automatically replace android guava with jre version: ${requestedVersion} -> ${jreVersion}")
}
}
}
}
}
}
task copyToParent(type: Copy) {
into "$buildDir/libs"
subprojects {
from tasks.withType(Jar)
}
}
build.finalizedBy(copyToParent)
gradle.buildFinished {
if (project.hasProperty('cleanSubBuild')) {
subprojects {
buildDir.deleteDir()
}
}
}