diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..3a3b974 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,38 @@ +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 + + - name: Release build + run: ./gradlew clean build + + # 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 }} diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml new file mode 100644 index 0000000..d60815c --- /dev/null +++ b/.github/workflows/snapshot.yml @@ -0,0 +1,38 @@ +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 clean build + - 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 f1041ac..5a40ffe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ Change Log ========== - + + Version 1.0.4 *(28-02-2022)* + ---------------------------- + + * Migration to maven central + Version 1.0.3 *(26-06-2018)* ---------------------------- diff --git a/README.md b/README.md index 5f55756..db88442 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ buildscript { } dependencies { - classpath 'nz.co.trademe.includeme:includeme:1.0.3' + classpath 'nz.co.trademe.includeme:includeme:1.0.4' } } diff --git a/build.gradle b/build.gradle index 7748a18..b143c65 100644 --- a/build.gradle +++ b/build.gradle @@ -1,22 +1,31 @@ -ext { - name = "IncludeMe" -} - -apply from: 'common.gradle' +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() } dependencies { classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$bintray_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' } } + + +apply from: "${rootDir}/publish-root.gradle" + +ext { + PUBLISH_VERSION = rootVersionName + ARTIFACT_ID = "includeme" +} + apply plugin: 'java-gradle-plugin' apply plugin: 'kotlin' apply plugin: 'maven-publish' @@ -31,19 +40,18 @@ gradlePlugin { } } -sourceCompatibility = 1.8 - repositories { google() jcenter() } + dependencies { - compile gradleApi() - compile "com.android.tools.build:gradle:$agp_version" - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + implementation gradleApi() + implementation "com.android.tools.build:gradle:$agp_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - testCompile 'junit:junit:4.12' + testImplementation'junit:junit:4.12' } @@ -66,4 +74,5 @@ compileKotlin { } compileTestKotlin { kotlinOptions.jvmTarget = "1.8" -} \ No newline at end of file +} + diff --git a/common.gradle b/common.gradle index 823cb39..8ec5307 100644 --- a/common.gradle +++ b/common.gradle @@ -1,8 +1,14 @@ -ext.version = "1.0.3" +ext.version = "1.0.4" ext.group = "nz.co.trademe.includeme" +ext.repo = "includeme" ext.scm = 'https://github.com/TradeMe/IncludeMe.git' ext.description = 'A Gradle plugin that simplifies working with composite builds' +ext.connection = 'scm:git:github.com/TradeMe/IncludeMe.git' +ext.developerConnection = 'scm:git:ssh://github.com/TradeMe/IncludeMe.git' +ext.url = 'https://github.com/TradeMe/IncludeMe' + + ext.bintray_version = '1.7.3' -ext.kotlin_version = '1.2.30' -ext.agp_version = "3.0.1" +ext.kotlin_version = '1.5.0' +ext.agp_version = "4.0.1" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e6670c5..662499a 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.6-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip diff --git a/publish-root.gradle b/publish-root.gradle new file mode 100644 index 0000000..fe05c24 --- /dev/null +++ b/publish-root.gradle @@ -0,0 +1,49 @@ + +// 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) + }) + version = rootVersionName + 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 427c47b..221a460 100644 --- a/publishing.gradle +++ b/publishing.gradle @@ -1,77 +1,97 @@ apply plugin: 'maven-publish' -apply plugin: 'com.jfrog.bintray' +apply plugin: 'signing' +apply plugin: 'org.jetbrains.dokka' -project.group = project.ext.group -project.version = project.ext.version - -bintray { - user = project.hasProperty("BINTRAY_USERNAME") ? project.property('BINTRAY_USERNAME') : null - key = project.hasProperty("BINTRAY_API_KEY") ? project.property('BINTRAY_API_KEY') : null - pkg { - repo = project.ext.name - name = getArtifactId() - userOrg = 'trademe' - licenses = ['Apache-2.0'] - vcsUrl = project.ext.scm - version { - name = project.version - desc = project.ext.description - released = new Date() - vcsTag = project.version - } - publications = ['Bintray'] +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 } -} -// Create the pom configuration: -def pomConfig = { - licenses { - license { - name "MIT License" - url "http://www.opensource.org/licenses/mit-license.php" - distribution "repo" - } - } - scm { - url ext.scm - } + +} +task javadocJar(type: Jar, dependsOn: dokkaJavadoc) { + archiveClassifier.set('javadoc') + from dokkaJavadoc.outputDirectory } -task sourceJar(type: Jar, dependsOn: 'classes') { - from sourceSets.main.allSource - classifier = 'sources' +artifacts { + archives androidSourcesJar + archives javadocJar } -publishing.publications { - Bintray(MavenPublication) { - from components.java +group = project.ext.group - groupId project.ext.group - artifactId getArtifactId() - version project.ext.version +afterEvaluate { + publishing { - artifact sourceJar + publications { + release(MavenPublication) { + groupId group + artifactId ARTIFACT_ID + version PUBLISH_VERSION - pom.withXml { - def root = asNode() - root.appendNode('description', project.ext.description) - root.appendNode('name', project.ext.name) - root.appendNode('url', project.ext.scm) - root.children().last() + pomConfig - } - } -} + if (project.plugins.findPlugin("com.android.library")) { + from components.release + } else { + from components.java + } -def getArtifactId() { - return getArtifactId(project) + artifact androidSourcesJar + artifact javadocJar -} + // metadata + pom { + name = ARTIFACT_ID + description = 'SDK' + url = project.ext.url + licenses { + license { + name = "MIT License" + url = "http://www.opensource.org/licenses/mit-license.php" + } + } + 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 -def getArtifactId(someProject) { - if (!someProject.ext.has('artifactId')) { - //default artifactId is the project/module name - return someProject.getName() + } + } + } + } + } +} +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 + } else { + sign configurations.archives } - return someProject.ext.artifactId +} +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 } \ No newline at end of file