forked from jodconverter/jodconverter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
255 lines (199 loc) · 7.8 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
// Import the content of the libraries.gradle file
apply from: "dependencies.gradle"
description = 'JODConverter'
// External dependencies for the build script
buildscript {
// Gradle will not find vars defined in an external file when referring to them
// in the buildscript block, unless you link it from the buildscript block, too.
apply from: "dependencies.gradle"
repositories {
mavenCentral()
//Needed only for SNAPSHOT versions
//maven { url "http://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://plugins.gradle.org/m2" }
}
dependencies {
classpath gradlePlugins.coveralls
classpath gradlePlugins.dependency_management
classpath gradlePlugins.nebula_project
classpath gradlePlugins.nexus_staging
classpath gradlePlugins.spotless
}
}
ext {
baselineJavaVersion = JavaVersion.VERSION_1_8
sourceEncoding = "UTF-8"
// Set up different subproject lists for individual configuration
ext.javaprojects = subprojects.findAll { new File(it.projectDir, 'src/main/java').directory }
ext.releasedprojects = javaprojects.findAll { !it.name.contains('sample') }
ext.publishedprojects = releasedprojects.findAll { !it.name.contains('jodconverter-cli') }
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Configuration to apply to all the projects
allprojects {
// Add the clean task to all the project
apply plugin: 'base'
// Generates files for Intellij IDEA
apply plugin: 'idea'
// Generates files for Eclipse
apply plugin: 'eclipse'
// Generate reports containing useful information about the build (tasks, dependencies, properties)
apply plugin: 'project-report'
apply plugin: "maven"
// Set the group and current version
group = groupId
version = currentVersion
// Set the maven repository that looks for plugin dependencies.
repositories {
mavenCentral()
}
// Eclipse setup
// Workaround until https://github.com/gradle/gradle/issues/898
// is resolved.
// Several files have UTF-8 encoding and Eclipse running on Windows
// will have trouble unless we tell it to use UTF-8 encoding. This
// setting needs to go into the org.eclipse.core.resources.prefs file,
// which the project script isn't set up to configure.
eclipse {
ext.corePrefsPath = '.settings/org.eclipse.core.resources.prefs'
ext.genCorePrefs = {
File corePrefs = file(corePrefsPath)
corePrefs.parentFile.mkdirs()
corePrefs.text = """\
eclipse.preferences.version=1
encoding/<project>=UTF-8
""".stripIndent()
}
project {
file {
// Will be applied when the project is imported into Eclipse
genCorePrefs()
}
}
// Will be applied after the eclipseProject task
eclipseProject.doLast {
genCorePrefs()
}
// Will be applied after the cleanEclipse task
cleanEclipse.doLast {
delete corePrefsPath
}
}
tasks.eclipse.dependsOn(cleanEclipse)
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Java projects configuration
// Apply the configuration for the java projects only
configure(javaprojects) {
// Spotless needs a buildscript repository for all java project
buildscript {
repositories {
maven { url "https://plugins.gradle.org/m2" }
}
}
// Apply the gradle file specific to all java projects
apply from: "$rootDir/gradle/java-projects.gradle"
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Code quality control coverage (JaCoCo)
// We need JacocoMerge to aggregate sub projects report
apply plugin: 'jacoco'
// Send coverage data to coveralls.io
apply plugin: 'com.github.kt3k.coveralls'
// Configures the JaCoCo plugin
jacoco {
toolVersion = versions.jacoco_version
}
// Creates an aggregated JaCoCo executionData for all
// the tests (unit tests and integration tests) found
// in sub Java projects
task jacocoMerge(type: JacocoMerge) {
description = 'Aggregates JaCoCo test and integration test coverage reports of all projects.'
group = "Reporting"
// Gather execution data from all subprojects
releasedprojects.each { subproject ->
executionData subproject.tasks.withType(Test)
}
doFirst {
executionData = files(executionData.findAll { it.exists() })
}
}
// Code coverage report for all the sub (java) projects
task jacocoRootReport(type: JacocoReport, group: 'Coverage reports') {
description = 'Generates an aggregate report from all subprojects'
dependsOn releasedprojects.test, releasedprojects.integrationTest, jacocoMerge
additionalSourceDirs = files(releasedprojects.sourceSets.main.allSource.srcDirs)
sourceDirectories = files(releasedprojects.sourceSets.main.allSource.srcDirs)
classDirectories = files(releasedprojects.sourceSets.main.output)
executionData jacocoMerge.destinationFile
reports {
html.enabled = true // human readable
xml.enabled = true // required by coveralls
}
}
coveralls {
sourceDirs = releasedprojects.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
onlyIf { System.env.'CI' }
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Distribution configuration
configure(releasedprojects) {
apply plugin: 'distribution'
// exclude jodconverter-cli since it has its own distribution configuration
if (!project.name.contains('jodconverter-cli')) {
distributions {
main {
baseName = project.name
contents {
from jar, sourcesJar, javadocJar
}
}
}
}
}
// Copy all the distributions of the subprojects to the root project
task distZip(type: Zip) {
description "Create full distribution zip"
baseName project.name
group "Distribution"
//from releasedprojects.collect { it.tasks.matching { it.name == 'distZip' || it.name == 'distTar' } }
from releasedprojects.collect { it.distZip }
}
project.tasks["distZip"].dependsOn releasedprojects*.distZip
//project.tasks["distZip"].dependsOn releasedprojects*.assembleDist
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Publishing configuration
// Add the ability to release to Maven Central from Gradle without dealing with Nexus UI
apply plugin: "io.codearte.nexus-staging"
nexusStaging {
username = findProperty('ossrhUsername')
password = findProperty('ossrhPassword')
}
// Apply the configuration for the published projects only
configure(publishedprojects) {
// Apply the gradle file specific to all published projects
apply from: "$rootDir/gradle/published-projects.gradle"
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Utilities
task printConfigurations {
group "Help"
doLast {
subprojects.findAll().each { p ->
println "${p}"
p.configurations.each { println " | " + it.name }
println ""
}
}
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~