forked from tronprotocol/java-tron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
146 lines (123 loc) · 3.71 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
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
compile fileTree(dir: 'libs', include: '*.jar')
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.13.0'
testCompile group: 'org.hamcrest', name: 'hamcrest-junit', version: '1.0.0.1'
testCompile group: 'org.testng', name: 'testng', version: '6.14.3'
// https://mvnrepository.com/artifact/com.beust/jcommander
compile group: 'com.beust', name: 'jcommander', version: '1.78'
compile 'com.github.halibobo1205.leveldb-java:leveldb:v0.12.5'
compile 'com.github.halibobo1205.leveldb-java:leveldb-api:v0.12.5'
}
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'
}
jacoco {
destinationFile = file("$buildDir/jacoco/jacocoTest.exec")
classDumpDir = file("$buildDir/jacoco/classpathdumps")
}
}
jacocoTestReport {
reports {
xml.enabled true
csv.enabled false
html.destination file("${buildDir}/jacocoHtml")
}
executionData.from = 'build/jacoco/jacocoTest.exec'
}
def binaryRelease(taskName, jarName, mainClass) {
return tasks.create("${taskName}", Jar) {
baseName = jarName
version = null
from(sourceSets.main.output) {
include "/**"
}
from {
configurations.compile.collect {
it.isDirectory() ? it : zipTree(it)
}
}
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.runtime
}
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')
def releaseBinary = hasProperty('binaryRelease') ? getProperty('binaryRelease') : 'true'
if (releaseBinary == 'true') {
artifacts {
archives(binaryRelease('buildArchiveManifestJar', 'ArchiveManifest', 'org.tron.plugins.ArchiveManifest'))
}
}
task copyToParent(type: Copy) {
into "../build/distributions"
from "$buildDir/distributions"
include "*.zip"
}
build.finalizedBy(copyToParent)