From ed0c7feeabb09732b865d2c676a190adfe7535cb Mon Sep 17 00:00:00 2001 From: Kez Date: Sun, 20 Jul 2025 01:09:04 +0900 Subject: [PATCH 1/6] Update Gradle wrapper And Add Gradle version catalog with libs.versions.toml --- gradle.properties | 7 ++++++- gradle/libs.versions.toml | 19 +++++++++++++++++++ gradle/wrapper/gradle-wrapper.properties | 2 +- 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 gradle/libs.versions.toml diff --git a/gradle.properties b/gradle.properties index b388c0f..487c1cc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=1.3.0-SNAPSHOT +VERSION_NAME=1.3.0 GROUP=com.squareup.phrase POM_NAME=Phrase @@ -18,3 +18,8 @@ POM_DEVELOPER_ID=square POM_DEVELOPER_NAME=Square, Inc. android.useAndroidX=true + +# Maven Central Publishing +mavenCentralPublishing=true +signAllPublications=true +mavenCentralAutomaticPublishing=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..61a086e --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,19 @@ +[versions] +androidGradlePlugin = "8.7.3" +androidxAnnotation = "1.9.1" +junit = "4.13.2" +festAssert = "2.0M10" +robolectric = "4.15.1" +vanniktech = "0.34.0" + +[libraries] +android-gradle-plugin = { module = "com.android.tools.build:gradle", version.ref = "androidGradlePlugin" } +androidx-annotation = { module = "androidx.annotation:annotation", version.ref = "androidxAnnotation" } +junit = { module = "junit:junit", version.ref = "junit" } +fest-assert = { module = "org.easytesting:fest-assert-core", version.ref = "festAssert" } +robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" } +vanniktech-publish-plugin = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "vanniktech" } + +[plugins] +android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" } +vanniktech-publish = { id = "com.vanniktech.maven.publish", version.ref = "vanniktech" } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d73b5d4..356d510 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Mon Mar 07 13:40:17 NZDT 2022 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME From 1bd4e5afc037b679299282b6e77436369326f0e3 Mon Sep 17 00:00:00 2001 From: Kez Date: Sun, 20 Jul 2025 01:09:20 +0900 Subject: [PATCH 2/6] Convert build.gradle to Kotlin DSL And Add settings.gradle.kts with modern configuration --- build.gradle | 76 ------------------------------------ build.gradle.kts | 52 ++++++++++++++++++++++++ settings.gradle.kts | 17 ++++++++ src/main/AndroidManifest.xml | 3 +- 4 files changed, 70 insertions(+), 78 deletions(-) delete mode 100644 build.gradle create mode 100644 build.gradle.kts create mode 100644 settings.gradle.kts diff --git a/build.gradle b/build.gradle deleted file mode 100644 index a872f23..0000000 --- a/build.gradle +++ /dev/null @@ -1,76 +0,0 @@ -buildscript { - repositories { - google() - mavenCentral() - maven { - url "https://plugins.gradle.org/m2/" - } - } - dependencies { - classpath 'com.android.tools.build:gradle:7.3.0-alpha07' - classpath 'com.vanniktech:gradle-maven-publish-plugin:0.18.0' - } -} -dependencies { - repositories { - google() - mavenCentral() - } -} - -apply plugin: 'com.android.library' -apply plugin: 'com.vanniktech.maven.publish' - -android { - compileSdkVersion 31 - - defaultConfig { - minSdkVersion 11 - versionName VERSION_NAME - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 - } -} - -dependencies { - implementation 'androidx.annotation:annotation:1.3.0' - - testImplementation 'junit:junit:4.13.2' - testImplementation 'org.easytesting:fest-assert-core:2.0M10' - testImplementation 'org.robolectric:robolectric:4.7.3' -} - -apply plugin: 'checkstyle' -checkstyle { - configFile file('checkstyle.xml') - ignoreFailures true - showViolations false - configProperties = [ - 'checkstyle.suppressions.file': file('checkstyle-suppressions.xml'), - ] -} - -// Applying the checkstyle plugin adds multiple tasks but not -// one for checkstylin' against android sources. This task -// belows does the trick. -task checkstyle(type: Checkstyle) { - configFile file('checkstyle.xml') - source 'src/main/java' - ignoreFailures false - showViolations true - include '**/*.java' - exclude '**/gen/**' - - classpath = files() -} - -allprojects { - plugins.withId("com.vanniktech.maven.publish") { - mavenPublish { - sonatypeHost = "S01" - } - } -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..9b5d43b --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,52 @@ +plugins { + alias(libs.plugins.android.library) + alias(libs.plugins.vanniktech.publish) + checkstyle +} + +android { + namespace = "com.squareup.phrase" + compileSdk = 35 + + defaultConfig { + minSdk = 11 + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } +} + +dependencies { + implementation(libs.androidx.annotation) + + testImplementation(libs.junit) + testImplementation(libs.fest.assert) + testImplementation(libs.robolectric) +} + +checkstyle { + configFile = file("checkstyle.xml") + isIgnoreFailures = true + isShowViolations = false + configProperties = mapOf( + "checkstyle.suppressions.file" to file("checkstyle-suppressions.xml") + ) +} + +tasks.register("checkstyle") { + configFile = file("checkstyle.xml") + source("src/main/java") + isIgnoreFailures = false + isShowViolations = true + include("**/*.java") + exclude("**/gen/**") + classpath = files() +} + +tasks.register("printVersion") { + doLast { + println(project.property("VERSION_NAME")) + } +} diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..c27953f --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,17 @@ +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } +} + +rootProject.name = "phrase" \ No newline at end of file diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index 51b8502..1623e4b 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -1,4 +1,3 @@ - + From 2ab26d2c79e00c952f7d80b506b2460e9fe7ce74 Mon Sep 17 00:00:00 2001 From: Kez Date: Sun, 20 Jul 2025 01:10:00 +0900 Subject: [PATCH 3/6] Configure Maven Central publishing in workflow --- .github/workflows/android.yml | 18 +++++++--- .github/workflows/publish-release.yml | 43 ++++++++++++++++++++++++ .github/workflows/publish-snapshot.yml | 46 ++++++++++++++++++++++++++ CHANGELOG.md | 12 +++++++ 4 files changed, 114 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/publish-release.yml create mode 100644 .github/workflows/publish-snapshot.yml diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 3ca4a8d..fb6e8e6 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -1,4 +1,4 @@ -name: Android CI +name: CI on: push: @@ -9,12 +9,14 @@ on: jobs: build: runs-on: ubuntu-latest + timeout-minutes: 30 steps: - - uses: actions/checkout@v3 - - uses: gradle/wrapper-validation-action@v1.0.4 - - name: set up JDK - uses: actions/setup-java@v2 + - uses: actions/checkout@v4 + - uses: gradle/wrapper-validation-action@v2 + + - name: Set up JDK 11 + uses: actions/setup-java@v4 with: java-version: 11 distribution: 'zulu' @@ -22,3 +24,9 @@ jobs: - name: Build with Gradle run: ./gradlew build + + - name: Run tests + run: ./gradlew test + + - name: Run lint + run: ./gradlew lint diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 0000000..4a7784c --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -0,0 +1,43 @@ +name: Publish Release + +on: + workflow_dispatch: + +jobs: + publish-release: + runs-on: ubuntu-latest + if: github.repository == 'square/phrase' + timeout-minutes: 30 + + steps: + - uses: actions/checkout@v4 + - uses: gradle/wrapper-validation-action@v2 + + - name: Set up JDK 11 + uses: actions/setup-java@v4 + with: + java-version: 11 + distribution: 'zulu' + cache: gradle + + - name: Ensure this isn't a -SNAPSHOT version + run: | + VERSION=$(./gradlew -q printVersion) + if [[ $VERSION == *"-SNAPSHOT" ]]; then + echo "Cannot publish a SNAPSHOT version ($VERSION) as a release" + exit 1 + fi + + - name: Assemble + run: ./gradlew assemble + + - name: Check + run: ./gradlew check + + - name: Publish Release + run: ./gradlew publishToMavenCentral + env: + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_CENTRAL_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_CENTRAL_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_SECRET_KEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_SECRET_PASSPHRASE }} \ No newline at end of file diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml new file mode 100644 index 0000000..f63b272 --- /dev/null +++ b/.github/workflows/publish-snapshot.yml @@ -0,0 +1,46 @@ +name: Publish Snapshot + +on: + workflow_dispatch: + push: + branches: + - master + +jobs: + publish-snapshot: + runs-on: ubuntu-latest + if: github.repository == 'square/phrase' + timeout-minutes: 30 + + steps: + - uses: actions/checkout@v4 + - uses: gradle/wrapper-validation-action@v2 + + - name: Set up JDK 11 + uses: actions/setup-java@v4 + with: + java-version: 11 + distribution: 'zulu' + cache: gradle + + - name: Check for -SNAPSHOT version + run: | + VERSION=$(./gradlew -q printVersion) + if [[ $VERSION != *"-SNAPSHOT" ]]; then + echo "Version must end with -SNAPSHOT for snapshot publishing ($VERSION)" + exit 1 + fi + + - name: Assemble + run: ./gradlew assemble + + - name: Check + run: ./gradlew check + + - name: Publish Snapshots + run: ./gradlew publishToMavenCentral + env: + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_CENTRAL_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_CENTRAL_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_SECRET_KEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_SECRET_PASSPHRASE }} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 09b1d33..bf76b59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,18 @@ Change Log ========== +## Version 1.3.0 + +_2025-07-20_ + + * **Breaking Change**: Migrate to Sonatype Central Portal for Maven publishing. + * Modernize Gradle build system with Kotlin DSL and version catalogs. + * Update to Android Gradle Plugin 8.7.3 and Gradle 8.10. + * Update all dependencies to latest versions. + * Add GitHub Actions workflows for automated CI/CD and Maven Central publishing. + * Simplify build configuration using gradle.properties for Maven Central settings. + * In-development snapshots are now published to the Central Portal Snapshots repository at https://central.sonatype.com/repository/maven-snapshots/. + ## Version 1.2.0 _2022-04-06_ From 205d2afe262573e9dc33d6295e316f3bbc43ffab Mon Sep 17 00:00:00 2001 From: Kez Date: Sun, 20 Jul 2025 01:14:58 +0900 Subject: [PATCH 4/6] Fix checkstyle Error --- build.gradle.kts | 3 --- checkstyle.xml | 9 ++++++--- gradle/libs.versions.toml | 2 -- src/main/java/com/squareup/phrase/Phrase.java | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 9b5d43b..ae509ce 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -30,9 +30,6 @@ checkstyle { configFile = file("checkstyle.xml") isIgnoreFailures = true isShowViolations = false - configProperties = mapOf( - "checkstyle.suppressions.file" to file("checkstyle-suppressions.xml") - ) } tasks.register("checkstyle") { diff --git a/checkstyle.xml b/checkstyle.xml index 3ea5e2e..3e09169 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -16,6 +16,11 @@ + + + + + @@ -50,9 +55,7 @@ - - - + diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 61a086e..3a57b4c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -7,12 +7,10 @@ robolectric = "4.15.1" vanniktech = "0.34.0" [libraries] -android-gradle-plugin = { module = "com.android.tools.build:gradle", version.ref = "androidGradlePlugin" } androidx-annotation = { module = "androidx.annotation:annotation", version.ref = "androidxAnnotation" } junit = { module = "junit:junit", version.ref = "junit" } fest-assert = { module = "org.easytesting:fest-assert-core", version.ref = "festAssert" } robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" } -vanniktech-publish-plugin = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "vanniktech" } [plugins] android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" } diff --git a/src/main/java/com/squareup/phrase/Phrase.java b/src/main/java/com/squareup/phrase/Phrase.java index 7f7580e..755208c 100644 --- a/src/main/java/com/squareup/phrase/Phrase.java +++ b/src/main/java/com/squareup/phrase/Phrase.java @@ -215,7 +215,7 @@ public CharSequence format() { return formatted; } - /** "Formats and sets as text in textView." */ + /** Formats and sets as text in textView. */ public void into(TextView textView) { if (textView == null) { throw new IllegalArgumentException("TextView must not be null."); From d59fab4a44331fc772ab49320553845312dcbe12 Mon Sep 17 00:00:00 2001 From: Kez Date: Sun, 20 Jul 2025 01:29:36 +0900 Subject: [PATCH 5/6] rollback version update --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 487c1cc..67909cc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=1.3.0 +VERSION_NAME=1.3.0-SNAPSHOT GROUP=com.squareup.phrase POM_NAME=Phrase From 140667d9526cd4c8d9be2ff15e3836b9f9c6b2a3 Mon Sep 17 00:00:00 2001 From: Kez Date: Sun, 20 Jul 2025 01:30:21 +0900 Subject: [PATCH 6/6] rollback Android CI Name --- .github/workflows/android.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index fb6e8e6..f0f369c 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -1,4 +1,4 @@ -name: CI +name: Android CI on: push: