@@ -7,196 +7,177 @@ plugins {
77 id ' maven-publish'
88 id ' jacoco'
99 id ' signing'
10- id ' io.github.gradle-nexus.publish-plugin' version ' 1.1.0'
11- id ' pl.allegro.tech.build.axion-release' version ' 1.13.14'
10+
11+ id ' io.github.gradle-nexus.publish-plugin' version ' 2.0.0'
12+ id ' pl.allegro.tech.build.axion-release' version ' 1.18.0'
1213}
1314
1415group = ' com.nordstrom.ui-tools'
1516description = ' Selenium Foundation'
1617
17- if (! project. hasProperty(' profile' )) {
18- ext. profile = ' selenium4'
19- } else {
20- assert [' selenium3' , ' selenium4' ]. contains(profile)
21- }
18+ ext. profile = project. findProperty(' profile' ) ?: ' selenium4'
19+ assert [' selenium3' , ' selenium4' ]. contains(profile)
2220
2321apply from : " ${ profile} Deps.gradle"
2422
2523if (project. hasProperty(' browsers' )) {
26- ext . browsers. split(' ,' ). each {
27- def browser = it . trim()
24+ project . browsers. split(' ,' ). each { browser ->
25+ browser = browser . trim()
2826 if (browser) {
2927 apply from : " ${ browser} Deps.gradle"
3028 }
3129 }
3230}
3331
34- // if " personality" is specified
32+ /* personality injection */
3533if (project. hasProperty(' personality' )) {
36- // store "injected" browser name setting
37- System . setProperty(' injected.selenium.browser.name' , ext. personality)
38- // if target is a mobile browser
39- if ([" .chrome" , " .safari" ]. any { ext. personality. endsWith(it) }) {
40- // specify "web-app" as the injected default context platform
34+ System . setProperty(' injected.selenium.browser.name' , personality)
35+
36+ if ([" .chrome" , " .safari" ]. any { personality. endsWith(it) }) {
4137 System . setProperty(' injected.selenium.context.platform' , ' web-app' )
42- // ensure ExamplePageServlet is installed
4338 System . setProperty(' injected.selenium.grid.examples' , ' true' )
4439 }
4540}
4641
47- def archiveVer = null
42+ /* Version logic */
4843def verBits = scmVersion. version. split(' -' )
49- def seleniumApi = ' s' + profile. charAt(8 )
50- if (verBits. length > 1 ) {
51- if (verBits[1 ]. equals(seleniumApi)) {
52- archiveVer = project. version
53- } else {
54- archiveVer = verBits[0 ] + ' -' + seleniumApi + ' -' + verBits[1 ]
55- }
56- } else {
57- archiveVer = verBits[0 ] + ' -' + seleniumApi
58- }
44+ def seleniumApi = " s${ profile.charAt(8)} "
5945
60- project. version = archiveVer
61-
62- def archiveBase = rootProject. name + ' -' + archiveVer
46+ def archiveVer = (verBits. length > 1 && verBits[1 ] == seleniumApi)
47+ ? project. version
48+ : verBits[0 ] + " -${ seleniumApi} " + (verBits. length > 1 ? " -${ verBits[1]} " : " " )
49+
50+ version = archiveVer
51+ def archiveBase = " ${ rootProject.name} -${ archiveVer} "
6352
6453java {
6554 withJavadocJar()
6655 withSourcesJar()
6756}
6857
69- clean {
70- delete ' logs '
71- delete ' target'
58+ /* Clean */
59+ tasks . named( ' clean ' ) {
60+ delete ' logs ' , ' target' , buildRoot
7261}
7362
63+ /* JaCoCo */
7464jacoco {
7565 toolVersion = ' 0.8.8'
76- reportsDirectory = file( " ${ buildDir } /customJacocoReportDir " )
66+ reportsDirectory = layout . buildDirectory . dir( " jacoco " )
7767}
7868
79- // jacocoTestReport {
80- // reports {
81- // xml.enabled false
82- // csv.enabled false
83- // html.destination file("${buildDir}/jacocoHtml")
84- // }
85- // }
86-
87- jar {
88- group ' Build'
89- description " Assembles a jar archive containing the '${ profile} ' classes, POM and Maven properties."
90-
69+ /* Shared libs dir */
70+ def libsDirProvider = layout. buildDirectory. dir(" libs" )
71+
72+ /* Main JAR */
73+ tasks. named(' jar' , Jar ) {
74+ group = ' Build'
75+ description = " Assembles a jar archive containing the '${ profile} ' classes, POM and Maven properties."
76+
9177 def destPath = " META-INF/maven/${ project.group} /${ rootProject.name} "
92- def timestamp = Long . valueOf(System . currentTimeMillis()). toString()
93- def pomTokens = [projectVersion : archiveVer, projectTimestamp : timestamp, seleniumApi : seleniumApi]
94- def propTokens = [projectVersion : archiveVer, projectGroupId : project. group, projectArtifactId : rootProject. name]
95-
78+ def timestamp = System . currentTimeMillis(). toString()
79+
9680 from(' .' ) {
97- include(' pom.xml' )
98- into(destPath)
99- filter(ReplaceTokens , tokens : pomTokens)
81+ include ' pom.xml'
82+ into destPath
83+ filter ReplaceTokens , tokens : [
84+ projectVersion : archiveVer,
85+ projectTimestamp : timestamp,
86+ seleniumApi : seleniumApi
87+ ]
10088 }
89+
10190 from(' .' ) {
102- include(' pom.properties' )
103- into(destPath)
104- filter(ReplaceTokens , tokens : propTokens)
91+ include ' pom.properties'
92+ into destPath
93+ filter ReplaceTokens , tokens : [
94+ projectVersion : archiveVer,
95+ projectGroupId : project. group,
96+ projectArtifactId : rootProject. name
97+ ]
10598 }
106- archiveFileName = archiveBase + ' .jar'
107- destinationDirectory = libsDir
108- }
10999
110- clean {
111- delete buildRoot
100+ archiveFileName . set( " ${ archiveBase } .jar " )
101+ destinationDirectory . set(libsDirProvider)
112102}
113103
114- sourcesJar {
115- group ' Build'
116- description " Assembles a jar archive containing the '${ profile} ' source files."
117-
118- archiveClassifier = ' sources'
119- from sourceSets. main. allSource
120- archiveFileName = archiveBase + ' -sources.jar'
121- destinationDirectory = libsDir
104+ /* Sources JAR */
105+ tasks. named(' sourcesJar' , Jar ) {
106+ group = ' Build'
107+ archiveClassifier. set(' sources' )
108+ archiveFileName. set(" ${ archiveBase} -sources.jar" )
109+ destinationDirectory. set(libsDirProvider)
122110}
123111
124- javadocJar {
125- dependsOn javadoc
126- group ' Build'
127- description " Assembles a jar archive containing the '${ profile} ' JavaDoc files."
128-
129- archiveClassifier = ' javadoc'
130- from javadoc. destinationDir
131- archiveFileName = archiveBase + ' -javadoc.jar'
132- destinationDirectory = libsDir
112+ /* Javadoc JAR */
113+ tasks. named(' javadocJar' , Jar ) {
114+ group = ' Build'
115+ archiveClassifier. set(' javadoc' )
116+ archiveFileName. set(" ${ archiveBase} -javadoc.jar" )
117+ destinationDirectory. set(libsDirProvider)
133118}
134119
120+ /* Test system property propagation */
135121tasks. withType(Test ). configureEach {
136- // iterate over system properties
137- System . getProperties(). each { key , val ->
138- // if this is a property that should be propagated to the test task
139- if (key. endsWith(' .binary.path' ) || [' injected.' , ' selenium.' , ' appium.' , ' testng.' , ' junit.' ]. any { key. startsWith(it) }) {
140- // if running on Windows and this property defines JSON browser capabilities
141- if (OperatingSystem . current(). isWindows() && key. endsWith(' selenium.browser.caps' )) {
142- // escape double quotes
143- val = val. replace(' "' , ' \\\" ' )
122+ systemProperties. putAll(
123+ System . properties. findAll { k , _ ->
124+ k. endsWith(' .binary.path' ) ||
125+ [' injected.' , ' selenium.' , ' appium.' , ' testng.' , ' junit.' ]
126+ .any { k. startsWith(it) }
127+ }. collectEntries { k , v ->
128+ if (OperatingSystem . current(). isWindows() && k. endsWith(' selenium.browser.caps' )) {
129+ [(k): v. replace(' "' , ' \\\" ' )]
130+ } else {
131+ [(k): v]
144132 }
145- // propagate property
146- systemProperty key, val
147133 }
148- }
149- }
134+ )
150135
136+ reports. html. outputLocation. set(
137+ layout. buildDirectory. dir(" reports/${ name} " )
138+ )
139+ }
151140
152- task testNG (type : Test ) {
141+ /* TestNG */
142+ tasks. register(' testNG' , Test ) {
153143 useTestNG()
154- reports. html. destination = file(" ${ buildDir} /reports/testng" )
155144 testLogging. showStandardStreams = true
156145
157- // --- Optional test JVM debugging ---
146+ testClassesDirs = sourceSets. test. output. classesDirs
147+ classpath = sourceSets. test. runtimeClasspath
148+
158149 if (project. findProperty(' debugTestNG' ) == ' true' ) {
159- jvmArgs + = [
160- ' -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005'
161- ]
150+ jvmArgs ' -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005'
162151 maxParallelForks = 1
163152 forkEvery = 0
164153 }
165154}
166155
167- test {
168- dependsOn testNG
169- reports . html . destination = file( " ${ buildDir } /reports/junit " )
156+ /* JUnit */
157+ tasks . named( ' test ' , Test ) {
158+ dependsOn tasks . named( ' testNG ' )
170159 testLogging. showStandardStreams = true
171-
172- // --- Optional test JVM debugging ---
160+
173161 if (project. findProperty(' debugJUnit' ) == ' true' ) {
174- jvmArgs + = [
175- ' -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5006'
176- ]
162+ jvmArgs ' -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5006'
177163 maxParallelForks = 1
178164 forkEvery = 0
179165 }
180- }
181166
182- scmVersion {
183- hooks {
184- pre ' fileUpdate' , [file : ' README.md' , pattern : {v , p -> / (<version>)\d +\.\d +\.\d +(-s[34]<\/ version>)/ }, replacement : {v , p -> " \$ 1$v \$ 2" }]
185- pre ' fileUpdate' , [file : ' README.md' , pattern : {v , p -> / (selenium-foundation:)\d +\.\d +\.\d +(-s[34])/ }, replacement : {v , p -> " \$ 1$v \$ 2" }]
186- pre ' commit'
187- post ' push'
188- }
167+ jvmArgs " -javaagent:${ classpath.find { it.name.contains('junit-foundation') }} "
189168}
190169
170+ /* Artifacts */
191171artifacts {
192- archives tasks[ ' sourcesJar' ]
193- archives tasks[ ' javadocJar' ]
172+ archives tasks. named( ' sourcesJar' )
173+ archives tasks. named( ' javadocJar' )
194174}
195175
176+ /* Publishing */
196177publishing {
197178 publications {
198179 mavenJava(MavenPublication ) {
199- from( components. java)
180+ from components. java
200181 pom {
201182 name = ' Selenium Foundation'
202183 groupId = project. group
@@ -234,16 +215,19 @@ publishing {
234215 }
235216}
236217
218+ /* Signing */
237219signing {
238220 sign publishing. publications. mavenJava
239221}
240222
241- task install {
242- dependsOn publishToMavenLocal
243- group publishToMavenLocal. group
244- description ' [alias] ' + publishToMavenLocal. description
223+ /* Install alias */
224+ tasks. register(' install' ) {
225+ dependsOn tasks. named(' publishToMavenLocal' )
226+ group = tasks. named(' publishToMavenLocal' ). get(). group
227+ description = " [alias] publish to Maven Local"
245228}
246229
230+ /* Nexus publishing */
247231nexusPublishing {
248232 packageGroup = ' com.nordstrom'
249233 repositories {
@@ -257,6 +241,7 @@ nexusPublishing {
257241 }
258242}
259243
244+ /* Repositories */
260245repositories {
261246 mavenLocal()
262247 mavenCentral()
@@ -265,6 +250,7 @@ repositories {
265250 maven { url " ${ projectDir} /repo" }
266251}
267252
253+ /* Dependencies */
268254dependencies {
269255 constraints {
270256 api ' com.nordstrom.tools:java-utils:3.4.1'
@@ -274,18 +260,15 @@ dependencies {
274260 api ' org.hamcrest:hamcrest-core:3.0'
275261 api ' org.yaml:snakeyaml:2.4'
276262 }
263+
277264 api ' com.nordstrom.tools:java-utils'
278265 api ' com.nordstrom.tools:settings'
279266 api ' com.nordstrom.tools:junit-foundation'
267+
280268 api(' com.github.sbabcoc:logback-testng' ) {
281269 exclude group : ' org.testng' , module : ' testng'
282270 }
271+
283272 api ' org.hamcrest:hamcrest-core'
284273 api ' org.yaml:snakeyaml'
285274}
286-
287- test {
288- jvmArgs = [
289- " -javaagent:${ classpath.find { it.name.contains('junit-foundation') }.absolutePath} "
290- ]
291- }
0 commit comments