-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.gradle
227 lines (187 loc) · 6.94 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
plugins {
id 'com.diffplug.gradle.spotless' version '3.17.0' apply false
id 'com.gradle.build-scan' version '2.2.1'
id 'org.sonarqube' version '2.7.1'
id 'nebula.release' version '9.2.0'
}
description 'Softbank Payment for JAVA'
ext {
gradleDir = "${rootProject.rootDir}/gradle"
javaprojects = subprojects.findAll { new File(it.projectDir, 'src/main/java').directory }
publishedprojects = javaprojects.findAll { !it.name.contains('sample') }
}
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
if (System.getenv('CI')) {
tag 'CI'
if (System.getenv('TRAVIS')) {
link "TRAVIS BUILD", System.getenv("TRAVIS_BUILD_WEB_URL")
}
} else {
tag 'Local'
}
tag System.getProperty('os.name')
if (project.hasProperty('gitter.url')) {
buildFinished { buildResult ->
buildScanPublished { scan ->
['curl', '-s', '-d', "message=Build scan: ${scan.buildScanUri}", project.property('gitter.url')].execute()
}
}
}
}
// Configuration to apply to all the projects
allprojects {
apply plugin: 'vogle.base'
// Set the maven repository that looks for plugin dependencies.
repositories {
mavenCentral()
}
}
// Configuration to apply to JAVA Projects
configure(javaprojects) {
// Adds Java compilation along with testing and bundling capabilities
apply plugin: 'vogle.java-library'
sourceCompatibility = 1.8
targetCompatibility = 1.8
// Provides spring dependency management functionality
dependencyManagement {
dependencies {
dependency 'org.apache.httpcomponents:httpclient:4.5.8'
dependency 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.9.8'
dependency 'org.hibernate.validator:hibernate-validator:6.0.17.Final'
dependency 'org.slf4j:slf4j-api:1.7.26'
dependency 'ch.qos.logback:logback-classic:1.2.3'
dependency 'org.glassfish:javax.el:3.0.1-b11'
dependency 'javax.servlet:javax.servlet-api:4.0.1'
dependency 'junit:junit:4.12'
dependency 'org.assertj:assertj-core:3.12.0'
dependency 'org.mockito:mockito-core:2.28.2'
dependency 'org.powermock:powermock-api-mockito2:2.0.2'
dependency 'org.powermock:powermock-module-junit4:2.0.2'
dependency 'org.springframework.boot:spring-boot-autoconfigure:2.1.5.RELEASE'
dependency 'org.springframework.boot:spring-boot-configuration-processor:2.1.5.RELEASE'
dependency 'org.springframework.boot:spring-boot-starter-test:2.1.5.RELEASE'
}
}
// Sets common dependencies in java project
dependencies {
// test modules
testImplementation 'ch.qos.logback:logback-classic'
testImplementation 'junit:junit'
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.mockito:mockito-core'
testImplementation 'org.powermock:powermock-api-mockito2'
testImplementation 'org.powermock:powermock-module-junit4'
}
// Performs quality checks on Java source files and generates reports
apply plugin: 'vogle.code-quality'
checkstyle {
config = rootProject.resources.text.fromFile('config/vogle-checkstyle.xml')
}
pmd {
toolVersion = '6.11.0'
ruleSetConfig = rootProject.resources.text.fromFile('config/vogle-ruleset-6.11.x.xml')
}
// Spotless is a general-purpose formatting plugin
apply plugin: 'com.diffplug.gradle.spotless'
spotless {
java {
licenseHeaderFile "$rootDir/config/license.java"
}
}
// Apply sonarqube
apply plugin: 'org.sonarqube'
sonarqube {
properties {
def hasIntegTest = file("$projectDir/src/integTest/java").directory
property "sonar.sourceEncoding", "UTF-8"
property "sonar.sources", "src/main/java"
property "sonar.scm.disabled ", "true"
if (hasIntegTest) {
property "sonar.tests", "src/test/java,src/integTest/java"
} else {
property "sonar.tests", "src/test/java"
}
property "sonar.java.coveragePlugin", "jacoco"
if (hasIntegTest) {
property "sonar.jacoco.reportPaths", "build/jacoco/test.exec,build/jacoco/integrationTest.exec"
property "sonar.junit.reportPaths", "build/test-results/test,build/test-results/integrationTest"
} else {
property "sonar.jacoco.reportPaths", "build/jacoco/test.exec"
property "sonar.junit.reportPaths", "build/test-results/test"
}
property "sonar.java.pmd.reportPaths", "build/reports/pmd/main.xml"
property "sonar.java.checkstyle.reportPaths", "build/reports/checkstyle/main.xml"
}
}
}
// Configuration to apply to JAVA Projects
configure(publishedprojects) {
// Documentation setup
javadoc {
options.bottom = "Copyright ${new Date().format('yyyy')} <a href='http://vogle.com' target='_blank'>Vogle Labs</a>, All rights reserved."
options.stylesheetFile = new File(rootProject.rootDir, "config/dracula-javadoc8.css")
options.links("http://docs.oracle.com/javase/8/docs/api/")
}
// Provides code coverage metrics for Java code
apply plugin: 'vogle.report'
jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 0.5
}
}
rule {
enabled = false
element = 'CLASS'
includes = ['com.vogle.sbpayment*']
limit {
counter = 'LINE'
value = 'TOTALCOUNT'
maximum = 0.3
}
}
}
}
// Archive task used to create a sources jar and a javadoc jar
apply plugin: 'vogle.archive'
// Publish to maven repository
apply plugin: 'vogle.nexus-publish'
nexus {
orgName = 'Vogle Labs.'
orgUrl = 'http://vogle.com'
license = 'apache2'
}
contacts {
moniker 'Allan Im'
github 'allanim'
}
}
// Make distribution files
apply plugin: 'distribution'
distributions {
sbpayment {
baseName = project.name
contents {
from "$rootDir/LICENSE", "$rootDir/README.md", "$rootDir/README_JA.md", jar, sourceJar, javadocJar
}
}
}
sbpaymentDistZip {
destinationDirectory = file("$rootProject.buildDir/sbpayment")
}
sbpaymentDistTar {
destinationDirectory = file("$rootProject.buildDir/sbpayment")
}
}
// report tools
apply plugin: 'vogle.report'
// Coveralls
apply plugin: 'vogle.coveralls'
// Codacy
apply plugin: 'vogle.codacy'
// release version
apply plugin: 'nebula.release'