Skip to content
Merged
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
18 changes: 6 additions & 12 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,15 @@ jobs:

- name: Build and test
run: ./gradlew build
- name: Read version
id: version
run: |
VERSION=$(grep '^VERSION_NAME=' gradle.properties | cut -d= -f2)
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT

- name: Publish SNAPSHOT (main only)
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && endsWith(steps.version.outputs.VERSION, 'SNAPSHOT')
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_IN_MEMORY_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
run: ./gradlew publishAllPublicationsToMavenCentralRepository -x test
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: ./gradlew publishAllPublicationsToCentralPortalSnapshots -x test
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The task name publishAllPublicationsToCentralPortalSnapshots used in the CI workflow does not exist. The nmcp plugin configuration only defines publishAllPublicationsToCentralPortal, which is meant for releases. For SNAPSHOT publishing, you should either use the standard Maven publishing task publishAllPublicationsToMavenRepository or configure a separate nmcp task for snapshots. The nmcp plugin's publishAllPublicationsToCentralPortal task is typically used for releases, not snapshots.

Suggested change
run: ./gradlew publishAllPublicationsToCentralPortalSnapshots -x test
run: ./gradlew publishAllPublicationsToMavenRepository -x test

Copilot uses AI. Check for mistakes.

- name: Update dependency graph
uses: gradle/actions/dependency-submission@v5
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/Release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ jobs:
release:
runs-on: ubuntu-latest
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_IN_MEMORY_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

steps:
- uses: actions/checkout@v6
Expand Down Expand Up @@ -46,4 +45,4 @@ jobs:
run: ./gradlew build -Pversion=${{ steps.version.outputs.VERSION }}

- name: Deploy to Maven Central
run: ./gradlew publishAllPublicationsToMavenCentralRepository -Pversion=${{ steps.version.outputs.VERSION }}
run: ./gradlew publishAllPublicationsToCentralPortal -Pversion=${{ steps.version.outputs.VERSION }}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ A lightweight Java SDK for the Apple Maps Server API, with automatic access-toke

## Installation

Replace `0.1.2` with the latest release.
Replace `0.1.3` with the latest release.

Note: this repo’s build uses a Gradle Java toolchain (Java 17). If you don’t have JDK 17 installed locally, Gradle will download it automatically.

### Gradle

```groovy
dependencies {
implementation("com.williamcallahan:apple-maps-java:0.1.2")
implementation("com.williamcallahan:apple-maps-java:0.1.3")
}
```

Expand All @@ -28,7 +28,7 @@ dependencies {
<dependency>
<groupId>com.williamcallahan</groupId>
<artifactId>apple-maps-java</artifactId>
<version>0.1.2</version>
<version>0.1.3</version>
</dependency>
```

Expand Down
75 changes: 67 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ import java.util.Properties
import java.io.FileInputStream

plugins {
id("com.vanniktech.maven.publish") version "0.35.0"
`java-library`
`maven-publish`
signing
id("com.gradleup.nmcp") version "1.2.1"
}

// Load .env file if it exists
Expand Down Expand Up @@ -45,7 +47,7 @@ val javaTargetVersion = 17
group = providers.gradleProperty("GROUP").orNull ?: "com.williamcallahan"
version = providers.gradleProperty("version").orNull
?: providers.gradleProperty("VERSION_NAME").orNull
?: "0.1.2"
?: "0.1.4-SNAPSHOT"

repositories {
mavenCentral()
Expand Down Expand Up @@ -160,12 +162,69 @@ tasks.withType<Javadoc>().configureEach {
(options as StandardJavadocDocletOptions).addStringOption("-release", javaTargetVersion.toString())
}

mavenPublishing {
publishToMavenCentral(automaticRelease = true)
signAllPublications()
publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
artifactId = providers.gradleProperty("POM_ARTIFACT_ID").orNull ?: "apple-maps-java"

pom {
name.set(providers.gradleProperty("POM_NAME").orNull ?: "Apple Maps Java")
description.set(providers.gradleProperty("POM_DESCRIPTION").orNull ?: "Apple Maps Java implements the Apple Maps Server API for use in JVMs.")
url.set(providers.gradleProperty("POM_URL").orNull ?: "https://github.com/WilliamAGH/apple-maps-java")

licenses {
license {
name.set(providers.gradleProperty("POM_LICENSE_NAME").orNull ?: "MIT License")
url.set(providers.gradleProperty("POM_LICENSE_URL").orNull ?: "https://opensource.org/license/mit")
}
}

developers {
developer {
id.set(providers.gradleProperty("POM_DEVELOPER_ID").orNull ?: "WilliamAGH")
name.set(providers.gradleProperty("POM_DEVELOPER_NAME").orNull ?: "William Callahan")
url.set(providers.gradleProperty("POM_DEVELOPER_URL").orNull ?: "https://github.com/WilliamAGH/")
}
}

scm {
url.set(providers.gradleProperty("POM_SCM_URL").orNull ?: "https://github.com/WilliamAGH/apple-maps-java")
connection.set(providers.gradleProperty("POM_SCM_CONNECTION").orNull ?: "scm:git:git://github.com/WilliamAGH/apple-maps-java.git")
developerConnection.set(providers.gradleProperty("POM_SCM_DEV_CONNECTION").orNull ?: "scm:git:ssh://git@github.com/WilliamAGH/apple-maps-java.git")
}
}
}
}

repositories {
maven {
val releasesUrl = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
val snapshotsUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
url = if (version.toString().endsWith("SNAPSHOT")) snapshotsUrl else releasesUrl

credentials {
username = providers.environmentVariable("SONATYPE_USERNAME").orNull
password = providers.environmentVariable("SONATYPE_PASSWORD").orNull
}
}
}
}

signing {
val signingKey = providers.environmentVariable("GPG_PRIVATE_KEY").orNull
val signingPassword = providers.environmentVariable("GPG_PASSPHRASE").orNull

if (signingKey != null && signingPassword != null) {
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications)
}
}

// Fix task dependency issue with Gradle 9.x and vanniktech plugin
tasks.matching { it.name == "generateMetadataFileForMavenPublication" }.configureEach {
dependsOn(tasks.matching { it.name == "plainJavadocJar" })
nmcp {
publishAllPublicationsToCentralPortal {
username.set(providers.environmentVariable("SONATYPE_USERNAME").orNull)
password.set(providers.environmentVariable("SONATYPE_PASSWORD").orNull)
publishingType.set("USER_MANAGED")
}
}
9 changes: 7 additions & 2 deletions docs/authorization.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Option A (recommended): environment variable

```bash
export APPLE_MAPS_TOKEN="your-token"
export APPLE_MAPS_ORIGIN="https://api.example.com" # Required if your JWT has a specific origin
```

Option B (local dev for this repo): `.env` fallback
Expand All @@ -31,7 +32,7 @@ cp .env-example .env
`.env` is ignored by git (so you don’t accidentally commit secrets).

This project’s Gradle build loads `.env` into **system properties**, which is mainly convenient for running tests locally.
In CI, prefer setting `APPLE_MAPS_TOKEN` as an environment variable.
In CI, set `APPLE_MAPS_TOKEN` as an environment variable. Optionally set `APPLE_MAPS_ORIGIN` if your token requires it (e.g., `https://api.example.com` matching your JWT's `origin` claim).

## Supplying the token to the SDK

Expand All @@ -40,9 +41,13 @@ For example:

```java
String token = System.getenv("APPLE_MAPS_TOKEN");
String origin = System.getenv("APPLE_MAPS_ORIGIN");
if (token == null || token.isBlank()) {
token = System.getProperty("APPLE_MAPS_TOKEN");
}
if (origin == null || origin.isBlank()) {
origin = System.getProperty("APPLE_MAPS_ORIGIN");
}

AppleMaps api = new AppleMaps(token);
AppleMaps api = new AppleMaps(token, origin);
```
2 changes: 1 addition & 1 deletion docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This repo includes a small CLI for running Apple Maps Server queries from your t

## Prerequisites

Set `APPLE_MAPS_TOKEN` (env var recommended). See `README.md` / `docs/authorization.md`.
Set `APPLE_MAPS_TOKEN` (env var recommended). Optionally set `APPLE_MAPS_ORIGIN` if your token requires it (e.g. `https://api.example.com` matching your JWT's `origin` claim). See `README.md` / `docs/authorization.md`.

## Run

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GROUP=com.williamcallahan
POM_ARTIFACT_ID=apple-maps-java
VERSION_NAME=0.1.2-SNAPSHOT
VERSION_NAME=0.1.4-SNAPSHOT

POM_NAME=Apple Maps Java
POM_DESCRIPTION=Apple Maps Java implements the Apple Maps Server API for use in JVMs.
Expand Down
Loading
Loading