forked from SDA-SE/sda-dropwizard-commons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
189 lines (159 loc) · 5.31 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
buildscript {
repositories {
maven { url "https://plugins.gradle.org/m2/" }
}
}
plugins {
id 'java'
id 'maven-publish'
id 'jacoco'
id 'org.sonarqube' version '2.8'
id 'com.diffplug.gradle.spotless' version '3.28.0'
}
allprojects {
apply plugin: 'idea'
idea.module.inheritOutputDirs = true
}
// we need a repository for the combination of jacoco and sonarcloud
repositories {
mavenCentral()
}
subprojects {
apply plugin: 'maven-publish'
apply plugin: 'com.diffplug.gradle.spotless'
group 'org.sdase.commons'
repositories {
mavenCentral()
maven { url "http://packages.confluent.io/maven/" } // for sda-commons-server-kafka-confluent-testing only
}
spotless {
if (project.name != 'sda-commons-bom' && project.name != 'sda-commons-dependencies') {
java {
googleJavaFormat()
}
}
groovyGradle {
greclipse()
indentWithSpaces(2)
}
}
// TODO: reenable this setting on a new ci environment
// tasks.withType(Test) {
// maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
// }
version = System.getenv('SEMANTIC_VERSION')
publishing {
repositories {
maven {
def releasesRepoUrl = "https://nexus.intern.sda-se.online/repository/sda-se-releases/"
def snapshotsRepoUrl = "https://nexus.intern.sda-se.online/repository/sda-se-snapshots/"
url = version.endsWith('-SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username System.getenv('SDA_NEXUS_USER')
password System.getenv('SDA_NEXUS_PASSWORD')
}
}
}
}
}
/**
* Configure all regular submodules (all except the bom module)
*
* Problem is: You can't apply plugins 'java' and 'java-platform' at the same time.
*/
configure(subprojects.findAll {it.name != 'sda-commons-bom' && it.name != 'sda-commons-dependencies'}) {
apply plugin: 'java'
apply plugin: 'jacoco'
sourceCompatibility = 1.8
// Configure JaCoCo to export the reports in XML format
jacocoTestReport {
reports {
xml.enabled true
}
}
// Configure sonar to use the aggregated global report file
sonarqube {
properties {
property "sonar.coverage.jacoco.xmlReportPaths", '../build/reports/jacoco/report.xml'
}
}
dependencies {
compile enforcedPlatform(project(':sda-commons-dependencies'))
}
sourceSets {
main {
output.resourcesDir = output.classesDirs.singleFile
}
test {
output.resourcesDir = output.classesDirs.singleFile
}
}
configurations.all {
resolutionStrategy {
// fail eagerly on version conflict (includes transitive dependencies)
// e.g. multiple different versions of the same dependency (group and name are equal)
failOnVersionConflict()
}
}
}
/**
* Add publishing configuration for Java modules.
*
* More Infos:
* - sda-commons-bom uses own publishing because it's just a BOM
* - example modules and dependency-check should not be published at all
*/
List<String> unpublishedModules = Arrays.asList("sda-commons-bom", "sda-commons-dependencies", "sda-commons-dependency-check")
configure(subprojects.findAll {
!unpublishedModules.contains(it.name) && !it.name.endsWith("-example")
}) {
task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier = 'sources'
from sourceSets.main.allJava
}
publishing {
publications {
maven(MavenPublication) {
from components.java
artifact sourcesJar
}
}
}
jar {
into("META-INF/maven/$project.group/$project.name") {
from { generatePomFileForMavenPublication }
rename ".*", "pom.xml"
}
}
}
// Reconfigure the testReport task to display the results of all modules into a single report
task testReport(type: TestReport) {
destinationDir = file("$buildDir/reports/allTests")
// Include the results from the `test` task in all subprojects
reportOn subprojects.findAll {it.name != 'sda-commons-bom' && it.name != 'sda-commons-dependencies'}*.test
}
// Create a combined XML report of all modules in the root project
task codeCoverageReport(type: JacocoReport) {
executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")
subprojects.each {
// noinspection GroovyAssignabilityCheck
sourceSets it.sourceSets.main
}
reports {
xml.enabled = true
xml.destination file("${buildDir}/reports/jacoco/report.xml")
}
}
sonarqube {
properties {
property 'sonar.projectKey', 'SDA-SE_sda-dropwizard-commons'
property 'sonar.organization', 'sda-se'
property 'sonar.host.url', 'https://sonarcloud.io'
property 'sonar.login', System.getenv('SONAR_LOGIN_TOKEN')
property 'sonar.pullrequest.provider', 'GitHub'
property 'sonar.pullrequest.github.repository', System.getenv('GITHUB_REPOSITORY')
if (System.getenv('GITHUB_PR') != null) {
property 'sonar.pullrequest.key', System.getenv('GITHUB_PR')
}
}
}