Skip to content

Commit

Permalink
chore(android): enable maven publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
abhaysood committed Jul 2, 2024
1 parent 4fa858e commit 59833a0
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 77 deletions.
17 changes: 9 additions & 8 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,10 @@ jobs:
uses: gradle/wrapper-validation-action@v1
- name: Publish measure-android
run: ./gradlew clean :measure:publish --no-daemon --no-parallel --no-configuration-cache --stacktrace

# Certain gradle plugin tests depend on the measure-android artifact being published. We run all the tests for
# measure-android-gradle here to ensure everything works.
- name: Run measure-android-gradle tests
run: ./gradlew clean :measure-android-gradle:test --no-daemon --no-parallel --no-configuration-cache --stacktrace
- name: Run measure-android-gradle functional tests
run: ./gradlew clean :measure-android-gradle:functionalTest --no-daemon --no-parallel --no-configuration-cache --stacktrace
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.MAVEN_ARTIFACT_SIGNING_KEY }}

publish-android-gradle:
runs-on: ubuntu-latest
Expand All @@ -130,4 +127,8 @@ jobs:
# - name: Run measure-android-gradle functional tests
# run: ./gradlew clean :measure-android-gradle:functionalTest --no-daemon --no-parallel --no-configuration-cache --stacktrace
- name: Publish measure-android-gradle
run: ./gradlew clean :measure-android-gradle:publishMavenPublicationToGitHubPackagesRepository --no-daemon --no-parallel --no-configuration-cache --stacktrace
run: ./gradlew clean :measure-android-gradle:publishMavenPublicationToGitHubPackagesRepository --no-daemon --no-parallel --no-configuration-cache --stacktrace
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.MAVEN_ARTIFACT_SIGNING_KEY }}
8 changes: 4 additions & 4 deletions measure-android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ Add the following plugin to your project.

```kotlin
plugins {
id("sh.measure.android.gradle") version "0.2.0"
id("sh.measure.android.gradle") version "0.3.0"
}
```

or, use the following if you're using `build.gradle`.

```groovy
plugins {
id 'sh.measure.android.gradle' version '0.2.0'
id 'sh.measure.android.gradle' version '0.3.0'
}
```

Expand All @@ -110,13 +110,13 @@ Add the following to your app's `build.gradle.kts`file.
[//]: # (TODO: Replace with the actual version on maven central)

```kotlin
implementation("sh.measure:measure-android:0.2.0")
implementation("sh.measure:measure-android:0.3.0")
```

or, add the following to your app's `build.gradle`file.

```groovy
implementation 'sh.measure:measure-android:0.2.0'
implementation 'sh.measure:measure-android:0.3.0'
```

### 5. Initialize the SDK
Expand Down
8 changes: 1 addition & 7 deletions measure-android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,4 @@ kotlin.code.style=official

GROUP=sh.measure
MEASURE_ARTIFACT_ID=measure-android
MEASURE_VERSION_NAME=0.2.0

POM_INCEPTION_YEAR=2024
POM_URL=https://github.com/measure-sh/measure
POM_SCM_URL=https://github.com/measure-sh/measure
POM_SCM_CONNECTION=scm:[email protected]:measure-sh/measure.git
POM_SCM_DEV_CONNECTION=scm:[email protected]:measure-sh/measure.git
MEASURE_VERSION_NAME=0.3.0
5 changes: 4 additions & 1 deletion measure-android/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ bundletool = "1.15.6"
android-tools = "31.4.1"
junit-platform-launcher = "1.10.2"
kotlin = "1.9.21"
measure-android = "0.2.0"
measure-android = "0.3.0"
androidx-activity-compose = "1.7.2"
androidx-appcompat = "1.6.1"
androidx-constraintlayout = "2.1.4"
Expand Down Expand Up @@ -42,6 +42,7 @@ diffplug-spotless = "6.24.0"
compose-plugin = "1.5.11"
gradle-plugin-publish = "1.2.0"
autonomousapps-testkit = "0.8"
mavenPublish = "0.29.0"

[libraries]
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity-compose" }
Expand Down Expand Up @@ -109,3 +110,5 @@ diffplug-spotless = { id = "com.diffplug.spotless", version.ref = "diffplug-spot
compose = { id = "org.jetbrains.compose", version.ref = "compose-plugin" }
gradle-plugin-publish = { id = "com.gradle.plugin-publish", version.ref = "gradle-plugin-publish" }
autonomousapps-testkit = { id = "com.autonomousapps.testkit", version.ref = "autonomousapps-testkit" }
mavenPublish = { id = "com.vanniktech.maven.publish", version.ref = "mavenPublish" }

68 changes: 38 additions & 30 deletions measure-android/measure-android-gradle/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import com.vanniktech.maven.publish.GradlePublishPlugin
import com.vanniktech.maven.publish.SonatypeHost

plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.gradle.plugin.publish)
Expand All @@ -6,12 +9,9 @@ plugins {
alias(libs.plugins.diffplug.spotless)
id("sh.measure.plugin.aar2jar")
id("java-gradle-plugin")
id("maven-publish")
alias(libs.plugins.mavenPublish)
}

group = properties["GROUP"] as String
version = properties["MEASURE_PLUGIN_VERSION_NAME"] as String

gradlePlugin {
plugins {
create("plugin") {
Expand All @@ -23,41 +23,49 @@ gradlePlugin {
}
}

kotlin {
jvmToolchain(17)
}

java {
withSourcesJar()
withJavadocJar()
}

val measureGradlePluginVersion = properties["MEASURE_PLUGIN_VERSION_NAME"] as String
private val groupId = properties["MEASURE_PLUGIN_GROUP_ID"] as String
private val artifactId = properties["MEASURE_PLUGIN_ARTIFACT_ID"] as String
private val pluginVersion = properties["MEASURE_PLUGIN_VERSION_NAME"] as String

mavenPublishing {
coordinates(groupId, artifactId, pluginVersion)
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, automaticRelease = false)
signAllPublications()

publishing {
publications {
create<MavenPublication>("maven") {
groupId = properties["GROUP"] as String
artifactId = properties["MEASURE_PLUGIN_ARTIFACT_ID"] as String
version = measureGradlePluginVersion
configure(
GradlePublishPlugin()
)

from(components["java"])
pom {
name.set("Measure Android Gradle Plugin")
description.set("Measure Android Gradle Plugin")
inceptionYear.set("2024")
url.set("https://github.com/measure-sh/measure")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
}

repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/measure-sh/measure")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
developers {
developer {
id.set("measure")
name.set("measure.sh")
}
}
scm {
url.set("https://github.com/measure-sh/measure")
connection.set("scm:git:git://github.com/measure-sh/measure.git")
developerConnection.set("scm:git:ssh://[email protected]/measure-sh/measure.git")
}
}
}

kotlin {
jvmToolchain(17)
}

dependencies {
compileOnly(libs.agp)
compileOnly(libs.asm.util)
Expand Down
10 changes: 2 additions & 8 deletions measure-android/measure-android-gradle/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
GROUP=sh.measure.android.gradle
MEASURE_PLUGIN_GROUP_ID=sh.measure.android.gradle
MEASURE_PLUGIN_ARTIFACT_ID=sh.measure.android.gradle.gradle.plugin
MEASURE_PLUGIN_VERSION_NAME=0.2.0

POM_INCEPTION_YEAR=2024
POM_URL=https://github.com/measure-sh/measure
POM_SCM_URL=https://github.com/measure-sh/measure
POM_SCM_CONNECTION=scm:[email protected]:measure-sh/measure.git
POM_SCM_DEV_CONNECTION=scm:[email protected]:measure-sh/measure.git
MEASURE_PLUGIN_VERSION_NAME=0.3.0
57 changes: 38 additions & 19 deletions measure-android/measure/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,39 +1,58 @@
@file:Suppress("UnstableApiUsage")

import com.diffplug.gradle.spotless.SpotlessExtension
import com.vanniktech.maven.publish.AndroidSingleVariantLibrary
import com.vanniktech.maven.publish.SonatypeHost

plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.kotlinx.binary.compatibility.validator)
alias(libs.plugins.diffplug.spotless)
id("maven-publish")
alias(libs.plugins.mavenPublish)
}

val measureSdkVersion = properties["MEASURE_VERSION_NAME"] as String
publishing {
publications {
create<MavenPublication>("maven") {
groupId = properties["GROUP"] as String
artifactId = properties["MEASURE_ARTIFACT_ID"] as String
version = measureSdkVersion
private val measureSdkVersion = properties["MEASURE_VERSION_NAME"] as String
private val groupId = properties["GROUP"] as String
private val artifactId = properties["MEASURE_ARTIFACT_ID"] as String

afterEvaluate {
from(components["release"])
mavenPublishing {
coordinates(groupId, artifactId, measureSdkVersion)
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, automaticRelease = false)
signAllPublications()

configure(
AndroidSingleVariantLibrary(
variant = "release",
sourcesJar = true,
publishJavadocJar = true,
),
)

pom {
name.set("Measure Android SDK")
description.set("Measure Android SDK")
inceptionYear.set("2024")
url.set("https://github.com/measure-sh/measure")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
}

repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/measure-sh/measure")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
developers {
developer {
id.set("measure")
name.set("measure.sh")
}
}
scm {
url.set("https://github.com/measure-sh/measure")
connection.set("scm:git:git://github.com/measure-sh/measure.git")
developerConnection.set("scm:git:ssh://[email protected]/measure-sh/measure.git")
}
}
}

Expand Down

0 comments on commit 59833a0

Please sign in to comment.