-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbuild.gradle
141 lines (118 loc) · 3.87 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
plugins {
id "io.spring.dependency-management" version "1.0.6.RELEASE"
id 'com.github.kt3k.coveralls' version '2.8.2'
id 'application'
}
apply plugin: 'com.github.kt3k.coveralls'
allprojects {
apply plugin: 'java-library'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'jacoco'
apply from: "${rootDir}/versions.gradle"
version = rootProject.version
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
dependencies {
implementation 'com.google.code.findbugs:jsr305'
implementation 'org.javatuples:javatuples'
implementation 'org.apache.logging.log4j:log4j-api:2.11.2'
testImplementation 'junit:junit'
testImplementation 'org.assertj:assertj-core'
}
repositories {
jcenter()
maven { url "https://jitpack.io" }
maven { url "https://dl.bintray.com/libp2p/jvm-libp2p" }
}
task allDependencies(type: DependencyReportTask) {}
// Customize module jars so every module and sub-module receives right name
tasks.withType(Jar) {
def titleAddon = ''
if (rootProject == project) {
baseName = project.name
} else {
def projectCustomName = project.path.replaceAll(":", "-");
baseName = rootProject.name + projectCustomName
titleAddon = ' ' + projectCustomName.substring(1) // cut starting -
}
manifest {
attributes('Implementation-Title': rootProject.title + titleAddon,
'Implementation-Version': project.version)
}
}
javadoc {
options.author = true
options.header = project.name
options.addStringOption('-quiet')
options.encoding = "UTF-8"
options.links(
"http://docs.oracle.com/javase/8/docs/api/"
)
}
jacoco {
toolVersion = '0.8.2'
}
jacocoTestReport {
reports {
xml.enabled = true
html.enabled = true
}
}
}
def allSubProjects = subprojects.findAll()
jacoco {
toolVersion = "0.8.3"
}
task jacocoMerge(type: JacocoMerge) {
allSubProjects.each { subproject ->
executionData(new File(subproject.buildDir, 'jacoco/test.exec'))
}
doFirst {
executionData = files(executionData.findAll { it.exists() })
}
for (project in allSubProjects) {
dependsOn project.path + ":jacocoTestReport"
}
}
task jacocoRootReport(type: JacocoReport, group: 'Coverage reports') {
description = 'Generates an aggregate report from all subprojects'
dependsOn allSubProjects.test, tasks.jacocoMerge
additionalSourceDirs = files(allSubProjects.sourceSets.main.allSource.srcDirs)
sourceDirectories = files(allSubProjects.sourceSets.main.allSource.srcDirs)
classDirectories = files(allSubProjects.sourceSets.main.output)
executionData = files(tasks.jacocoMerge.destinationFile)
reports {
html.enabled = true // human readable
xml.enabled = true // required by coveralls
}
}
coveralls {
sourceDirs = allSubProjects.sourceSets.main.allSource.srcDirs.flatten()
jacocoReportPath = "${buildDir}/reports/jacoco/jacocoRootReport/jacocoRootReport.xml"
}
tasks.coveralls {
group = 'Coverage reports'
description = 'Uploads the aggregated coverage report to Coveralls'
dependsOn jacocoRootReport
}
// We have enabled `application` plugin but we don't need its default behavior
// Instead we will use it via createScript() method when it's needed
startScripts.enabled = false
// Creates executable scripts for entry points
// Subproject must apply application plugin to be able to call this method.
def createScript(project, mainClass, name) {
project.tasks.create(name: name, type: CreateStartScripts) {
outputDir = new File(project.buildDir, 'scripts')
mainClassName = mainClass
applicationName = name
classpath = project.startScripts.classpath + project.configurations.runtime
}
project.tasks[name].dependsOn(project.jar)
project.applicationDistribution.with {
into("bin") {
from(project.tasks[name])
fileMode = 0755
duplicatesStrategy = 'exclude'
}
}
}