forked from 4finance/micro-infra-spring
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
239 lines (199 loc) · 7.79 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
buildscript {
repositories {
mavenLocal()
jcenter()
maven { url "https://plugins.gradle.org/m2/" } //for sonarqube plugin
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:1.4.0.RELEASE"
classpath 'com.ofg:uptodate-gradle-plugin:+'
classpath "com.ofg:micro-common-release:0.1.18"
classpath "io.spring.gradle:dependency-management-plugin:0.5.6.RELEASE"
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:+"
if (project.hasProperty("coverage")) {
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:+'
classpath "org.sonarqube.gradle:gradle-sonarqube-plugin:1.0"
}
}
dependencies {
ant.unjar src: configurations.classpath.find { it.name.startsWith("micro-common-release") }, dest: 'build/release'
}
}
apply from: "${rootProject.buildDir}/release/gradle/version.gradle"
scmVersion {
tag {
prefix = 'release'
versionSeparator = '/'
}
}
allprojects {
group = 'com.ofg'
project.version = scmVersion.version
}
Set emptySubprojects = [project(':swagger'), project(':micro-deps-root'), project(':stub-runner-root')]
Set srcSubprojects = subprojects - emptySubprojects
configure(srcSubprojects) {
apply plugin: 'groovy'
apply from: "${rootProject.buildDir}/release/gradle/publish.gradle"
bintray {
pkg {
repo = project.name.startsWith("micro-deps") ? 'micro-deps' : 'micro'
vcsUrl = 'https://github.com/4finance/micro-infra-spring.git'
}
}
}
apply from: "${rootProject.buildDir}/release/gradle/release.gradle"
//NOTE: All release and publishing modifications (including further scmVersion closure) should be put AFTER the apply of publish.gradle and/or release.gradle
// (to be not overridden by the default values applied in those files)
allprojects {
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
configurations {
all {
resolutionStrategy {
exclude group: 'log4j', module: 'log4j'
force 'org.apache.httpcomponents:httpclient:4.5.2+'
force 'org.jboss.logging:jboss-logging:3.3.0.Final'
eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'org.slf4j') { details.useVersion '1.7.21' }
if (details.requested.group == 'com.fasterxml.jackson.core') { details.useVersion '2.8.1' }
// To prevent an accidental usage of groovy-all.jar and groovy.jar in different versions
// all modularized Groovy jars are replaced with groovy-all.jar by default.
if (details.requested.group == 'org.codehaus.groovy' && details.requested.name != "groovy-all") {
details.useTarget("org.codehaus.groovy:groovy-all:${details.requested.version}")
}
if (details.requested.group == 'org.aspectj') { details.useVersion '1.8.9' }
}
}
}
}
}
task addHashFile << {
String gitCmd = "git log --pretty=format:'%H' -n 1"
def proc = gitCmd.execute()
proc.waitFor()
project.buildDir.mkdirs()
new File(project.buildDir, "commitHash.txt").withWriter { it << proc.in.text }
}
configure(emptySubprojects + rootProject) {
apply plugin: 'base'
}
configure(srcSubprojects) {
apply plugin: 'com.ofg.uptodate'
apply plugin: "io.spring.dependency-management"
sourceCompatibility = 1.8
dependencyManagement {
imports {
mavenBom 'org.springframework.cloud:spring-cloud-starter-parent:Brixton.SR4'
}
dependencies {
dependency "org.codehaus.groovy:groovy-all:2.4.7"
dependency "com.google.guava:guava:19.0"
dependency "commons-io:commons-io:2.4"
dependencySet(group:"org.apache.curator", version: "2.8.0") {
entry "curator-x-discovery"
entry "curator-test"
}
//test
dependency "ch.qos.logback:logback-classic:1.1.7"
dependency "com.jayway.restassured:rest-assured:2.9.0"
dependency "com.github.tomakehurst:wiremock:2.0.10-beta"
dependency "cglib:cglib-nodep:3.2.0"
dependency "org.objenesis:objenesis:2.1"
dependencySet(group:'org.spockframework', version: '1.0-groovy-2.4') {
entry "spock-core"
entry "spock-spring"
}
dependency "info.solidsoft.spock:spock-global-unroll:0.5.0"
dependencySet(group:'com.jayway.awaitility', version: '1.7.0') {
entry "awaitility"
entry "awaitility-groovy"
}
}
}
test {
jvmArgs project.gradle.startParameter.systemPropertiesArgs.entrySet().collect{"-D${it.key}=${it.value}"}
jvmArgs '-XX:MaxPermSize=256m', '-Xmx512m'
testLogging {
exceptionFormat = 'full'
}
maxHeapSize = "2g"
maxParallelForks = project.hasProperty('parallel') ? Runtime.runtime.availableProcessors() : 1
}
jar {
dependsOn addHashFile
from new File(project.buildDir, "commitHash.txt")
}
//Dependencies in all subprojects - http://solidsoft.wordpress.com/2014/11/13/gradle-tricks-display-dependencies-for-all-subprojects-in-multi-project-build/
task allDeps(type: DependencyReportTask) {}
task allInsight(type: DependencyInsightReportTask) {}
configurations {
jansi.extendsFrom(runtime)
}
groovydoc {
def title = "IPDS ${version}"
groovyClasspath = project.configurations.jansi
}
dependencies {
jansi 'org.fusesource.jansi:jansi:1.12'
}
}
if (project.hasProperty("coverage")) {
configure(srcSubprojects + rootProject) {
apply plugin: 'jacoco'
}
apply plugin: 'com.github.kt3k.coveralls'
apply plugin: 'org.sonarqube'
sonarqube {
properties {
property "sonar.projectName", "micro-infra-spring"
}
}
configure(srcSubprojects) {
jacocoTestReport {
reports {
xml.enabled = true // coveralls plugin depends on xml format report
}
}
test {
jacoco {
excludes = ['*Configuration', 'repackaged.*']
}
}
sonarqube {
properties {
property "sonar.groovy.jacoco.reportPath", "$buildDir/jacoco/test.exec" //TODO: Could be taken from JaCoCo extension directly
property "sonar.exclusions", "**/src/main/resources/static/swagger/**"
}
}
}
coveralls {
sourceDirs = files(srcSubprojects.sourceSets.main.allSource.srcDirs).files.absolutePath
}
task jacocoRootReport(type: JacocoReport) {
// Gather execution data from all subprojects
// (change this if you e.g. want to calculate unit test/integration test coverage separately)
executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")
// Add all relevant sourcesets from the subprojects
srcSubprojects.each {
sourceSets it.sourceSets.main
}
reports {
xml.enabled true
xml.destination "${buildDir}/reports/jacoco/test/jacocoTestReport.xml"
}
}
// always run the tests before generating the report
jacocoRootReport.dependsOn {
srcSubprojects*.test
srcSubprojects*.jacocoTestReport
}
}
//Individual HTML test reports could be disabled to speed up build a little bit if testReport was the only one used - http://stackoverflow.com/a/16921750
task testReport(type: TestReport) {
destinationDir = file("$buildDir/reports/allTests")
reportOn srcSubprojects*.test
}