Skip to content

Commit c328379

Browse files
Merge pull request #9 from stepstone-tech/create-scripts-for-maven-publication-and-release-version-2-2-0
Prepare publishing to maven central & prepare 2.2.0 version
2 parents 952d4f5 + e6b299a commit c328379

File tree

6 files changed

+146
-83
lines changed

6 files changed

+146
-83
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ It heavily depends on [Android Test Orchestrator](https://medium.com/stepstone-t
1515
### 1. Add a Gradle dependency in your `build.gradle`
1616

1717
```groovy
18-
implementation 'com.stepstone.xrunner:xrunner-library:2.1.0'
18+
implementation 'com.stepstone.xrunner:xrunner-library:2.2.0'
1919
```
2020

2121
*NOTE:* not on AndroidX yet? See *Compatibility* section at the bottom.
@@ -46,7 +46,7 @@ android {
4646
}
4747
4848
dependencies {
49-
androidTestUtil 'androidx.test:orchestrator:1.2.0'
49+
androidTestUtil 'androidx.test:orchestrator:1.4.0'
5050
}
5151
```
5252

@@ -85,7 +85,7 @@ Here are some samples:
8585

8686
| XRunner version | Test runner version |
8787
|:------------------------------------------------------------------------:|:---------------------------------------:|
88-
| [X.Y.Z](https://github.com/stepstone-tech/AndroidTestXRunner/tree/X.Y.Z) | `androidx.test:runner:1.4.0` |
88+
| [2.2.0](https://github.com/stepstone-tech/AndroidTestXRunner/tree/2.2.0) | `androidx.test:runner:1.4.0` |
8989
| [2.1.0](https://github.com/stepstone-tech/AndroidTestXRunner/tree/2.1.0) | `androidx.test:runner:1.2.0` |
9090
| [2.0.0](https://github.com/stepstone-tech/AndroidTestXRunner/tree/2.0.0) | `androidx.test:runner:1.1.0` |
9191
| [1.0.0](https://github.com/stepstone-tech/AndroidTestXRunner/tree/1.0.0) | `com.android.support.test:runner:1.0.2` |

build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ buildscript {
1515
}
1616
}
1717

18+
plugins {
19+
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
20+
}
21+
1822
allprojects {
1923
repositories {
2024
google()
@@ -45,3 +49,5 @@ configure(allprojects) {
4549
task clean(type: Delete) {
4650
delete rootProject.buildDir
4751
}
52+
53+
apply from: "xrunner-library/scripts/publish-root.gradle"

ktlint.gradle

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,12 @@
22
//
33
// kotlin-gradle-plugin must be applied for configuration below to work
44
// (see https://kotlinlang.org/docs/reference/using-gradle.html)
5-
6-
repositories {
7-
jcenter()
8-
}
9-
105
configurations {
116
ktlint
127
}
138

149
dependencies {
15-
ktlint "com.pinterest:ktlint:0.34.2"
10+
ktlint "com.pinterest:ktlint:0.42.1"
1611
// additional 3rd party ruleset(s) can be specified here
1712
// just add them to the classpath (e.g. ktlint 'groupId:artifactId:version') and
1813
// ktlint will pick them up

xrunner-library/build.gradle

Lines changed: 5 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -31,93 +31,24 @@ dependencies {
3131
}
3232

3333
ext {
34-
bintrayRepo = 'maven'
35-
bintrayName = 'android-test-xrunner'
36-
37-
publishedGroupId = 'com.stepstone.xrunner'
34+
artifactGroupId = 'com.stepstone.xrunner'
3835
libraryName = 'Android Test XRunner'
39-
artifact = 'xrunner-library'
36+
artifactId = 'xrunner-library'
4037

4138
libraryDescription = 'Running UI tests multiple times made easy'
4239

4340
siteUrl = 'https://github.com/stepstone-tech/AndroidTestXRunner'
44-
gitUrl = 'https://github.com/stepstone-tech/AndroidTestXRunner.git'
4541

46-
libraryVersion = '2.1.0'
42+
libraryVersion = '2.2.0'
4743

4844
licenseName = 'The Apache Software License, Version 2.0'
4945
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
50-
allLicenses = ["Apache-2.0"]
5146
}
5247

5348
task sourcesJar(type: Jar) {
54-
classifier = 'sources'
49+
getArchiveClassifier().set("sources")
5550
from android.sourceSets.main.java.srcDirs
5651
}
5752

58-
dokkaJavadoc.configure {
59-
dokkaSourceSets {
60-
named("main") {
61-
noAndroidSdkLink.set(false)
62-
}
63-
}
64-
}
65-
66-
task javadocJar(type: Jar, dependsOn: dokkaJavadoc) {
67-
classifier = 'javadoc'
68-
from "$buildDir/dokka/javadoc"
69-
}
70-
71-
publishing {
72-
publications {
73-
MyPublication(MavenPublication) {
74-
75-
artifact sourcesJar
76-
artifact javadocJar
77-
artifact("$buildDir/outputs/aar/xrunner-library-release.aar")
78-
79-
groupId publishedGroupId
80-
artifactId artifact
81-
version libraryVersion
82-
83-
pom {
84-
packaging 'aar'
85-
withXml {
86-
87-
asNode().appendNode('name', libraryName)
88-
89-
asNode().appendNode('description', libraryDescription)
90-
91-
asNode().appendNode('url', siteUrl)
92-
93-
// License
94-
def licensesNode = asNode().appendNode('licenses')
95-
def licenseNode = licensesNode.appendNode('license')
96-
licenseNode.appendNode('name', licenseName)
97-
licenseNode.appendNode('url', licenseUrl)
98-
99-
// Git
100-
def scmNode = asNode().appendNode('scm')
101-
scmNode.appendNode('connection', gitUrl)
102-
scmNode.appendNode('developerConnection', gitUrl)
103-
scmNode.appendNode('url', siteUrl)
104-
105-
def dependenciesNode = asNode().appendNode('dependencies')
106-
107-
// Iterate over the implementation dependencies (we don't want the test ones), adding a <dependency> node for each
108-
configurations.implementation.allDependencies.each {
109-
// Ensure dependencies such as fileTree are not included.
110-
if (it.name != 'unspecified') {
111-
def dependencyNode = dependenciesNode.appendNode('dependency')
112-
dependencyNode.appendNode('groupId', it.group)
113-
dependencyNode.appendNode('artifactId', it.name)
114-
dependencyNode.appendNode('version', it.version)
115-
}
116-
}
117-
}
118-
}
119-
}
120-
}
121-
}
122-
12353
publishToMavenLocal.dependsOn 'assembleRelease'
54+
apply from: "scripts/publish-module.gradle"
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// based on https://getstream.io/blog/publishing-libraries-to-mavencentral-2021/
2+
// & https://gist.github.com/zsmb13/56ed98c8fe916de441f2a9d8e060cd4a
3+
apply plugin: 'maven-publish'
4+
apply plugin: 'signing'
5+
apply plugin: 'org.jetbrains.dokka'
6+
7+
task androidSourcesJar(type: Jar) {
8+
archiveClassifier.set('sources')
9+
from android.sourceSets.main.java.srcDirs
10+
from android.sourceSets.main.kotlin.srcDirs
11+
}
12+
13+
tasks.withType(dokkaHtmlPartial.getClass()).configureEach {
14+
pluginsMapConfiguration.set(
15+
["org.jetbrains.dokka.base.DokkaBase": """{ "separateInheritedMembers": true}"""]
16+
)
17+
}
18+
19+
dokkaJavadoc.configure {
20+
dokkaSourceSets {
21+
named("main") {
22+
noAndroidSdkLink.set(false)
23+
}
24+
}
25+
}
26+
27+
task javadocJar(type: Jar, dependsOn: dokkaJavadoc) {
28+
archiveClassifier.set('javadoc')
29+
from dokkaJavadoc.outputDirectory
30+
}
31+
32+
artifacts {
33+
archives androidSourcesJar
34+
archives javadocJar
35+
}
36+
37+
group = artifactGroupId
38+
version = libraryVersion
39+
40+
afterEvaluate {
41+
publishing {
42+
publications {
43+
release(MavenPublication) {
44+
groupId artifactGroupId
45+
artifactId artifactId
46+
version libraryVersion
47+
from components.release
48+
49+
artifact androidSourcesJar
50+
artifact javadocJar
51+
52+
pom {
53+
name = artifactId
54+
description = libraryDescription
55+
url = siteUrl
56+
licenses {
57+
license {
58+
name = licenseName
59+
url = licenseUrl
60+
}
61+
}
62+
developers {
63+
developer {
64+
id = 'zawadz88'
65+
name = 'Piotr Zawadzki'
66+
67+
}
68+
developer {
69+
id = 'RobertZagorski'
70+
name = 'Robert Zagórski'
71+
72+
}
73+
}
74+
scm {
75+
connection = 'scm:[email protected]:stepstone-tech/AndroidTestXRunner.git'
76+
developerConnection = 'scm:git:ssh://github.com:stepstone-tech/AndroidTestXRunner.git'
77+
url = siteUrl
78+
}
79+
}
80+
}
81+
}
82+
}
83+
}
84+
85+
signing {
86+
useInMemoryPgpKeys(
87+
rootProject.ext["signing.keyId"],
88+
rootProject.ext["signing.key"],
89+
rootProject.ext["signing.password"],
90+
)
91+
sign publishing.publications
92+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// based on https://getstream.io/blog/publishing-libraries-to-mavencentral-2021/
2+
// & https://gist.github.com/zsmb13/56ed98c8fe916de441f2a9d8e060cd4a
3+
// Create variables with empty default values
4+
ext["ossrhUsername"] = ''
5+
ext["ossrhPassword"] = ''
6+
ext["sonatypeStagingProfileId"] = ''
7+
ext["signing.keyId"] = ''
8+
ext["signing.password"] = ''
9+
ext["signing.key"] = ''
10+
ext["snapshot"] = ''
11+
12+
File secretPropsFile = project.rootProject.file('local.properties')
13+
if (secretPropsFile.exists()) {
14+
// Read local.properties file first if it exists
15+
Properties p = new Properties()
16+
new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) }
17+
p.each { name, value -> ext[name] = value }
18+
} else {
19+
// Use system environment variables
20+
ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
21+
ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
22+
ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
23+
ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
24+
ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
25+
ext["signing.key"] = System.getenv('SIGNING_KEY')
26+
ext["snapshot"] = System.getenv('SNAPSHOT')
27+
}
28+
29+
// Set up Sonatype repository
30+
nexusPublishing {
31+
repositoryDescription = "com.stepstone.xrunner:AndroidTestXRunner"
32+
repositories {
33+
sonatype {
34+
stagingProfileId = sonatypeStagingProfileId
35+
username = ossrhUsername
36+
password = ossrhPassword
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)