Skip to content

Commit

Permalink
[wpeview] Use 3rdparty plugin to simplify publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
zhani committed Oct 8, 2024
1 parent 55a1cfe commit 3ed7711
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 74 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/publish-to-maven-central.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Build and publish
run: ./gradlew wpeview:publishReleasePublicationToOSSRHRepository
env:
OSSRH_USERNAME: ${{ secrets.CENTRAL_TOKEN_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.CENTRAL_TOKEN_PASSWORD }}
SIGNING_KEY: ${{ secrets.PGP_CENTRAL_SIGNING_KEY }}
SIGNING_PASSWORD: ${{ secrets.PGP_CENTRAL_SIGNING_KEY_PASSPHRASE }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.CENTRAL_TOKEN_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.CENTRAL_TOKEN_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.PGP_CENTRAL_SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.PGP_CENTRAL_SIGNING_KEY_PASSPHRASE }}
92 changes: 22 additions & 70 deletions wpeview/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import com.vanniktech.maven.publish.AndroidSingleVariantLibrary
import com.vanniktech.maven.publish.SonatypeHost

plugins {
id 'com.android.library'
id 'maven-publish'
id 'signing'
id "com.vanniktech.maven.publish" version "0.29.0"
}

android {
Expand Down Expand Up @@ -90,14 +92,6 @@ android {
})
}
}

publishing {
singleVariant('release') {
// This ensures only the release variant is published
withSourcesJar() // Include sources JAR
withJavadocJar() // Include Javadoc JAR (optional)
}
}
}

dependencies {
Expand All @@ -107,76 +101,34 @@ dependencies {
androidTestImplementation "androidx.test.ext:junit:1.2.1"
}

publishing {
publications {
release(MavenPublication) {
afterEvaluate {
from components.release
}

groupId 'org.wpewebkit.wpeview'
artifactId 'wpeview'
version '0.1.0'

// The sources and Javadoc JARs are automatically added because of `withSourcesJar()` and `withJavadocJar()` above
mavenPublishing {
configure(new AndroidSingleVariantLibrary("release", true, true))

pom {
name = 'WPEView'
description = 'WPE WebKit for Android'
url = 'https://github.com/Igalia/wpe-android'
coordinates("org.wpewebkit.wpeview", "wpeview", "0.1.0")

licenses {
license {
name = 'GNU Lesser General Public License v2.1'
url = 'https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt'
distribution = 'repo'
}
}
pom {
name = 'WPEView'
description = 'WPE WebKit for Android'
url = 'https://github.com/Igalia/wpe-android'

scm {
connection = 'scm:[email protected]/Igalia/wpe-android.git'
url = 'https://github.com/Igalia/wpe-android.git'
}
licenses {
license {
name = 'GNU Lesser General Public License v2.1'
url = 'https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt'
distribution = 'repo'
}
}
}

repositories {
maven {
name = "OSSRH"
url = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")

credentials {
username = project.findProperty("ossrhUsername") ?: System.getenv("OSSRH_USERNAME")
password = project.findProperty("ossrhPassword") ?: System.getenv("OSSRH_PASSWORD")
}
scm {
connection = 'scm:[email protected]/Igalia/wpe-android.git'
url = 'https://github.com/Igalia/wpe-android.git'
}
}
}

signing {
def signingKey = project.findProperty("signing.secretKey") ?: System.getenv("SIGNING_KEY")
def signingPassword = project.findProperty("signing.password")?: System.getenv("SIGNING_PASSWORD")

if (signingKey && signingPassword) {
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications
} else {
logger.warn("Signing key or password not found, signing will be skipped.")
}
}

tasks.withType(Javadoc).configureEach {
enabled = false // Disable Javadoc if not needed
}

tasks.register('javadocJar', Jar) {
archiveClassifier.set('javadoc')
}
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)

tasks.register('sourcesJar', Jar) {
from android.sourceSets.main.java.srcDirs
archiveClassifier.set('sources')
// Enable GPG signing for all publications
signAllPublications()
}

gradle.afterProject { project ->
Expand Down

0 comments on commit 3ed7711

Please sign in to comment.