From 3b28ad7a0755e24c812c1c33c1107485910b4da6 Mon Sep 17 00:00:00 2001 From: Rob Greene Date: Wed, 7 Mar 2018 19:59:46 -0600 Subject: [PATCH] Adding Gradle config to publish to the Maven Central Repository. --- .gitignore | 1 + MAVEN-REPO.md | 57 +++++++++++++++++++++++++++++++++++++++++++ README.md | 3 +++ build.gradle | 61 +++++++++++++++++++++++++++++++++++++++++++++++ gradle.properties | 8 +++++++ 5 files changed, 130 insertions(+) create mode 100644 MAVEN-REPO.md create mode 100644 gradle.properties diff --git a/.gitignore b/.gitignore index ddd9ae2..366ab31 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ build/ .settings/ .classpath .project +bin/ diff --git a/MAVEN-REPO.md b/MAVEN-REPO.md new file mode 100644 index 0000000..3e13994 --- /dev/null +++ b/MAVEN-REPO.md @@ -0,0 +1,57 @@ +# Releasing to the Maven Central Repository + +## GPG Keys + +Summary of commands for GPG2 keys preparation... + +Generate key: + +```bash +$ gpg2 --gen-key +``` + +Publish key on public key server: + +```bash +$ gpg2 --list-keys +$ gpg2 --list-secret-keys +$ gpg2 --keyserver hkp://pool.sks-keyservers.net --send-keys +``` + +Extract secret key for the Gradle signing plugin: + +```bash +$ gpg2 --export-secret-keys > secring.gpg +``` + +## Build and publish to Central Repository + +Ensure full build passes: + +```bash +$ ./gradlew clean test javadoc assemble +<...lots of stuff, primarily Javadoc issues...> +BUILD SUCCESSFUL in 3s +13 actionable tasks: 13 executed +``` + +Upload: + +```bash +$ ./gradlew uploadArchives + +BUILD SUCCESSFUL in 10s +10 actionable tasks: 1 executed, 9 up-to-date +``` + +Then follow "releasing the deployment" below. + +## Tag and publish on GitHub + +Just a reminder! + +# References + +* http://central.sonatype.org/pages/gradle.html +* http://central.sonatype.org/pages/releasing-the-deployment.html +* For all the other little pieces, Google is your friend. ;-) diff --git a/README.md b/README.md index f093167..823d1a2 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,6 @@ This project is a direct off-shoot of the AppleCommander project and implements a pure Java API to manipulate ShrinkIt (NuFX) archives ([Apple File Type Note $E0/8002](http://www.apple2online.com/web_documents/ft_e0.8002_shrinkit.pdf)). +*Developers* + +Being new to Gradle, all of the Maven release components are in the `build.gradle` file. More a warning than anything, just in case it causes issues. Please make more portable and submit a PR. diff --git a/build.gradle b/build.gradle index 9b98e7e..be00ab4 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,7 @@ apply plugin: 'java' apply plugin: 'application' +apply plugin: 'maven' +apply plugin: 'signing' repositories { jcenter() @@ -18,3 +20,62 @@ jar { ) } } + +task javadocJar(type: Jar) { + classifier = 'javadoc' + from javadoc +} + +task sourcesJar(type: Jar) { + classifier = 'sources' + from sourceSets.main.allSource +} + +artifacts { + archives javadocJar, sourcesJar +} + +signing { + sign configurations.archives +} + +uploadArchives { + repositories { + mavenDeployer { + beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } + + repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { + authentication(userName: ossrhUsername, password: ossrhPassword) + } + + snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { + authentication(userName: ossrhUsername, password: ossrhPassword) + } + + pom.project { + name archivesBaseName + packaging 'jar' + description 'A Java library for managing Apple II ShrinkIt archives.' + url 'https://applecommander.github.io/' + + scm { + url 'https://github.com/AppleCommander/ShrinkItArchive' + } + + licenses { + license { + name 'The GNU General Public License (GPL) Version 2, June 1991' + url 'https://www.gnu.org/licenses/gpl-2.0.html' + } + } + + developers { + developer { + id 'robgreene' + email 'robgreene@gmail.com' + } + } + } + } + } +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..d8b6c78 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,8 @@ +# Universal ShrinkItArchive version number. Used for: +# - Naming JAR file. +# - The build will insert this into a file that is read at run time as well. +version=1.1.0 + +# Maven Central Repository G and A of GAV coordinate. :-) +group=net.sf.applecommander +archivesBaseName=AppleCommander