Skip to content

Commit

Permalink
migration to maven central
Browse files Browse the repository at this point in the history
  • Loading branch information
sabintrademe committed Feb 18, 2022
1 parent 243285e commit c927219
Show file tree
Hide file tree
Showing 11 changed files with 255 additions and 78 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Publish

on:
push:
branches:
- main
- 'releases/**'

jobs:
publish:
name: Release build and publish
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
distribution: adopt
java-version: 11

# Builds the release artifacts of the library
- name: Release build
run: ./gradlew assembleRelease -x :googlemaps:assembleRelease -x :mapbox:assembleRelease -x :mapme:assembleRelease

# Generates other artifacts
- name: Source jar and dokka
run: ./gradlew androidSourcesJar javadocJar

# Runs upload, and then closes & releases the repository
- name: Publish to MavenCentral
run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
37 changes: 35 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,50 @@
apply plugin: 'io.github.gradle-nexus.publish-plugin'
apply plugin: 'org.jetbrains.dokka'

buildscript {
apply from: 'common.gradle'

repositories {
maven { url "https://plugins.gradle.org/m2/" }
google()
jcenter()
mavenLocal()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:$gradle_version"
classpath "digital.wup:android-maven-publish:$android_maven_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'io.github.gradle-nexus:publish-plugin:1.1.0'
classpath 'org.jetbrains.dokka:dokka-gradle-plugin:1.6.10'
}
}

allprojects {
repositories {
google()
jcenter()
}

afterEvaluate {
// Common library module configurations
if (plugins.hasPlugin("com.android.library") || plugins.hasPlugin("com.android.application")) {
android.compileSdkVersion = project.ext.compileSdk


android.defaultConfig {
minSdkVersion project.ext.minSdk
targetSdkVersion project.ext.compileSdk
vectorDrawables.useSupportLibrary = true
}

android.compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
apply from: "${rootDir}/publish-root.gradle"
14 changes: 9 additions & 5 deletions common.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
ext.version = "1.2.0"
ext.group = "nz.co.trademe.mapme"
ext.repo = "MapMe"
ext.repo = "mapme"
ext.org = "trademe"
ext.scm = 'https://github.com/TradeMe/MapMe.git'
ext.url = 'https://github.com/TradeMe/MapMe'
ext.description = 'MapMe is an Android library that brings the adapter pattern to Maps, simplifying the management of markers and annotations.'

ext.compileSdk = 28
ext.connection = 'scm:git:github.com/TradeMe/MapMe.git'
ext.developerConnection = 'scm:git:ssh://github.com/TradeMe/MapMe.git'

ext.compileSdk = 31
ext.minSdk = 15
ext.buildTools = "28.0.3"
ext.kotlin_version = '1.2.71'
ext.buildTools = "29.0.3"
ext.kotlin_version = '1.5.0'
ext.dokka_version = '0.9.15'
ext.gradle_version = '3.2.0'
ext.gradle_version = '7.0.1'
ext.mapbox_version = '6.4.0'
ext.google_play_services_version = '15.0.1'
ext.androidx_version = '1.0.0'
Expand Down
14 changes: 7 additions & 7 deletions googlemaps/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ apply plugin: 'kotlin-android'
apply from: '../publishing.gradle'

android {
compileSdkVersion compileSdk
compileSdkVersion project.ext.compileSdk
buildToolsVersion buildTools

defaultConfig {
minSdkVersion minSdk
targetSdkVersion compileSdk
minSdkVersion project.ext.minSdk
targetSdkVersion project.ext.compileSdk

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Expand All @@ -49,12 +49,12 @@ repositories {
}

dependencies {
compile "com.google.android.gms:play-services-maps:$google_play_services_version"
compile "androidx.appcompat:appcompat:$androidx_version"
implementation "com.google.android.gms:play-services-maps:$google_play_services_version"
implementation "androidx.appcompat:appcompat:$androidx_version"

compile project(':mapme')
implementation project(':mapme')

compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}


28 changes: 19 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
#Disables an error with Gradle that is fixed in Gradle 4.4 but an error is still thrown with AGP 3.0.1
#error will be removed in 3.1.0
#See https://d.android.com/r/tools/buildscript-classpath-check.html
android.enableBuildScriptClasspathCheck=false

# Bintray credentials - When publishing, ensure changes to this file are not added to source control
BINTRAY_USERNAME=INSERT_USERNAME_HERE
BINTRAY_API_KEY=INSERT_KEY_HERE
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
android.enableJetifier=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
6 changes: 3 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Mar 10 13:26:55 NZDT 2017
#Fri Feb 18 14:17:21 NZDT 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-all.zip
zipStoreBase=GRADLE_USER_HOME
16 changes: 6 additions & 10 deletions mapbox/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ apply plugin: 'kotlin-android'
apply from: '../publishing.gradle'

android {
compileSdkVersion compileSdk
compileSdkVersion project.ext.compileSdk
buildToolsVersion buildTools

defaultConfig {
minSdkVersion minSdk
targetSdkVersion compileSdk
minSdkVersion project.ext.minSdk
targetSdkVersion project.ext.compileSdk

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Expand All @@ -42,10 +42,6 @@ android {
lintConfig new File(rootProject.projectDir, "lint.xml")
}

compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}

repositories {
Expand All @@ -54,11 +50,11 @@ repositories {
}

dependencies {
compile("com.mapbox.mapboxsdk:mapbox-android-sdk:$mapbox_version@aar") {
implementation("com.mapbox.mapboxsdk:mapbox-android-sdk:$mapbox_version@aar") {
transitive = true
}

compile project(':mapme')
implementation project(':mapme')

compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
19 changes: 10 additions & 9 deletions mapme/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
buildscript {
apply from: '../common.gradle'
repositories {
maven { url "https://plugins.gradle.org/m2/" }
google()
jcenter()
mavenLocal()
Expand All @@ -25,12 +26,12 @@ apply from: '../publishing.gradle'


android {
compileSdkVersion compileSdk
compileSdkVersion project.ext.compileSdk
buildToolsVersion buildTools

defaultConfig {
minSdkVersion minSdk
targetSdkVersion compileSdk
minSdkVersion project.ext.minSdk
targetSdkVersion project.ext.compileSdk

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -62,13 +63,13 @@ repositories {
}

dependencies {
testCompile 'junit:junit:4.12'
testCompile "org.mockito:mockito-core:2.7.22"
testCompile "com.nhaarman:mockito-kotlin:1.4.0"
testCompile 'org.amshove.kluent:kluent:1.20'
testImplementation 'junit:junit:4.12'
testImplementation "org.mockito:mockito-core:2.7.22"
testImplementation "com.nhaarman:mockito-kotlin:1.4.0"
testImplementation 'org.amshove.kluent:kluent:1.20'

compile "androidx.recyclerview:recyclerview:$androidx_version"
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "androidx.recyclerview:recyclerview:$androidx_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}


38 changes: 38 additions & 0 deletions publish-root.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

// Create variables with empty default values
ext["signing.keyId"] = ''
ext["signing.password"] = ''
ext["signing.key"] = ''
ext["ossrhUsername"] = ''
ext["ossrhPassword"] = ''
ext["sonatypeStagingProfileId"] = ''

File secretPropsFile = project.rootProject.file('local.properties')
if (secretPropsFile.exists()) {
// Read local.properties file first if it exists
Properties p = new Properties()
new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) }
p.each { name, value -> ext[name] = value }
} else {
// Use system environment variables
ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
ext["signing.key"] = System.getenv('SIGNING_KEY')
ext["snapshot"] = System.getenv('SNAPSHOT')
}

// Set up Sonatype repository
nexusPublishing {
repositories {
sonatype {
stagingProfileId = sonatypeStagingProfileId
username = ossrhUsername
password = ossrhPassword
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
}
}
}
Loading

0 comments on commit c927219

Please sign in to comment.