Skip to content

Commit

Permalink
Fix plugins, dependencies and layout for Gradle 7 (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbabcoc authored Mar 6, 2022
1 parent 69bf387 commit 4f7bfdb
Show file tree
Hide file tree
Showing 29 changed files with 152 additions and 207 deletions.
240 changes: 79 additions & 161 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
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'
id 'java-library'
id 'maven-publish'
id 'jacoco'
id 'signing'
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
id 'pl.allegro.tech.build.axion-release' version '1.13.6'
}

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'

Expand All @@ -32,7 +21,7 @@ if (!project.hasProperty('profile')) {
apply from: "${profile}Deps.gradle"

def archiveVer = null
def verBits = project.version.split('-')
def verBits = scmVersion.version.split('-')
def seleniumApi = 's' + profile.charAt(8)
if (verBits.length > 1) {
if (verBits[1].equals(seleniumApi)) {
Expand All @@ -47,52 +36,10 @@ if (verBits.length > 1) {
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
}
java {
withJavadocJar()
withSourcesJar()
}

clean {
Expand All @@ -113,15 +60,7 @@ jacocoTestReport {
}
}

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) {
jar {
group 'Build'
description "Assembles a jar archive containing the '${profile}' classes, POM and Maven properties."

Expand All @@ -130,7 +69,6 @@ task("${profile}Jar", type: Jar) {
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)
Expand All @@ -143,29 +81,29 @@ task("${profile}Jar", type: Jar) {
}
archiveFileName = archiveBase + '.jar'
destinationDirectory = libsDir
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

clean {
delete buildRoot
}

task("${profile}SourcesJar", type: Jar) {
sourcesJar {
group 'Build'
description "Assembles a jar archive containing the '${profile}' source files."

classifier = 'sources'
from sourceSets["${profile}"].allSource
from sourceSets.main.allSource
archiveFileName = archiveBase + '-sources.jar'
destinationDirectory = libsDir
}

task("${profile}JavadocJar", type: Jar, dependsOn: "${profile}Javadoc") {
javadocJar {
dependsOn javadoc
group 'Build'
description "Assembles a jar archive containing the '${profile}' JavaDoc files."

classifier = 'javadoc'
from tasks["${profile}Javadoc"].destinationDir
from javadoc.destinationDir
archiveFileName = archiveBase + '-javadoc.jar'
destinationDirectory = libsDir
}
Expand All @@ -182,104 +120,84 @@ test {
testLogging.showStandardStreams = true
}

scmVersion {
hooks {
pre 'fileUpdate', [file: 'README.md', pattern: {v, p -> /(<version>)$v(-s[23]<\/version>)/}, replacement: {v, p -> "\$1$v\$2"}]
pre 'fileUpdate', [file: 'README.md', pattern: {v, p -> /(selenium-foundation:)$v(-s[23])/}, replacement: {v, p -> "\$1$v\$2"}]
pre 'commit'
post 'push'
}
}

artifacts {
archives tasks["${profile}Jar"]
archives tasks["${profile}SourcesJar"]
archives tasks["${profile}JavadocJar"]
archives tasks['sourcesJar']
archives tasks['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)
publishing {
publications {
mavenJava(MavenPublication) {
from(components.java)
pom {
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'
}
}

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)
}
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}

pom.scopeMappings.with {
mappings.clear()
addMapping(300, configurations.compile, 'compile')
addMapping(300, configurations["${profile}Compile"], 'compile')
developers {
developer {
id = 'scoba'
name = 'Scott Babcock'
email = 'scoba@hotmail.com'
organization = 'Nordstrom'
organizationUrl = 'https://shop.nordstrom.com'
}
}
}
}
}
}

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'
}
}
task install {
dependsOn publishToMavenLocal
group publishToMavenLocal.group
description '[alias] ' + publishToMavenLocal.description
}

developers {
developer {
id 'scoba'
name 'Scott Babcock'
email 'scoba@hotmail.com'
organization 'Nordstrom'
organizationUrl 'https://shop.nordstrom.com'
nexusPublishing {
packageGroup = 'com.nordstrom'
repositories {
ossrh {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
if (project.hasProperty('ossrhStagingProfileId')) {
stagingProfileId = ossrhStagingProfileId
}
}
}
}

nexusStaging {
packageGroup = 'com.nordstrom'
stagingProfileId = '76d943f622957'
}

repositories {
mavenLocal()
mavenCentral()
Expand All @@ -289,14 +207,14 @@ repositories {
}

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') {
api 'com.nordstrom.tools:java-utils:2.1.0'
api 'com.nordstrom.tools:settings:2.3.10'
api 'com.nordstrom.tools:junit-foundation:15.3.4'
api('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' } }
api('org.hamcrest:hamcrest-core') { version { strictly '2.2' } }
api('org.yaml:snakeyaml') { version { strictly '1.28' } }
}

test {
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
profile=selenium3
version=22.4.4-SNAPSHOT
org.gradle.java.installations.auto-detect=false
org.gradle.java.installations.auto-download=false
org.gradle.java.installations.fromEnv=JDK7_HOME,JDK8_HOME,JDK11_HOME
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@
</goals>
<configuration>
<sources>
<source>src/main/java-s2</source>
<source>src/selenium2/java</source>
</sources>
</configuration>
</execution>
Expand Down Expand Up @@ -450,7 +450,7 @@
</goals>
<configuration>
<sources>
<source>src/main/java-s3</source>
<source>src/selenium3/java</source>
</sources>
</configuration>
</execution>
Expand Down
Loading

0 comments on commit 4f7bfdb

Please sign in to comment.