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
9 changes: 9 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ jobs:
distribution: 'zulu'
java-version: '17'

- name: Setup Android SDK
uses: android-actions/setup-android@v2

- name: Install Android SDK components
run: |
echo "sdk.dir=$ANDROID_SDK_ROOT" > local.properties
sdkmanager --install "platform-tools" "platforms;android-34" "build-tools;34.0.0"
yes | sdkmanager --licenses

- name: ktlint
run: bash ./ktlint "**/src/**/*.kt" --color

Expand Down
35 changes: 35 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .ops/pitest.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ if (!hasAndroid && project.name != "ext-acorn-android-lint") {
project.apply plugin: "info.solidsoft.pitest"

project.dependencies {
pitest("org.pitest:pitest-junit5-plugin:0.14")
pitest(libs.pitest.junit5)
}

pitest {
targetClasses = ["com.*", "acorn.*"]
pitestVersion = "1.4.9"
pitestVersion = libs.versions.pitest.core.get()
testPlugin = "junit5"
threads = 4
outputFormats = ["XML", "HTML"]
Expand Down
20 changes: 0 additions & 20 deletions .ops/publishing-android.gradle

This file was deleted.

82 changes: 0 additions & 82 deletions .ops/publishing-base.gradle

This file was deleted.

16 changes: 0 additions & 16 deletions .ops/publishing-kotlin.gradle

This file was deleted.

159 changes: 159 additions & 0 deletions .ops/publishing.gradle
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

@copilot I'm getting 404 when I publish

Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
// Shared Maven Central publishing configuration for Acorn
// Applies to subprojects that define `groupId` and `artifactId` in their gradle.properties.

ext.isAndroidLibrary = { project.plugins.hasPlugin("com.android.library") }
ext.isJvmLibrary = { project.plugins.hasPlugin("org.gradle.java-library") || project.plugins.hasPlugin("org.jetbrains.kotlin.jvm") }

// Apply plugins if not already applied
plugins.withId("org.gradle.maven-publish") {}
if (!plugins.hasPlugin("org.gradle.maven-publish")) {
apply plugin: "maven-publish"
}
if (!plugins.hasPlugin("signing")) {
apply plugin: "signing"
}

// Set group and artifact from module gradle.properties
if (project.hasProperty("groupId")) {
group = project.property("groupId")
}

// Ensure sources and javadoc artifacts exist
if (isJvmLibrary()) {
// Ensure Java convention is present to register sources/javadoc jars
plugins.withId("org.gradle.java") {
java {
withSourcesJar()
withJavadocJar()
}
}
plugins.withId("org.gradle.java-library") {
java {
withSourcesJar()
withJavadocJar()
}
}
}

// For Android libraries, use AGP's publishing DSL to configure the release variant with sources
plugins.withId("com.android.library") {
android {
publishing {
singleVariant("release") {
withSourcesJar()
}
}
}

// Provide a minimal javadoc jar to satisfy Maven Central requirements
// This creates an empty javadoc jar, which is acceptable for Android/Kotlin libraries
tasks.register("androidJavadocJar", Jar) {
archiveClassifier.set("javadoc")
}
}

publishing {
publications {
def pub = publications.findByName("maven") as MavenPublication
if (pub == null) {
maven(MavenPublication) {
if (isAndroidLibrary()) {
// Publish the release variant for Android libraries
afterEvaluate {
from components.findByName("release")
}
// Sources are added via AGP publishing DSL (singleVariant + withSourcesJar)
// Provide a minimal javadoc jar as required by Maven Central
artifact tasks.named("androidJavadocJar")
} else {
// JVM libraries
if (components.findByName("java") != null) {
from components.java
}
}

if (project.hasProperty("artifactId")) {
artifactId = project.property("artifactId")
}

pom {
name = "Acorn"
description = "Mastering Android Navigation"
url = "https://github.com/nhaarman/Acorn"

licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution = "repo"
}
}

developers {
developer {
id = "nhaarman"
name = "Niek Haarman"
}
}

scm {
url = "https://github.com/nhaarman/Acorn"
connection = "scm:git:git://github.com/nhaarman/Acorn.git"
developerConnection = "scm:git:ssh://github.com/nhaarman/Acorn.git"
}
}
}
}
}

repositories {
// Prefer Central Publishing Portal if configured; otherwise fall back to OSSRH
def isSnapshot = project.version?.toString()?.endsWith("-SNAPSHOT")
def useCentral = (findProperty("centralPortal")?.toString()?.toBoolean() ?: false)
|| (System.getenv("CENTRAL_PORTAL")?.toBoolean() ?: false)

if (useCentral) {
if (isSnapshot) {
throw new GradleException("Central Publishing Portal does not accept SNAPSHOT versions. Remove -SNAPSHOT or disable centralPortal.")
}
maven {
name = "CentralPortal"
def centralUrl = findProperty("centralPortalUrl") ?: System.getenv("CENTRAL_PORTAL_URL")
if (!centralUrl) {
// Default upload endpoint for Central Portal (token-based)
centralUrl = "https://central.sonatype.com/api/v1/publisher/deploy/maven2"
}
url = uri(centralUrl)
credentials {
username = findProperty("centralPortalUsername") ?: System.getenv("CENTRAL_PORTAL_USERNAME")
password = findProperty("centralPortalPassword") ?: System.getenv("CENTRAL_PORTAL_PASSWORD")
}
}
} else {
// Legacy OSSRH repositories for releases and snapshots
maven {
name = "OSSRH"
def releasesUrl = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
def snapshotsUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
url = isSnapshot ? snapshotsUrl : releasesUrl

credentials {
// Support multiple property names and environment variables
username = findProperty("ossrhUsername") ?: findProperty("mavenCentralUsername")
?: System.getenv("OSSRH_USERNAME") ?: System.getenv("MAVEN_CENTRAL_USERNAME")
password = findProperty("ossrhPassword") ?: findProperty("mavenCentralPassword")
?: System.getenv("OSSRH_PASSWORD") ?: System.getenv("MAVEN_CENTRAL_PASSWORD")
}
}
}
}
}

// Configure signing (only if keys are available)
signing {
if (findProperty("signing.secretKeyRingFile") || findProperty("signing.keyId")) {
sign publishing.publications
} else {
logger.lifecycle("[publishing] Signing is not configured; publications will not be signed.")
}
}
Loading