-
Notifications
You must be signed in to change notification settings - Fork 61
/
build.gradle.sample
152 lines (129 loc) · 4.77 KB
/
build.gradle.sample
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
import java.text.SimpleDateFormat
buildscript {
ext {
gradleVersion = '8.11.1'
teswizVersion = '1.0.8'
}
repositories {
mavenLocal()
}
}
plugins {
id "java"
id "idea"
id "maven-publish"
}
version '0.0.1'
project.ext.log4jProperties = "src/test/resources/log4j2.properties"
java {
sourceCompatibility = "17"
targetCompatibility = "17"
}
repositories {
mavenLocal()
maven { url 'https://jitpack.io' }
}
configurations {
cucumberRuntime {
extendsFrom testImplementation
}
}
compileJava { options.encoding = "UTF-8" }
dependencies {
implementation("com.github.znsio:teswiz:${project.teswizVersion}") {
transitive = false
}
}
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 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()
}
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"
}
// 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
}
wrapper {
gradleVersion = project.gradleVersion // version from gradle.properties
}