-
Notifications
You must be signed in to change notification settings - Fork 61
/
build.gradle
273 lines (238 loc) · 9.03 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
import org.codehaus.groovy.runtime.GStringImpl
import java.text.SimpleDateFormat
buildscript {
ext {
gradleVersion = "8.11.1"
applitoolsAppiumVersion = "5.72.0"
browserStackLocalVersion = "1.1.4"
fasterxmlJacksonVersion = "2.18.1"
atdVersion = "b313941325" // ATD main branch
jadbVersion = "1.2.1"
unirestVersion = "3.14.5"
specmaticVersion = '1.3.39'
webDriverManagerVersion = '5.9.2'
jodaTimeVersion = "2.13.0"
masterThoughtVersion = "5.8.4"
commonsLang3Version = "3.17.0"
commonsRngSimpleVersion = "1.6"
aspectJVersion = "1.9.22.1"
assertJVersion = "3.26.3"
jetbrainsAnnotationsVersion = "26.0.1"
junitVersion = "5.11.3"
snakeyamlVersion = "2.3"
jsonDiffVersion = "0.4.14"
}
}
plugins {
id "org.sonarqube" version "6.0.0.5145"
id "java"
id "idea"
id "com.github.johnrengelman.shadow" version '8.1.1'
id "maven-publish"
id "io.freefair.aspectj.post-compile-weaving" version "8.11"
}
group = 'com.github.znsio'
version '1.0.8'
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
repositories {
mavenLocal()
flatDir {
dirs 'libs'
}
mavenCentral()
maven {
url 'https://jitpack.io'
}
}
configurations {
cucumberRuntime {
extendsFrom testImplementation
}
}
compileJava {
options.encoding = "UTF-8"
}
idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
dependencies {
implementation fileTree(dir: "$project.projectDir/libs", include: ['*.jar'])
implementation files(layout.buildDirectory.files("/classes/main"))
implementation files(layout.buildDirectory.files("/classes/test"))
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:$project.fasterxmlJacksonVersion"
implementation "com.konghq:unirest-java:$project.unirestVersion"
implementation "org.assertj:assertj-core:$project.assertJVersion"
implementation ("com.github.AppiumTestDistribution:AppiumTestDistribution:$project.atdVersion") {
exclude group: 'io.appium', module: 'java-client'
}
implementation "org.apache.commons:commons-lang3:$project.commonsLang3Version"
implementation "org.apache.commons:commons-rng-simple:$project.commonsRngSimpleVersion"
implementation "com.github.vidstige:jadb:$project.jadbVersion"
implementation "org.jetbrains:annotations:$project.jetbrainsAnnotationsVersion"
implementation "org.junit.jupiter:junit-jupiter:$project.junitVersion"
implementation "joda-time:joda-time:$project.jodaTimeVersion"
implementation "com.browserstack:browserstack-local-java:$project.browserStackLocalVersion"
implementation ("com.applitools:eyes-appium-java5:$project.applitoolsAppiumVersion") {
// exclude group: 'io.appium', module: 'java-client'
}
implementation "net.masterthought:cucumber-reporting:$masterThoughtVersion"
implementation "org.aspectj:aspectjrt:$project.aspectJVersion"
implementation "in.specmatic:specmatic-core:${project.specmaticVersion}"
implementation "io.github.bonigarcia:webdrivermanager:$project.webDriverManagerVersion"
implementation "org.yaml:snakeyaml:$project.snakeyamlVersion"
implementation "com.flipkart.zjsonpatch:zjsonpatch:$project.jsonDiffVersion"
}
shadowJar {
archiveBaseName.set("$project.name")
archiveClassifier.set('')
archiveVersion.set("$project.version")
zip64 true
manifest {
attributes "Multi-Release": true
attributes "Main-Class": "com.znsio.e2e.runner.Runner"
}
exclude "**/Log4j2Plugins.dat"
}
tasks.register('sourcesJar', Jar) {
dependsOn classes
archiveClassifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives sourcesJar
archives shadowJar
}
wrapper {
gradleVersion = project.gradleVersion // version from gradle.properties
}
publishing {
publications {
testing(MavenPublication) {
from components.java
artifact sourcesJar
}
}
}
tasks.register('install') { dependsOn publishToMavenLocal }
static def getCurrentDatestamp() {
Date today = new Date()
SimpleDateFormat df = new SimpleDateFormat("MM-dd-yyyy")
return df.format(today)
}
static def getMonth() {
Date today = new Date()
SimpleDateFormat df = new SimpleDateFormat("MMM-yyyy")
return df.format(today)
}
static def getCurrentTimestamp() {
Date today = new Date()
SimpleDateFormat df = new SimpleDateFormat("HH-mm-ss")
return df.format(today)
}
project.ext.logDir = "./target/" + getMonth() + "/" + getCurrentDatestamp() + "/" + getCurrentTimestamp()
def copyRpPropertiesIfMissing() {
def rpFile = file('src/test/resources/reportportal.properties')
def rpTemplateFile = file('src/test/resources/reportportal.properties.template')
if (!rpFile.exists() && rpTemplateFile.exists()) {
println "Copying $rpTemplateFile to $rpFile"
rpFile.text = rpTemplateFile.text
} else if (!rpTemplateFile.exists()) {
println "$rpTemplateFile does not exist. Please create it."
} else {
println "$rpFile already exists."
}
System.setProperty("reportportal.properties.file", rpFile.absolutePath)
}
task copyRpPropertiesIfMissing {
doLast {
copyRpPropertiesIfMissing()
}
}
gradle.taskGraph.whenReady { taskGraph ->
if (taskGraph.hasTask(':build') || taskGraph.hasTask(':run')) {
copyRpPropertiesIfMissing()
}
}
tasks.register('run', JavaExec) {
doFirst {
println "Using LOG_DIR: ${project.logDir}"
System.setProperty "LOG_DIR", "${project.logDir}"
environment "APPLITOOLS_LOG_DIR", "${project.logDir}/applitools_logs"
def hostname = InetAddress.getLocalHost().getHostName()
println "Hostname: $hostname"
def ipAddress = InetAddress.getAllByName(hostname)
.find { it.hostAddress.startsWith("192") || it.hostAddress.startsWith("172") || it.hostAddress.startsWith("10") }
?.hostAddress
println "IP Address of this machine: $ipAddress"
if (null == ipAddress) {
println "Unable to get local IP address. NOT updating BASE_URL and REMOTE_WEBDRIVER_GRID_HOST_NAME"
} else {
// println "Updating BASE_URL ('http://$ipAddress:3000') and REMOTE_WEBDRIVER_GRID_HOST_NAME ('$ipAddress')"
// environment "BASE_URL", "http://$ipAddress:3000"
environment "REMOTE_WEBDRIVER_GRID_HOST_NAME", "$ipAddress"
}
def configFile = System.getenv("CONFIG")
if (null == configFile || !file(configFile).exists()) {
println("CONFIG file not provided, or does not exist")
println("Run the test by providing the CONFIG file not provided, or does not exist")
assert file(configFile).exists()
}
// You can also specify which config file to use based on the value of RUN_IN_CI as shown below
//
// def isRunInCI = Boolean.parseBoolean(System.getenv("RUN_IN_CI"))
// println "isRunningInCI: $isRunInCI"
// def configFile = isRunInCI
// ? "./configs/theapp/theapp_pcloudy_config.properties"
// : "./configs/theapp/theapp_local_android_config.properties"
// configFile = System.getenv("CONFIG") ? System.getenv("CONFIG") : configFile
systemProperties = System.properties as Map<String, ?>
def runnerArgs = [
"${configFile}",
"com/znsio/teswiz/steps",
"./src/test/resources/com/znsio/teswiz/features"
]
args = runnerArgs
println("Debug mode: " + System.getProperty('debug', 'false'))
// attach debugger
// example: ./gradlew run -Ddebug=true
if (System.getProperty('debug', 'false') == 'true') {
println("In debug mode")
jvmArgs '-Xdebug', '-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,' +
'address=*:5005'
}
}
mainClass = "com.znsio.teswiz.runner.Runner"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
}
test {
useJUnitPlatform()
outputs.upToDateWhen { false }
testLogging {
events "started", "passed", "skipped", "failed"
// show standard out and standard error of the test JVM(s) on the console
showStandardStreams = true
// show full exception trace
exceptionFormat = 'full'
showStackTraces = true
showCauses = true
showExceptions = true
}
// attach debugger
if (System.getProperty('debug', 'false') == 'true') {
jvmArgs '-Xdebug', '-agentlib:jdwp=transport=dt_socket,server=n,address=192.168.29.248:9009,suspend=y'
}
println "Using LOG_DIR: ${project.logDir}"
reports {
html.required.set(true)
junitXml.required.set(true)
html.outputLocation.set(file("$project.logDir/unit-test-results"))
junitXml.outputLocation.set(file("$project.logDir/unit-test-results"))
}
}
shadowJar.finalizedBy sourcesJar