diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..e1e9a85 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,39 @@ +name: Publish + +on: + push: + branches: + - master + +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 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 }} + SNAPSHOT: false \ No newline at end of file diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml new file mode 100644 index 0000000..964b4e4 --- /dev/null +++ b/.github/workflows/snapshot.yml @@ -0,0 +1,37 @@ +name: Publish Snapshot builds + + +on: + push: + branches: + - 'release/**' +jobs: + publish: + name: Snapshot 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 + - name: Release build + + run: ./gradlew googlemaps:assembleRelease -x :mapbox:assembleRelease -x :mapme:assembleRelease + - name: Source jar and dokka + run: ./gradlew androidSourcesJar javadocJar + - name: Publish to MavenCentral + run: ./gradlew publishReleasePublicationToSonatypeRepository + + + +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 }} + SNAPSHOT: true \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index d44ad32..7732653 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ Change Log ========== +Version 1.2.1 *(28-03-2022)* +---------------------------- + +* Migration to maven central Version 1.2.0 *(25-10-2018)* ---------------------------- diff --git a/README.md b/README.md index 13efec7..e76ec18 100644 --- a/README.md +++ b/README.md @@ -15,13 +15,13 @@ Download ```groovy //base dependency -compile 'nz.co.trademe.mapme:mapme:1.2.0' +compile 'nz.co.trademe.mapme:mapme:1.2.1' //for Google Maps support -compile 'nz.co.trademe.mapme:googlemaps:1.2.0' +compile 'nz.co.trademe.mapme:googlemaps:1.2.1' //for Mapbox support -compile 'nz.co.trademe.mapme:mapbox:1.2.0' +compile 'nz.co.trademe.mapme:mapbox:1.2.1' ``` diff --git a/build.gradle b/build.gradle index 21c7ac5..d95e577 100644 --- a/build.gradle +++ b/build.gradle @@ -1,17 +1,31 @@ +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() } } task clean(type: Delete) { delete rootProject.buildDir } +apply from: "${rootDir}/publish-root.gradle" \ No newline at end of file diff --git a/common.gradle b/common.gradle index 70ab3de..30a8548 100644 --- a/common.gradle +++ b/common.gradle @@ -1,16 +1,20 @@ -ext.version = "1.2.0" +ext.version = "1.2.1" 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.minSdk = 15 -ext.buildTools = "28.0.3" -ext.kotlin_version = '1.2.71' +ext.connection = 'scm:git:github.com/TradeMe/MapMe.git' +ext.developerConnection = 'scm:git:ssh://github.com/TradeMe/MapMe.git' + +ext.compileSdk = 30 +ext.minSdk = 19 +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 = '4.0.1' ext.mapbox_version = '6.4.0' ext.google_play_services_version = '15.0.1' ext.androidx_version = '1.0.0' diff --git a/googlemaps/build.gradle b/googlemaps/build.gradle index 192c7f7..4824cbc 100644 --- a/googlemaps/build.gradle +++ b/googlemaps/build.gradle @@ -13,9 +13,11 @@ buildscript { apply from: '../common.gradle' ext { - name = "MapMe GoogleMaps" + PUBLISH_VERSION = rootVersionName + ARTIFACT_ID = "googlemaps" } + apply plugin: 'com.android.library' apply plugin: 'kotlin-android' apply from: '../publishing.gradle' diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2c8e4e3..0c931fc 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip diff --git a/mapbox/build.gradle b/mapbox/build.gradle index 9e94e07..0d776ca 100644 --- a/mapbox/build.gradle +++ b/mapbox/build.gradle @@ -13,7 +13,8 @@ buildscript { apply from: '../common.gradle' ext { - name = "MapMe Mapbox" + PUBLISH_VERSION = rootVersionName + ARTIFACT_ID = "mapbox" } apply plugin: 'com.android.library' diff --git a/mapme/build.gradle b/mapme/build.gradle index 26f6964..f65a934 100644 --- a/mapme/build.gradle +++ b/mapme/build.gradle @@ -15,7 +15,8 @@ buildscript { apply from: '../common.gradle' ext { - name = "MapMe" + PUBLISH_VERSION = rootVersionName + ARTIFACT_ID = "mapme" } diff --git a/publish-root.gradle b/publish-root.gradle new file mode 100644 index 0000000..a54f1ab --- /dev/null +++ b/publish-root.gradle @@ -0,0 +1,48 @@ + +// Create variables with empty default values +ext["signing.keyId"] = '' +ext["signing.password"] = '' +ext["signing.key"] = '' +ext["ossrhUsername"] = '' +ext["ossrhPassword"] = '' +ext["sonatypeStagingProfileId"] = '' +ext["snapshot"] = 'true' + +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') +} + +if (Boolean.parseBoolean(snapshot)) { + ext["rootVersionName"] = project.ext.version + "-SNAPSHOT" +} else { + ext["rootVersionName"] = project.ext.version +} + +// Set up Sonatype repository +nexusPublishing { + repositories { + sonatype { + useStaging.set(provider { + !Boolean.parseBoolean(snapshot) + }) + 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/")) + } + } +} \ No newline at end of file diff --git a/publishing.gradle b/publishing.gradle index b61cd46..d8127dd 100644 --- a/publishing.gradle +++ b/publishing.gradle @@ -1,37 +1,95 @@ -if (project.plugins.hasPlugin("com.android.library")) { - apply plugin: 'digital.wup.android-maven-publish' +apply plugin: 'maven-publish' +apply plugin: 'signing' +apply plugin: 'org.jetbrains.dokka' - project.afterEvaluate { - task sourcesJar(type: Jar) { - from android.sourceSets.main.java.srcDirs - } +task androidSourcesJar(type: Jar) { + archiveClassifier.set('sources') + if (project.plugins.findPlugin("com.android.library")) { + + // For Android libraries + from android.sourceSets.main.java.srcDirs + from android.sourceSets.main.kotlin.srcDirs + } else { + from sourceSets.main.java.srcDirs + from sourceSets.main.kotlin.srcDirs } + +} +task javadocJar(type: Jar, dependsOn: dokkaJavadoc) { + archiveClassifier.set('javadoc') + from dokkaJavadoc.outputDirectory +} + +artifacts { + archives androidSourcesJar + archives javadocJar +} + + +afterEvaluate { publishing { + publications { - aar(MavenPublication) { - from project.components.android - artifact project.sourcesJar { - // not required, includes sourcesJar with correct classifier - classifier "sources" - } + release(MavenPublication) { groupId project.ext.group - artifactId project.name - version project.ext.version - } - } + artifactId ARTIFACT_ID + version PUBLISH_VERSION + + if (project.plugins.findPlugin("com.android.library")) { + from components.release + } else { + from components.java + } - repositories { - maven { - name 'Bintray' - url "https://api.bintray.com/maven/${project.org}/${project.repo}/${project.name}/;publish=1" + artifact androidSourcesJar + artifact javadocJar - credentials { - username BINTRAY_USERNAME - password BINTRAY_API_KEY + // metadata + pom { + name = ARTIFACT_ID + description = 'SDK' + url = project.ext.url + licenses { + license { + name = 'MapMe License' + url = 'https://github.com/sabintrademe/MapMe/blob/master/LICENSE' + } + } + developers { + developer { + id = 'sabinmj' + name = 'Sabin Mulakukodiyan' + email = 'sabin.mulakukodiyan@trademe.co.nz' + } + // Add all other devs here... + } + + // Version control info - if you're using GitHub, follow the + // format as seen here + scm { + connection = project.ext.connection + developerConnection = project.ext.developerConnection + url = project.ext.url + + } } } } } +} +signing { + if (rootProject.ext["signing.keyId"] && rootProject.ext["signing.key"] && rootProject.ext["signing.password"]) { + useInMemoryPgpKeys( + rootProject.ext["signing.keyId"], + rootProject.ext["signing.key"], + rootProject.ext["signing.password"], + ) + sign publishing.publications + } +} +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 } \ No newline at end of file diff --git a/sample/build.gradle b/sample/build.gradle index 8a03314..09ec390 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -70,6 +70,7 @@ repositories { } dependencies { + compile project(path: ':mapme') compile 'com.jakewharton.timber:timber:4.5.1' compile 'com.squareup.picasso:picasso:2.5.2'