Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,24 @@ 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'
cache: gradle

- name: Build with Gradle
run: ./gradlew build

- name: Run tests
run: ./gradlew test

- name: Run lint
run: ./gradlew lint
43 changes: 43 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
46 changes: 46 additions & 0 deletions .github/workflows/publish-snapshot.yml
Original file line number Diff line number Diff line change
@@ -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 }}
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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_
Expand Down
76 changes: 0 additions & 76 deletions build.gradle

This file was deleted.

49 changes: 49 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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
}

tasks.register<Checkstyle>("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"))
}
}
9 changes: 6 additions & 3 deletions checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
<property name="message" value="Line has trailing spaces."/>
</module>

<!-- Line length check -->
<module name="LineLength">
<property name="max" value="120"/>
</module>

<module name="TreeWalker">
<!--<property name="cacheFile" value="${checkstyle.cache.file}"/>-->

Expand Down Expand Up @@ -50,9 +55,7 @@

<!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sf.net/config_sizes.html -->
<module name="LineLength">
<property name="max" value="120"/>
</module>
<!-- LineLength moved outside TreeWalker -->
<module name="MethodLength"/>
<module name="ParameterNumber"/>

Expand Down
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 17 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[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]
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" }

[plugins]
android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" }
vanniktech-publish = { id = "com.vanniktech.maven.publish", version.ref = "vanniktech" }
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}

rootProject.name = "phrase"
3 changes: 1 addition & 2 deletions src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.squareup.phrase">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application/>
</manifest>
2 changes: 1 addition & 1 deletion src/main/java/com/squareup/phrase/Phrase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down