From d488113b84ace6538872afa7248b06f42a88d734 Mon Sep 17 00:00:00 2001 From: Rob Greene Date: Sat, 26 May 2018 18:07:56 -0500 Subject: [PATCH] Adding information for pushing to Maven Central as well as using the api. --- api/MAVEN-REPO.md | 59 +++++++++++++++++++++++++++++++++++++++++++++++ api/README.md | 22 ++++++++++++++++++ api/build.gradle | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 140 insertions(+) create mode 100644 api/MAVEN-REPO.md diff --git a/api/MAVEN-REPO.md b/api/MAVEN-REPO.md new file mode 100644 index 0000000..f451168 --- /dev/null +++ b/api/MAVEN-REPO.md @@ -0,0 +1,59 @@ +# 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 + +> Note that all of this can be run from the main 'applesingle' folder. + +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/api/README.md b/api/README.md index cbdd5ea..606c7a2 100644 --- a/api/README.md +++ b/api/README.md @@ -2,6 +2,28 @@ Usage is catered to the factory methods and builder. Some sample are included below. +## Maven / Gradle + +To include in a Maven project: + +```xml + + net.sf.applecommander + applesingle + 1.0.0 + +``` + +To include in a Gradle project: + +```groovy +dependencies { + // ... + compile "net.sf.applecommander:applesingle:1.0.0" + // ... +} +``` + ## Read AppleSingle Use the factory method to... diff --git a/api/build.gradle b/api/build.gradle index a05f9be..5dfb075 100644 --- a/api/build.gradle +++ b/api/build.gradle @@ -9,3 +9,62 @@ apply plugin: 'signing' dependencies { testImplementation 'junit:junit:4.12' } + +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: findProperty('ossrhUsername'), password: findProperty('ossrhPassword')) + } + + snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { + authentication(userName: findProperty('ossrhUsername'), password: findProperty('ossrhPassword')) + } + + pom.project { + name archivesBaseName + packaging 'jar' + description 'A Java library for managing AppleSingle files.' + url 'https://applecommander.github.io/' + + scm { + url 'https://github.com/AppleCommander/applesingle' + } + + licenses { + license { + name 'The GNU General Public License (GPL) Version 3, 29 June 2007' + url 'https://www.gnu.org/licenses/gpl-3.0.html' + } + } + + developers { + developer { + id 'robgreene' + email 'robgreene@gmail.com' + } + } + } + } + } +}