forked from CNXTEoEorg/perry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
328 lines (272 loc) · 10.7 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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
import org.apache.tools.ant.filters.ReplaceTokens
import java.text.SimpleDateFormat
buildscript {
repositories {
mavenLocal()
jcenter()
mavenCentral()
}
dependencies {
classpath group: 'javax.interceptor', name: 'javax.interceptor-api', version: '1.2'
classpath 'se.transmode.gradle:gradle-docker:1.2'
}
}
plugins {
id "java"
id 'application'
id "org.sonarqube" version "2.5"
id 'org.springframework.boot' version '1.5.2.RELEASE'
id "com.github.hierynomus.license" version "0.14.0"
}
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'maven-publish'
apply plugin: 'maven'
apply plugin: 'jacoco'
apply plugin: 'docker'
project.ext {
projectGroup = 'gov.ca.cwds.api'
configPath = "$rootProject.projectDir/config/"
springVersion = "1.5.19.RELEASE"
springfoxSwaggerVersion = "2.9.0"
projectMajorVersion = '4.1.0'
mainclass = 'gov.ca.cwds.PerryApplication'
targetDockerHubOrganization = System.env.DOCKERHUB_ORG ?: 'cwds'
cwdsModelVersion = '0.11.2_732-RC'
powerMockVersion = "1.7.3"
hikariCPVersion = "3.3.1"
// assume that Windows users use the Docker Toolbox
buildEnv = 'JENKINS'
devDockerHost = 'localhost'
devDockerPort = 2376
isRelease = System.getProperty("Release") == "true"
buildNumber = System.getProperty('BuildNumber')
customVersion = System.getProperty('CustomVersion')
projectSnapshotVersion = projectMajorVersion + "-SNAPSHOT"
projectReleaseVersion = (customVersion == null || customVersion == "" || customVersion.startsWith('$') ? projectMajorVersion + '_' + buildNumber + '-RC' : customVersion )
projectVersion = (isRelease ? projectReleaseVersion : projectSnapshotVersion )
// Publishing configuration
snapshotMavenRepo = "http://pr.dev.cwds.io/artifactory/repo"
releaseMavenRepo = "http://pr.dev.cwds.io/artifactory/libs-release"
artifactoryRepo = (isRelease ? releaseMavenRepo : snapshotMavenRepo)
shiroVersion = '1.2.3'
guiceVersion = '4.0'
jacksonVersion = '2.8.7'
servletApiVersion = '3.1.0'
commonsLangVersion = '3.6'
commonsCollectionsVersion = '4.2'
commonsIoVersion = '2.5'
serenityVersion = '1.9.13'
}
if (System.getProperty('newVersion') && System.getProperty('newVersion')!='null') {
def newVersion = "${System.getProperty('newVersion')}"
version = newVersion
projectMajorVersion = newVersion
projectVersion = newVersion
} else {
version = projectVersion
}
def dockerTag = projectVersion
group = projectGroup
description = """perry"""
sourceCompatibility = 1.8
targetCompatibility = 1.8
println "Release: " + isRelease
println "Build: " + buildNumber
println "Project Version: " + projectVersion
println "Project Major Version: " + projectMajorVersion
jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
html.destination "${buildDir}/jacocoHtml"
}
}
sonarqube {
properties {
property "sonar.jacoco.reportPath", "${buildDir}/jacoco/test.exec"
property "sonar.jacoco.itReportPath", "${buildDir}/jacoco/integrationTest.exec"
//sonar doesn't recognize AOP and shiro library!!!
property "sonar.exclusions", "/src/main/java/gov/ca/cwds/security/**"
}
}
//version = projectVersion
mainClassName = mainclass
bootRepackage {
mainClass = 'gov.ca.cwds.PerryApplication'
}
repositories {
mavenLocal()
maven {
url "http://pr.dev.cwds.io/artifactory/repo"
}
}
springBoot {
buildInfo {
additionalProperties = [
version: projectVersion,
buildNumber: ""+buildNumber,
time: buildTime()
]
}
}
def buildTime() {
final dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ssZ")
dateFormat.timeZone = TimeZone.getTimeZone('PDT')
dateFormat.format(new Date())
}
dependencies {
compile group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: springVersion
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version:springVersion
compile ('org.springframework.boot:spring-boot-starter-data-jpa:' + springVersion) {
exclude group: 'org.apache.tomcat', module: 'tomcat-jdbc'
}
compile group: 'com.zaxxer', name: 'HikariCP', version: hikariCPVersion
compile group: 'org.springframework.boot', name: 'spring-boot-starter-thymeleaf', version:springVersion
compile group:"org.springframework.boot", name:"spring-boot-starter-actuator", version:springVersion
compile group:"org.springframework.boot", name:"spring-boot-starter-data-redis", version:springVersion
compile group: 'org.springframework.security.oauth', name: 'spring-security-oauth2', version:'2.0.13.RELEASE'
compile group: 'org.springframework.session', name: 'spring-session', version:'1.3.1.RELEASE'
// https://mvnrepository.com/artifact/org.springframework.retry/spring-retry
compile group: 'org.springframework.retry', name: 'spring-retry', version: '1.2.2.RELEASE'
compile group: 'org.webjars', name: 'angularjs', version:'1.4.3'
compile group: 'org.webjars', name: 'jquery', version:'2.1.1'
compile group: 'org.webjars', name: 'bootstrap', version:'3.2.0'
compile group: 'org.webjars', name: 'webjars-locator', version:'0.32'
compile group: 'io.springfox', name: 'springfox-swagger2', version: springfoxSwaggerVersion
compile group: 'io.springfox', name: 'springfox-swagger-ui', version: springfoxSwaggerVersion
compile group: 'org.codehaus.groovy', name: 'groovy-all', version: '2.4.11'
compile group: 'org.liquibase', name: 'liquibase-core', version: '3.5.3'
compile group: 'com.newrelic.agent.java', name: 'newrelic-api', version: "3.41.0"
compile group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.11.325'
//h2 dev mode
compile group: 'com.h2database', name: 'h2', version: '1.4.196'
compile group: 'com.ibm', name: 'db2jcc4', version: '4.21.29'
compile group: 'com.ibm', name: 'db2jcc_license_cisuz', version: '4.0.0'
compile group: 'org.hibernate', name: 'hibernate-java8', version: '5.0.12.Final'
compile group: 'javax.ws.rs', name: 'javax.ws.rs-api', version: '2.0'
compile group: 'org.eclipse.jetty', name: 'jetty-server', version: '9.4.2.v20170220'
compile group: 'org.eclipse.jetty', name: 'jetty-webapp', version: '9.4.2.v20170220'
compile group: 'org.postgresql', name: 'postgresql', version: '9.4.1212.jre7'
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.8.6"
compile group: 'org.apache.commons', name: 'commons-collections4', version: commonsCollectionsVersion
compile project(':jwt-security')
compile group: 'javax.interceptor', name: 'javax.interceptor-api', version: '1.2'
testCompile(group: 'org.springframework.boot', name: 'spring-boot-starter-test', version:springVersion) {
exclude(module: 'commons-logging')
}
testCompile 'org.springframework.security:spring-security-test:4.2.6.RELEASE'
testCompile 'org.mockito:mockito-core:2.8.9'
testCompile group: 'org.hamcrest', name: 'hamcrest-junit', version: '2.0.0.0'
testCompile('org.glassfish.jersey.test-framework.providers:jersey-test-framework-provider-grizzly2:2.23.2') {
exclude group: 'javax.servlet', module: 'javax.servlet-api'
exclude group: 'junit', module: 'junit'
}
// https://mvnrepository.com/artifact/nl.jqno.equalsverifier/equalsverifier
testCompile group: 'nl.jqno.equalsverifier', name: 'equalsverifier', version: '2.1.6'
testCompile 'org.ow2.asm:asm-all:5.1'
testCompile group: 'io.dropwizard', name: 'dropwizard-testing', version: '1.0.5'
testCompile group: 'gov.ca.cwds.cals', name: 'cws-cms-data-model', version: cwdsModelVersion, changing: true
testCompile group: 'org.powermock', name: 'powermock-module-junit4', version: powerMockVersion
testCompile group: 'org.powermock', name: 'powermock-api-mockito2', version: powerMockVersion
}
test {
exclude '**/smoketest/**'
}
task smokeTest(type: Test) {
systemProperty 'perry.health.check.url', project.property('perry.health.check.url')
include '**/smoketest/**'
}
publish.dependsOn ':api-security:publish'
def isPortOpen(host, port) {
try {
Socket socket = new Socket(host, port)
socket.close()
return true
} catch (IOException e) {
return false
}
}
project.ext.dockerEnvVars = project.buildEnv != 'WIN_DEV' ? [:] : [
DOCKER_CERT_PATH: System.getProperty("user.home") + '/.docker/machine/machines/default',
DOCKER_HOST: "tcp://$project.devDockerHost:$project.devDockerPort",
DOCKER_MACHINE_NAME: 'default',
DOCKER_TLS_VERIFY: '1',
COMPOSE_CONVERT_WINDOWS_PATHS: 'true'
]
// reused in sub-modules
task checkDockerService {
enabled = project.buildEnv == 'WIN_DEV'
doFirst {
if (!isPortOpen(project.devDockerHost, project.devDockerPort)) {
throw new GradleException('Docker service is not available. Windows users should start Docker Quickstart Terminal of Docker Toolbox')
}
}
}
processResources {
filter(ReplaceTokens, tokens: [
'build.version': projectVersion as String,
'build.number' : (System.getenv("BUILD_NUMBER") ?: "IDE")
])
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
repositories {
mavenLocal()
maven {
url artifactoryRepo
}
}
}
task publishDocker(dependsOn: ':docker-perry:dockerPerryPublish') {
doLast {
println 'Docker published'
}
}
task publishLatestDocker(dependsOn: ':docker-perry:dockerPerryPublishLatest') {
doLast {
println 'Docker published'
}
}
task buildDocker(dependsOn: ':docker-perry:dockerCreateImage') {
doLast {
println 'Docker built'
}
}
task publishGit(dependsOn: ':docker-perry:pushGitTag') {
doLast {
println 'Docker published'
}
}
task integrationTestDev(dependsOn: ':integration-tests:testDevMode') {
doLast {
println 'Integration Test Passed'
}
}
task integrationTestProd(dependsOn: ':integration-tests:testCognitoMode') {
doLast {
println 'Integration Test Passed'
}
}
task integrationTestProdWithMFA(dependsOn: ':integration-tests:testCognitoWithMFAMode') {
doLast {
println 'Integration Test With MFA Passed'
}
}
javadoc {
options.addStringOption("charset", "UTF-8")
}
task integrationTest(type: Test, dependsOn: testClasses) {
include '**/*IT*'
exclude '**/*Test*'
}
task copyConfigToTestResources(type: Copy) {
from 'config'
into 'src/test/resources/scripts'
include 'idm.groovy', 'cognito.groovy', 'default.groovy'
}
test.dependsOn copyConfigToTestResources