Skip to content

Commit bde5396

Browse files
authored
Merge pull request #9 from sabintrademe/sabin/mp-178-migration_to_maven_central
Sabin/mp 178 migration to maven central
2 parents 3cbdaf4 + 54450c1 commit bde5396

File tree

9 files changed

+241
-36
lines changed

9 files changed

+241
-36
lines changed

.github/workflows/publish.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- 'releases/**'
8+
9+
jobs:
10+
publish:
11+
name: Release build and publish
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Check out code
15+
uses: actions/checkout@v2
16+
- name: Set up JDK 11
17+
uses: actions/setup-java@v2
18+
with:
19+
distribution: adopt
20+
java-version: 11
21+
22+
# Builds the release artifacts of the library
23+
- name: Release build
24+
run: ./gradlew :covert:assembleRelease
25+
26+
# Generates other artifacts
27+
- name: Source jar and dokka
28+
run: ./gradlew androidSourcesJar javadocJar
29+
30+
# Runs upload, and then closes & releases the repository
31+
- name: Publish to MavenCentral
32+
run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository
33+
env:
34+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
35+
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
36+
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
37+
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
38+
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
39+
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
40+
SNAPSHOT: false

.github/workflows/snapshot.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Publish Snapshot builds
2+
3+
4+
on:
5+
push:
6+
branches:
7+
- development
8+
- 'snapshot/**'
9+
10+
11+
12+
13+
jobs:
14+
publish:
15+
name: Snapshot build and publish
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Check out code
19+
uses: actions/checkout@v2
20+
- name: Set up JDK 11
21+
uses: actions/setup-java@v2
22+
with:
23+
distribution: adopt
24+
java-version: 11
25+
- name: Release build
26+
27+
run: ./gradlew :covert:assembleRelease
28+
- name: Source jar and dokka
29+
run: ./gradlew androidSourcesJar javadocJar
30+
- name: Publish to MavenCentral
31+
run: ./gradlew publishReleasePublicationToSonatypeRepository
32+
33+
34+
env:
35+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
36+
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
37+
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
38+
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
39+
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
40+
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
41+
SNAPSHOT: true

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,12 @@ Version 2.0.0 *(05-09-2019)*
1010
----------------------------
1111

1212
* Migrates to AndroidX
13-
* Adds optional support for disabling swipe refresh layouts during swipes
13+
* Adds optional support for disabling swipe refresh layouts during swipes
14+
15+
Version 2.0.1 *(17-02-2022)*
16+
----------------------------
17+
18+
* Migration to maven central
19+
*[Deprecation Details](https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/)
20+
21+

build.gradle

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1+
apply plugin: 'io.github.gradle-nexus.publish-plugin'
2+
apply plugin: 'org.jetbrains.dokka'
3+
14
buildscript {
25
apply from: 'common.gradle'
36

47
repositories {
8+
maven { url "https://plugins.gradle.org/m2/" }
59
google()
610
jcenter()
11+
mavenCentral()
712
}
813
dependencies {
914
classpath "com.android.tools.build:gradle:$android_gradle_plugin_version"
1015
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11-
classpath "digital.wup:android-maven-publish:$android_maven_version"
16+
classpath 'io.github.gradle-nexus:publish-plugin:1.1.0'
17+
classpath 'org.jetbrains.dokka:dokka-gradle-plugin:1.6.10'
1218
}
1319
}
1420

@@ -22,3 +28,4 @@ allprojects {
2228
task clean(type: Delete) {
2329
delete rootProject.buildDir
2430
}
31+
apply from: "${rootDir}/publish-root.gradle"

common.gradle

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
ext.version = "2.0.0"
1+
ext.version = "2.0.1"
22
ext.group = "nz.co.trademe.covert"
3-
ext.repo = "Covert"
3+
ext.repo = "covert"
44
ext.org = "trademe"
55
ext.scm = 'https://github.com/TradeMe/Covert.git'
6+
ext.connection = 'scm:git:github.com/TradeMe/Covert.git'
7+
ext.developerConnection = 'scm:git:ssh://github.com/TradeMe/Covert.git'
8+
ext.url = 'https://github.com/TradeMe/Covert'
69
ext.description = 'Covert is a small Android library allowing you to use Material Swipe Actions within a RecyclerView'
710

8-
ext.compile_sdk = 29
9-
ext.min_sdk = 15
11+
ext.compile_sdk = 30
12+
ext.min_sdk = 18
1013
ext.kotlin_version = '1.3.50'
11-
ext.android_maven_version = '3.6.2'
12-
ext.android_gradle_plugin_version = '3.5.0'
14+
ext.android_gradle_plugin_version = '4.0.1'

covert/build.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ apply plugin: 'com.android.library'
33
apply plugin: 'kotlin-android'
44
apply plugin: 'kotlin-android-extensions'
55

6+
ext {
7+
PUBLISH_VERSION = rootVersionName
8+
}
9+
610
apply from: '../common.gradle'
711
apply from: '../publishing.gradle'
812

@@ -17,9 +21,6 @@ android {
1721
}
1822
}
1923

20-
ext {
21-
name = "Covert"
22-
}
2324

2425
dependencies {
2526
implementation fileTree(dir: 'libs', include: ['*.jar'])

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip

publish-root.gradle

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
2+
// Create variables with empty default values
3+
ext["signing.keyId"] = ''
4+
ext["signing.password"] = ''
5+
ext["signing.key"] = ''
6+
ext["ossrhUsername"] = ''
7+
ext["ossrhPassword"] = ''
8+
ext["sonatypeStagingProfileId"] = ''
9+
ext["snapshot"] = 'true'
10+
11+
File secretPropsFile = project.rootProject.file('local.properties')
12+
if (secretPropsFile.exists()) {
13+
// Read local.properties file first if it exists
14+
Properties p = new Properties()
15+
new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) }
16+
p.each { name, value -> ext[name] = value }
17+
} else {
18+
// Use system environment variables
19+
ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
20+
ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
21+
ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
22+
ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
23+
ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
24+
ext["signing.key"] = System.getenv('SIGNING_KEY')
25+
ext["snapshot"] = System.getenv('SNAPSHOT')
26+
}
27+
if (Boolean.parseBoolean(snapshot)) {
28+
ext["rootVersionName"] = project.ext.version + "-SNAPSHOT"
29+
} else {
30+
ext["rootVersionName"] = project.ext.version
31+
}
32+
33+
34+
// Set up Sonatype repository
35+
nexusPublishing {
36+
repositories {
37+
sonatype {
38+
useStaging.set(provider {
39+
!Boolean.parseBoolean(snapshot)
40+
})
41+
stagingProfileId = sonatypeStagingProfileId
42+
username = ossrhUsername
43+
password = ossrhPassword
44+
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
45+
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
46+
}
47+
}
48+
}

publishing.gradle

Lines changed: 82 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,97 @@
1-
if (project.plugins.hasPlugin("com.android.library")) {
21

3-
apply plugin: 'digital.wup.android-maven-publish'
2+
apply plugin: 'maven-publish'
3+
apply plugin: 'signing'
4+
apply plugin: 'org.jetbrains.dokka'
45

5-
project.afterEvaluate {
6-
task sourcesJar(type: Jar) {
7-
from android.sourceSets.main.java.srcDirs
8-
}
6+
task androidSourcesJar(type: Jar) {
7+
archiveClassifier.set('sources')
8+
if (project.plugins.findPlugin("com.android.library")) {
9+
// For Android libraries
10+
from android.sourceSets.main.java.srcDirs
11+
from android.sourceSets.main.kotlin.srcDirs
12+
} else {
13+
from sourceSets.main.java.srcDirs
14+
from sourceSets.main.kotlin.srcDirs
915
}
1016

11-
task androidSourcesJar(type: Jar) {
12-
classifier = 'sources'
13-
from android.sourceSets.main.java.source
14-
}
1517

18+
}
19+
task javadocJar(type: Jar, dependsOn: dokkaJavadoc) {
20+
archiveClassifier.set('javadoc')
21+
from dokkaJavadoc.outputDirectory
22+
}
23+
24+
artifacts {
25+
archives androidSourcesJar
26+
archives javadocJar
27+
}
28+
29+
30+
afterEvaluate {
1631
publishing {
32+
1733
publications {
18-
aar(MavenPublication) {
19-
from project.components.android
20-
artifact project.androidSourcesJar
34+
release(MavenPublication) {
2135
groupId project.ext.group
22-
artifactId project.name
23-
version project.ext.version
24-
}
25-
}
36+
artifactId project.ext.repo
37+
version PUBLISH_VERSION
38+
39+
if (project.plugins.findPlugin("com.android.library")) {
40+
from components.release
41+
} else {
42+
from components.java
43+
}
44+
45+
artifact androidSourcesJar
46+
artifact javadocJar
2647

27-
repositories {
28-
maven {
29-
name 'Bintray'
30-
url "https://api.bintray.com/maven/${project.org}/${project.repo}/${project.name}/;publish=1"
48+
// metadata
49+
pom {
50+
name = project.ext.repo
51+
description = 'SDK'
52+
url = project.ext.url
53+
licenses {
54+
license {
55+
name = 'Covert License'
56+
url = 'https://github.com/TradeMe/Covert/blob/master/LICENSE'
57+
}
58+
}
59+
developers {
60+
developer {
61+
id = 'sabinmj'
62+
name = 'Sabin Mulakukodiyan'
63+
email = 'sabin.mulakukodiyan@trademe.co.nz'
64+
}
65+
// Add all other devs here...
66+
}
3167

32-
credentials {
33-
username BINTRAY_USERNAME
34-
password BINTRAY_API_KEY
68+
// Version control info - if you're using GitHub, follow the
69+
// format as seen here
70+
scm {
71+
connection = project.ext.connection
72+
developerConnection = project.ext.developerConnection
73+
url = project.ext.url
74+
75+
}
3576
}
3677
}
3778
}
3879
}
80+
}
81+
signing {
82+
if (rootProject.ext["signing.keyId"] && rootProject.ext["signing.key"] && rootProject.ext["signing.password"]) {
83+
useInMemoryPgpKeys(
84+
rootProject.ext["signing.keyId"],
85+
rootProject.ext["signing.key"],
86+
rootProject.ext["signing.password"],
87+
)
88+
sign publishing.publications
89+
90+
} else {
91+
sign configurations.archives
92+
}
93+
}
94+
java {
95+
sourceCompatibility = JavaVersion.VERSION_1_8
96+
targetCompatibility = JavaVersion.VERSION_1_8
3997
}

0 commit comments

Comments
 (0)