-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
111 lines (96 loc) · 2.95 KB
/
Copy pathbuild.gradle
File metadata and controls
111 lines (96 loc) · 2.95 KB
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
plugins {
id "war"
id "net.wasdev.wlp.gradle.plugins.Liberty" version "2.6.3"
id "io.spring.dependency-management" version "1.0.7.RELEASE"
}
ext {
openlibertyVersion = "19.0.0.2"
appName = project.name
testServerHttpPort = 9080
testServerHttpsPort = 9443
warContext = appName
}
version = "1.0-SNAPSHOT"
group = "io.openliberty.guides"
description = "Open Liberty MicroProfile with Gradle"
repositories {
mavenCentral()
}
dependencyManagement {
imports {
mavenBom "io.openliberty.features:features-bom:$openlibertyVersion"
}
dependencies {
dependency "io.openliberty:openliberty-runtime:$openlibertyVersion"
dependency "javax.servlet:javax.servlet-api:3.1.0"
dependency "junit:junit:4.12"
dependency "commons-httpclient:commons-httpclient:3.1"
}
}
dependencies {
providedCompile "io.openliberty.features:microProfile-2.1"
libertyRuntime "io.openliberty.features:microProfile-2.1"
testImplementation "commons-httpclient:commons-httpclient"
testImplementation "junit:junit"
}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
liberty {
server {
name = "${appName}Server"
configFile = file("src/main/liberty/config/server.xml")
bootstrapProperties = [
"default.http.port" : testServerHttpPort as String,
"default.https.port": testServerHttpsPort as String,
"app.context.root" : warContext as String,
]
packageLiberty {
archive = "$buildDir/${appName}.zip"
include = "usr"
}
}
}
war {
archiveFileName = "${archiveBaseName.get()}.${archiveExtension.get()}"
}
test {
reports.html.destination = file("$buildDir/reports/unit")
reports.junitXml.destination = file("$buildDir/test-results/unit")
exclude "**/*IT*" // this one is needed for regular gradle test executions...
}
task integrationTest(type: Test) {
group = "Liberty"
description "Runs the integration tests."
systemProperty "liberty.test.port", testServerHttpPort
systemProperty "war.name" , warContext
reports.html.destination = file("$buildDir/reports/it")
reports.junitXml.destination = file("$buildDir/test-results/it")
include "**/*IT*" // integration tests
exclude "**/*Test*" // unit tests
}
static void browseUrl(def source) {
java.awt.Desktop.desktop.browse(source)
}
task openBrowser {
group = "Liberty"
description = "Open application on http://localhost:8080/${warContext}"
doLast {
browseUrl("http://localhost:${testServerHttpPort}/${appName}".toURL())
}
}
task openTestReport {
group = "Liberty"
description = "Open test report"
doLast {
browseUrl(file("$buildDir/reports/it/index.html").toURI())
}
}
clean.dependsOn("libertyStop")
check.dependsOn("integrationTest")
integrationTest.dependsOn("libertyStart")
integrationTest.finalizedBy("libertyStop")
//integrationTest.finalizedBy("openTestReport") // skip browser opening
libertyPackage.dependsOn("libertyStop")