forked from jhinkey/com-liferay-adaptive-media
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-ext.gradle
269 lines (213 loc) · 6.28 KB
/
build-ext.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
import com.bmuschko.gradle.docker.tasks.image.DockerTagImage
import com.liferay.gradle.plugins.app.docker.AppDockerPlugin
import javax.management.remote.JMXConnectorFactory as JmxFactory
import javax.management.remote.JMXServiceURL as JmxUrl
import org.kt3k.gradle.plugin.CoverallsPlugin
buildscript {
dependencies {
classpath group: "com.liferay", name: "com.liferay.gradle.plugins.app.docker", version: "1.0.1"
classpath group: "org.kt3k.gradle.plugin", name: "coveralls-gradle-plugin", version: "2.6.3"
}
repositories {
maven {
url "https://cdn.lfrs.sl/repository.liferay.com/nexus/content/groups/public"
}
}
}
apply plugin: CoverallsPlugin
allprojects {
apply plugin: JacocoPlugin
jacoco {
toolVersion = "0.7.8"
}
repositories {
mavenLocal()
maven {
url "https://cdn.lfrs.sl/repository.liferay.com/nexus/content/groups/public"
}
}
}
if (System.getenv('TRAVIS')) {
configure(subprojects.findAll {!it.childProjects}) {
liferay {
deployDir = new File(getClientDeployDir())
}
task createClientDeployDir(type: Exec) {
commandLine 'mkdir', '-m', '777', '-p', "${getClientDeployDir()}"
}
task createJacocoTestIntegrationFile(type: Exec) {
doFirst {
commandLine 'touch', "${rootDir}/build/jacoco/testIntegration.exec"
}
}
task copyJacocoAgent(type: Copy) {
configurations.jacocoAgent.asFileTree.each {
from(zipTree(it))
}
into "${rootDir}/build/jacoco"
finalizedBy createJacocoTestIntegrationFile
}
deploy {
dependsOn createClientDeployDir
}
test {
ignoreFailures = false
}
testIntegration {
ignoreFailures = false
testLogging {
events "started", "passed", "skipped", "failed", "standardOut", "standardError"
showExceptions true
exceptionFormat "full"
showCauses true
showStackTraces true
}
}
setUpTestableTomcat {
enabled = false
}
startTestableTomcat {
enabled = false
}
stopTestableTomcat {
enabled = false
}
}
apply plugin: AppDockerPlugin
appDocker {
imageName this.getImageName()
imageUser this.getUserName()
inputDir "adaptive-media-docker"
def excludedModules = project.getProperty('com.liferay.adaptive.media.docker.excluded.modules').split(',')
onlyIf {
project -> !excludedModules.contains(project.name)
}
}
docker {
registryCredentials {
username = System.getenv().get("DOCKER_USER")
password = System.getenv().get("DOCKER_PWD")
}
}
allprojects {
ext {
dockerDestinationDir = prepareAppDockerImageInputDir.destinationDir
}
}
task checkDocker() {
doLast {
def url = "http://localhost:8080"
println("Trying to reach " + url)
while (true) {
try {
print(".")
url.toURL().text
println("Portal startup finished")
break
}
catch (Exception e) {
Thread.sleep(1000)
}
}
}
}
task runDocker(type: Exec) {
dependsOn subprojects.findAll {!it.childProjects}.copyJacocoAgent
def javaOpts = project.getProperty('com.liferay.adaptive.media.java.opts')
javaOpts += ' ' + project.getProperty('com.liferay.adaptive.media.jacoco.opts')
if (project.hasProperty('debug')) {
javaOpts += ' ' + project.getProperty('com.liferay.adaptive.media.debug.opts')
}
commandLine 'docker', 'run',
'-e', "JACOCO_DIR=${rootDir}/build/jacoco",
'-e', "JAVA_OPTS=$javaOpts",
'-e', "ROOT_DIR=${rootDir}",
'-p', '5005:5005',
'-p', '8080:8080',
'-p', '8099:8099',
'-p', '8778:8778',
'-p', '11311:11311',
'-v', "${rootDir}/build/jacoco:/jacoco",
'-v', "${getClientDeployDir()}:/liferay/deploy",
'-d',
'--name', "com-liferay-adaptive-media",
getImageNameWithUserAndVersion()
finalizedBy checkDocker
}
}
def getClientDeployDir() {
return "${rootDir}/${project.property('com.liferay.adaptive.media.deploy.dir')}"
}
def getImageName() {
return project.property("com.liferay.adaptive.media.docker.image.name")
}
def getImageVersion() {
return project.property("com.liferay.adaptive.media.docker.image.version")
}
def getUserName() {
return project.property("com.liferay.adaptive.media.docker.username")
}
def getImageNameWithUser() {
return getUserName() + "/" + getImageName()
}
def getImageNameWithUserAndVersion() {
return getImageNameWithUser() + ":" + getImageVersion()
}
task jacocoRootReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) {
dependsOn = subprojects.findAll{!it.childProjects}.test
additionalSourceDirs = files(subprojects.findAll{!it.childProjects}.sourceSets.main.allSource.srcDirs)
sourceDirectories = files(subprojects.findAll{!it.childProjects}.sourceSets.main.allSource.srcDirs)
classDirectories = files(subprojects.findAll{!it.childProjects}.sourceSets.main.output)
executionData = files(subprojects.findAll{!it.childProjects}.jacocoTestReport.executionData, "${rootDir}/build/jacoco/testIntegration.exec")
onlyIf = { true }
afterEvaluate {
classDirectories = files(classDirectories.files.collect {
fileTree(dir: it,
exclude: [
'**/*Exception*',
'**/model/*Model*',
'**/model/*Soap*',
'**/model/*Wrapper*',
'**/model/impl/*BaseImpl*',
'**/model/impl/*CacheModel*',
'**/model/impl/*ModelImpl*',
'**/service/*ServiceUtil*',
'**/service/*ServiceWrapper*',
'**/service/base/*',
'**/service/http/*',
'**/service/persistence/*Util*',
'**/service/persistence/impl/*PersistenceImpl*',
'**/service/persistence/impl/*FinderBaseImpl*',
'**/service/util/*',
'**/test/util/*',
'adaptive-media-demo/**',
'adaptive-media-demo-data-creator-api/**',
'adaptive-media-demo-data-creator-impl/**',
])
})
}
reports {
html.enabled = true
xml.enabled = true
xml.destination "${rootDir}/build/reports/jacoco/test/jacocoTestReport.xml"
csv.enabled = false
}
doFirst {
executionData = files(executionData.findAll { it.exists() })
}
}
task dumpJacoco {
doLast {
def serverUrl = 'service:jmx:rmi:///jndi/rmi://localhost:8099/jmxrmi'
String beanName = "org.jacoco:type=Runtime"
def server = JmxFactory.connect(new JmxUrl(serverUrl)).MBeanServerConnection
def gmxb = new GroovyMBean(server, beanName)
gmxb.dump(true)
}
}
tasks.coveralls {
dependsOn jacocoRootReport
}
coveralls.sourceDirs = files(subprojects.findAll{!it.childProjects}.sourceSets.main.allSource.srcDirs).collect {
file -> file.absolutePath
}