diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d2cdf21..47160e0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,7 @@ name: Build Example on: [ push, workflow_dispatch ] jobs: - publish: + build: runs-on: ubuntu-latest steps: # Checkout repository diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b823496..26f456e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,4 +1,4 @@ -name: Publish Plugin to Portal +name: Publish to Maven Central on: push: @@ -7,15 +7,18 @@ on: - 'v[0-9]+.[0-9]+.[0-9]+' jobs: - gradle: + publish: runs-on: ubuntu-latest - env: - GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PLUGIN_PORTAL_PUBLISH_KEY }} - GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PLUGIN_PORTAL_PUBLISH_SECRET }} steps: - - name: Checkout Repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v1 + with: + java-version: '17' - name: Grant permission to execute run: chmod +x gradlew - - name: Publish on Plugin Portal - run: ./gradlew --project-dir preset setupPluginUploadFromEnvironment publishPlugins -PgithubRefName=${{ github.ref_name }} + - name: Upload + run: | + echo "${{secrets.MAVEN_SIGNING_KEY_ARMOR_ASC}}" > ./signingkey.asc + gpg --quiet --output $GITHUB_WORKSPACE/signingkey.gpg --dearmor ./signingkey.asc + ./gradlew :preset:plugin:publishAndReleaseToMavenCentral -Psigning.secretKeyRingFile=$GITHUB_WORKSPACE/signingkey.gpg -Psigning.password='${{secrets.MAVEN_SIGNING_KEY_PASSPHRASE}}' -Psigning.keyId=${{secrets.MAVEN_SIGNING_KEY_ID}} -PmavenCentralUsername=${{secrets.MAVEN_CENTRAL_USERNAME}} -PmavenCentralPassword=${{secrets.MAVEN_CENTRAL_PASSWORD}} -PgithubRefName=${{ github.ref_name }} diff --git a/appexample/build.gradle.kts b/appexample/build.gradle.kts index 35baa9c..484871b 100644 --- a/appexample/build.gradle.kts +++ b/appexample/build.gradle.kts @@ -16,7 +16,7 @@ android { minSdk = 26 targetSdk = 34 versionCode = 1 - versionName = "0.0.1" + versionName = project.version.toString() testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner" } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 1a66ed8..4271038 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,12 +1,8 @@ [versions] +agp = "8.6.1" kotlin = "2.0.20" pluginPublish = "1.2.2" -coroutines = "1.8.1" -okhttp = "4.12.0" -retrofit = "2.11.0" -moshi = "1.15.1" -agp = "8.6.1" -jfrog-artifactory = "5.1.10" +vanniktech = "0.29.0" androidx-appcompat = "1.7.0" androidx-lifecycle = "2.8.6" @@ -16,20 +12,13 @@ kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin"} pluginPublish = { id = "com.gradle.plugin-publish", version.ref = "pluginPublish"} androidApplication = { id = "com.android.application", version.ref = "agp" } kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } -jfrog-artifactory = { id = "com.jfrog.artifactory", version.ref = "jfrog-artifactory" } +vanniktech = { id = "com.vanniktech.maven.publish", version.ref = "vanniktech" } [libraries] -junit = "junit:junit:4.13.2" - -coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" } -okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp"} -retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit"} -retrofitConverterScalars = { module = "com.squareup.retrofit2:converter-scalars", version.ref = "retrofit"} -moshi = { module = "com.squareup.moshi:moshi", version.ref = "moshi"} -moshiKotlin = { module = "com.squareup.moshi:moshi-kotlin", version.ref = "moshi"} -moshiAdapters = { module = "com.squareup.moshi:moshi-adapters", version.ref = "moshi"} agp = { module = "com.android.tools.build:gradle", version.ref = "agp"} +kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin"} androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" } androidx-lifecycle-viewmodelKtx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "androidx-lifecycle" } -kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin"} + +junit = "junit:junit:4.13.2" diff --git a/preset/build.gradle.kts b/preset/build.gradle.kts index 9d8f7da..6377f35 100644 --- a/preset/build.gradle.kts +++ b/preset/build.gradle.kts @@ -1,7 +1,6 @@ plugins { alias(libs.plugins.kotlin) apply false alias(libs.plugins.pluginPublish) apply false - alias(libs.plugins.jfrog.artifactory) apply false } allprojects { diff --git a/preset/gradle.properties b/preset/gradle.properties index 7bf809f..c4bf32a 100644 --- a/preset/gradle.properties +++ b/preset/gradle.properties @@ -3,8 +3,29 @@ GROUP=ch.ubique.gradle ARTIFACT_ID=preset # VERSION will only be used if no property "githubRefName" is set (which the release workflow does) VERSION=0.0.0 -DISPLAY_NAME=Ubique Preset -DESCRIPTION=Provides default Gradle configurations and utility methods for Android app projects. -WEBSITE=https://github.com/UbiqueInnovation/gradle-plugin-ubique-preset-android -VCS_URL=https://github.com/UbiqueInnovation/gradle-plugin-ubique-preset-android IMPLEMENTATION_CLASS=ch.ubique.gradle.preset.PresetPlugin + +# POM metadata +POM_NAME=preset +POM_PACKAGING=jar +POM_DESCRIPTION=Provides default Gradle configurations and utility methods for Android app projects. +POM_INCEPTION_YEAR=2024 + +# POM URLs +POM_URL=https://github.com/UbiqueInnovation/gradle-plugin-ubique-preset-android +POM_SCM_URL=https://github.com/UbiqueInnovation/gradle-plugin-ubique-preset-android +POM_SCM_CONNECTION=scm:git@github.com:UbiqueInnovation/gradle-plugin-ubique-preset-android.git +POM_SCM_DEV_CONNECTION=scm:git@github.com:UbiqueInnovation/gradle-plugin-ubique-preset-android.git + +# License information +POM_LICENCE_NAME=License +POM_LICENCE_URL=https://github.com/UbiqueInnovation/gradle-plugin-ubique-preset-android/blob/main/LICENSE +POM_LICENCE_DIST=repo + +# Developer information +POM_DEVELOPER_ID=UbiqueInnovation +POM_DEVELOPER_NAME=Ubique Innovation +POM_DEVELOPER_URL=https://www.ubique.ch/ + +# Sonatype metadata +SONATYPE_STAGING_PROFILE=ch.ubique diff --git a/preset/plugin/build.gradle.kts b/preset/plugin/build.gradle.kts index 3ebb859..01d7070 100644 --- a/preset/plugin/build.gradle.kts +++ b/preset/plugin/build.gradle.kts @@ -1,64 +1,48 @@ +import com.vanniktech.maven.publish.GradlePublishPlugin +import com.vanniktech.maven.publish.SonatypeHost import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { - kotlin("jvm") - `java-gradle-plugin` - alias(libs.plugins.pluginPublish) - alias(libs.plugins.jfrog.artifactory) + kotlin("jvm") + `java-gradle-plugin` + alias(libs.plugins.pluginPublish) + alias(libs.plugins.vanniktech) } dependencies { - implementation(kotlin("stdlib")) - implementation(gradleApi()) + implementation(kotlin("stdlib")) + implementation(gradleApi()) - implementation(libs.agp) - implementation(libs.kotlin.gradle) + implementation(libs.agp) + implementation(libs.kotlin.gradle) - implementation(libs.coroutines) - implementation(libs.okhttp) - implementation(libs.retrofit) - implementation(libs.retrofitConverterScalars) - implementation(libs.moshi) - implementation(libs.moshiKotlin) - implementation(libs.moshiAdapters) - - testImplementation(libs.junit) + testImplementation(libs.junit) } java { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } tasks.withType { - compilerOptions.jvmTarget = JvmTarget.JVM_17 - kotlinOptions.jvmTarget = JavaVersion.VERSION_17.toString() + compilerOptions.jvmTarget = JvmTarget.JVM_17 + kotlinOptions.jvmTarget = JavaVersion.VERSION_17.toString() } gradlePlugin { - plugins { - create(property("ID").toString()) { - id = property("ID").toString() - implementationClass = property("IMPLEMENTATION_CLASS").toString() - version = project.version - description = property("DESCRIPTION").toString() - displayName = property("DISPLAY_NAME").toString() - tags = listOf("android", "ubique") - } - } - website.set(property("WEBSITE").toString()) - vcsUrl.set(property("VCS_URL").toString()) + plugins { + create(property("ID").toString()) { + id = property("ID").toString() + implementationClass = property("IMPLEMENTATION_CLASS").toString() + version = project.version + } + } } -tasks.create("setupPluginUploadFromEnvironment") { - doLast { - val key = System.getenv("GRADLE_PUBLISH_KEY") - val secret = System.getenv("GRADLE_PUBLISH_SECRET") - if (key == null || secret == null) { - throw GradleException("GRADLE_PUBLISH_KEY and/or GRADLE_PUBLISH_SECRET are not defined environment variables") - } - System.setProperty("gradle.publish.key", key) - System.setProperty("gradle.publish.secret", secret) - } +mavenPublishing { + configure(GradlePublishPlugin()) + coordinates(property("GROUP").toString(), property("ARTIFACT_ID").toString(), project.version.toString()) + publishToMavenCentral(SonatypeHost.S01, true) + signAllPublications() } diff --git a/settings.gradle.kts b/settings.gradle.kts index 2213573..6e6f1f0 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -16,5 +16,7 @@ dependencyResolutionManagement { } } +rootProject.name = "gradle-plugin-preset-android" + include("appexample") includeBuild("preset")