-
Notifications
You must be signed in to change notification settings - Fork 16
/
build.gradle
304 lines (260 loc) · 8.17 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
import org.apache.tools.ant.filters.ReplaceTokens
plugins {
id 'io.codearte.nexus-staging' version '0.21.1'
id 'net.researchgate.release' version '2.8.1'
}
apply plugin: 'java-library'
apply plugin: 'maven'
apply plugin: 'jacoco'
apply plugin: 'signing'
compileJava.enabled = false
processResources.enabled = false
classes.enabled = false
jar.enabled = false
// remove default JAR artifact
configurations.archives.artifacts.removeAll { it.provider.name == 'jar' }
afterReleaseBuild.dependsOn uploadArchives
group = 'com.nordstrom.ui-tools'
description = 'Selenium Foundation'
if (!project.hasProperty('profile')) {
ext.profile = 'selenium2'
} else {
assert ['selenium2', 'selenium3'].contains(profile)
}
apply from: "${profile}Deps.gradle"
def archiveVer = null
def verBits = project.version.split('-')
def seleniumApi = 's' + profile.charAt(8)
if (verBits.length > 1) {
if (verBits[1].equals(seleniumApi)) {
archiveVer = project.version
} else {
archiveVer = verBits[0] + '-' + seleniumApi + '-' + verBits[1]
}
} else {
archiveVer = verBits[0] + '-' + seleniumApi
}
project.version = archiveVer
def archiveBase = rootProject.name + '-' + archiveVer
def buildRoot = null
def libsDir = null
switch ("${profile}") {
case "selenium2":
buildRoot = file('build-s2')
libsDir = new File(buildRoot, 'libs')
break
case "selenium3":
buildRoot = file('build-s3')
libsDir = new File(buildRoot, 'libs')
break
}
sourceSets {
selenium2 {
java {
srcDirs = [ 'src/main/java', 'src/main/java-s2' ]
outputDir = new File(buildRoot, 'classes')
}
resources {
srcDirs = [ 'src/main/resources' ]
}
compileClasspath = sourceSets.main.output + configurations.selenium2Compile
runtimeClasspath = output + compileClasspath + configurations.selenium2Runtime
output.resourcesDir = "${buildRoot}/classes"
}
selenium3 {
java {
srcDirs = [ 'src/main/java', 'src/main/java-s3' ]
outputDir = new File(buildRoot, 'classes')
}
resources {
srcDirs = [ 'src/main/resources' ]
}
compileClasspath = sourceSets.main.output + configurations.selenium3Compile
runtimeClasspath = output + compileClasspath + configurations.selenium3Runtime
output.resourcesDir = "${buildRoot}/classes"
}
test {
java {
outputDir = new File(buildRoot, 'test-classes')
}
compileClasspath += sourceSets["${profile}"].output
runtimeClasspath += sourceSets["${profile}"].output
}
}
clean {
delete 'logs'
delete 'target'
}
jacoco {
toolVersion = '0.8.5'
reportsDirectory = file("${buildDir}/customJacocoReportDir")
}
jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
html.destination file("${buildDir}/jacocoHtml")
}
}
task("${profile}Javadoc", type: Javadoc) {
group 'Documentation'
description "Generates Javadoc API documentation for the '${profile}' source code."
source = sourceSets["${profile}"].allJava
classpath = configurations.compile + configurations["${profile}Compile"]
}
task("${profile}Jar", type: Jar) {
group 'Build'
description "Assembles a jar archive containing the '${profile}' classes, POM and Maven properties."
def destPath = "META-INF/maven/${project.group}/${rootProject.name}"
def timestamp = Long.valueOf(System.currentTimeMillis()).toString()
def pomTokens = [projectVersion: archiveVer, projectTimestamp: timestamp, seleniumApi: seleniumApi]
def propTokens = [projectVersion: archiveVer, projectGroupId: project.group, projectArtifactId: rootProject.name]
from(sourceSets["${profile}"].output) { }
from('.') {
include('pom.xml')
into(destPath)
filter(ReplaceTokens, tokens: pomTokens)
}
from('.') {
include('pom.properties')
into(destPath)
filter(ReplaceTokens, tokens: propTokens)
}
archiveFileName = archiveBase + '.jar'
destinationDirectory = libsDir
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
clean {
delete buildRoot
}
task("${profile}SourcesJar", type: Jar) {
group 'Build'
description "Assembles a jar archive containing the '${profile}' source files."
classifier = 'sources'
from sourceSets["${profile}"].allSource
archiveFileName = archiveBase + '-sources.jar'
destinationDirectory = libsDir
}
task("${profile}JavadocJar", type: Jar, dependsOn: "${profile}Javadoc") {
group 'Build'
description "Assembles a jar archive containing the '${profile}' JavaDoc files."
classifier = 'javadoc'
from tasks["${profile}Javadoc"].destinationDir
archiveFileName = archiveBase + '-javadoc.jar'
destinationDirectory = libsDir
}
task testNG(type: Test) {
useTestNG()
reports.html.destination = file("${buildDir}/reports/testng")
testLogging.showStandardStreams = true
}
test {
dependsOn testNG
reports.html.destination = file("${buildDir}/reports/junit")
testLogging.showStandardStreams = true
}
artifacts {
archives tasks["${profile}Jar"]
archives tasks["${profile}SourcesJar"]
archives tasks["${profile}JavadocJar"]
}
signing {
sign configurations.archives
}
install {
repositories {
mavenInstaller {
pom.scopeMappings.with {
mappings.clear()
addMapping(300, configurations.compile, 'compile')
addMapping(300, configurations["${profile}Compile"], 'compile')
}
}
}
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment ->
signing.signPom(deployment)
signArchives.filesToSign.each {
def signOp = signing.sign(it)
def single = signOp.singleSignature
def matcher = it.name =~ /-(sources|javadoc)\.jar$/
single.name = 'selenium-foundation'
single.classifier = matcher.find() ? matcher.group(1) : null
deployment.addArtifact(single)
}
}
repository(url: 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/') {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: 'https://s01.oss.sonatype.org/content/repositories/snapshots/') {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
pom.scopeMappings.with {
mappings.clear()
addMapping(300, configurations.compile, 'compile')
addMapping(300, configurations["${profile}Compile"], 'compile')
}
}
}
}
def installer = install.repositories.mavenInstaller
def deployer = uploadArchives.repositories.mavenDeployer
[installer, deployer]*.pom*.whenConfigured { pom ->
pom.project {
name 'Selenium Foundation'
groupId project.group
artifactId rootProject.name
version archiveVer
packaging 'jar'
description 'Selenium Foundation is an automation framework designed to extend and enhance the capabilities provided by Selenium (WebDriver).'
url 'https://github.com/sbabcoc/Selenium-Foundation'
scm {
connection 'scm:git:https://github.com/sbabcoc/Selenium-Foundation.git'
developerConnection 'scm:git:https://github.com/sbabcoc/Selenium-Foundation.git'
url 'https://github.com/sbabcoc/Selenium-Foundation/tree/master'
tag 'HEAD'
}
licenses {
license {
name 'The Apache License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id 'scoba'
name 'Scott Babcock'
email 'scoba@hotmail.com'
organization 'Nordstrom'
organizationUrl 'https://shop.nordstrom.com'
}
}
}
}
nexusStaging {
packageGroup = 'com.nordstrom'
stagingProfileId = '76d943f622957'
}
repositories {
mavenLocal()
mavenCentral()
maven { url 'https://repo1.maven.org/maven2' }
maven { url 'https://repo.maven.apache.org/maven2' }
maven { url "${projectDir}/repo" }
}
dependencies {
compile 'com.nordstrom.tools:java-utils:2.1.0'
compile 'com.nordstrom.tools:settings:2.3.10'
compile 'com.nordstrom.tools:junit-foundation:15.3.4'
compile('com.github.sbabcoc:logback-testng:1.3.4') {
exclude group: 'org.testng', module: 'testng'
}
compile('org.hamcrest:hamcrest-core') { version { strictly '2.2' } }
compile('org.yaml:snakeyaml') { version { strictly '1.28' } }
}
test {
jvmArgs "-javaagent:${classpath.find { it.name.contains('junit-foundation') }.absolutePath}"
}