forked from halibobo1205/java-tron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
163 lines (140 loc) · 4.54 KB
/
build.gradle
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
plugins {
id "org.sonarqube" version "2.6"
}
apply plugin: 'application'
apply plugin: 'checkstyle'
jacoco {
toolVersion = "0.8.4"
}
def versions = [
checkstyle: '8.7',
]
mainClassName = 'org.tron.plugins.ArchiveManifest'
group 'org.tron'
version '1.0.0'
configurations {
checkstyleConfig
}
configurations.getByName('checkstyleConfig') {
transitive = false
}
dependencies {
//local libraries
implementation fileTree(dir: 'libs', include: '*.jar')
testImplementation project(":framework")
testImplementation project(":framework").sourceSets.test.output
implementation group: 'info.picocli', name: 'picocli', version: '4.6.3'
implementation group: 'com.typesafe', name: 'config', version: '1.3.2'
implementation group: 'me.tongfei', name: 'progressbar', version: '0.9.3'
implementation group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.69'
implementation group: 'org.rocksdb', name: 'rocksdbjni', version: '5.15.10'
implementation 'io.github.tronprotocol:leveldbjni-all:1.18.2'
implementation 'io.github.tronprotocol:leveldb:1.18.2'
implementation project(":protocol")
}
check.dependsOn 'lint'
checkstyle {
toolVersion = "${versions.checkstyle}"
configFile = file("../framework/config/checkstyle/checkStyleAll.xml")
}
checkstyleMain {
source = 'src/main/java'
}
task lint(type: Checkstyle) {
// Cleaning the old log because of the creation of the new ones (not sure if totaly needed)
delete fileTree(dir: "${project.rootDir}/app/build/reports")
source 'src'
include '**/*.java'
exclude 'main/gen/**'
exclude 'test/**'
// empty classpath
classpath = files()
//Failing the build
ignoreFailures = false
}
tasks.matching { it instanceof Test }.all {
testLogging.events = ["failed", "passed", "skipped"]
}
if (project.hasProperty("mainClass")) {
mainClassName = mainClass
}
test {
testLogging {
exceptionFormat = 'full'
}
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
jacoco {
destinationFile = file("../framework/build/jacoco/jacocoTest1.exec")
classDumpDir = file("$buildDir/jacoco/classpathdumps")
}
}
jacocoTestReport {
reports {
xml.enabled true
csv.enabled false
html.destination file("${buildDir}/jacocoHtml")
}
getExecutionData().setFrom(fileTree('../framework/build/jacoco').include("**.exec"))
}
def binaryRelease(taskName, jarName, mainClass) {
return tasks.create("${taskName}", Jar) {
baseName = jarName
version = null
from(sourceSets.main.output) {
include "/**"
}
from {
configurations.runtimeClasspath.collect { // https://docs.gradle.org/current/userguide/upgrading_version_6.html#changes_6.3
it.isDirectory() ? it : zipTree(it)
}
}
// exclude these files for bouncycastle
exclude "META-INF/*.SF"
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
manifest {
attributes "Main-Class": "${mainClass}"
}
}
}
def createScript(project, mainClass, name) {
project.tasks.create(name: name, type: CreateStartScripts) {
outputDir = new File(project.buildDir, 'scripts')
mainClassName = mainClass
applicationName = name
classpath = project.tasks[JavaPlugin.JAR_TASK_NAME].outputs.files + project.configurations.runtimeClasspath
}
project.tasks[name].dependsOn(project.jar)
project.applicationDistribution.with {
into("bin") {
from(project.tasks[name])
fileMode = 0755
}
}
}
applicationDistribution.from("../gradle/java-tron.vmoptions") {
into "bin"
}
createScript(project, 'org.tron.plugins.ArchiveManifest', 'ArchiveManifest')
createScript(project, 'org.tron.plugins.Toolkit', 'Toolkit')
def releaseBinary = hasProperty('binaryRelease') ? getProperty('binaryRelease') : 'true'
def skipArchive = hasProperty('skipArchive') ? true : false
def skipAll = hasProperty('skipAll') ? true : false
if (releaseBinary == 'true') {
artifacts {
archives(binaryRelease('buildToolkitJar', 'Toolkit', 'org.tron.plugins.Toolkit'))
}
if (!skipAll) {
if (!skipArchive) {
artifacts {
archives(binaryRelease('buildArchiveManifestJar', 'ArchiveManifest', 'org.tron.plugins.ArchiveManifest'))
}
}
}
}
task copyToParent(type: Copy) {
into "../build/distributions"
from "$buildDir/distributions"
include "*.zip"
}
build.finalizedBy(copyToParent)