Skip to content

Commit

Permalink
Fix maven publish
Browse files Browse the repository at this point in the history
  • Loading branch information
wsargent committed Jun 21, 2021
1 parent ce64911 commit 0360031
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 84 deletions.
65 changes: 61 additions & 4 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,75 @@ To format everything using [Spotless](https://github.com/diffplug/spotless/tree/
./gradlew spotlessApply
```

Releases are handled using [shipkit](https://github.com/mockito/shipkit):
First, try publishing to maven local:

```bash
./gradlew testRelease
./gradlew publishToMavenLocal
```

And then to run the release, which will increment the version number in `version.properties`:
If that works, then publish to Sonatype's staging repository and close:

```bash
./gradlew performRelease
./gradlew publishToSonatype closeSonatypeStagingRepository
```

Inspect this in Sonatype OHSSH repository. Delete the staging repository after inspection.

And then to promote it:

```bash
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
```

If it looks weird that you have to specify "publishToSonatype" with another task, that's because [it is weird](https://github.com/gradle-nexus/publish-plugin/issues/19).

## Gradle Signing

If you run into errors with signing doing a `publishToSonaType`, this is common and underdocumented.

```
No value has been specified for property 'signatory.keyId'.
```

For the `signatory.keyId` error message, you need to set `signing.gnupg.keyName` if you
are using GPG 2.1 and a Yubikey 4.

https://docs.gradle.org/current/userguide/signing_plugin.html#sec:signatory_credentials
https://github.com/gradle/gradle/pull/1703/files#diff-6c52391bbdceb4cca64ce7b03e78212fR6

Note you need to use `gpg -K` and pick only the LAST EIGHT CHARS of the public signing key.

> signing.gnupg.keyName = 5F798D53
### PinEntry

Also note that if you are using a Yubikey, it'll require you to type in a PIN, which screws up Gradle.

```
gpg: signing failed: No pinentry
```

So you need to use pinentry-mode loopback, which is helpfully supplied by passphrase.

- https://github.com/sbt/sbt-pgp/pull/142
- https://wiki.archlinux.org/index.php/GnuPG#Unattended_passphrase
- https://github.com/gradle/gradle/pull/1703/files#diff-790036df959521791fdafe474b673924

You want this specified only the command line, i.e.

> $ HISTCONTROL=ignoreboth ./gradlew publishToMavenLocal -Psigning.gnupg.passphrase=$PGP_PASSPHRASE --info
### Cannot Allocate Memory

gpg can't be run in parallel. You'll get this error message.

```
gpg: signing failed: Cannot allocate memory
```
[Gradle is not smart enough to disable this](https://github.com/gradle/gradle/issues/12167).

Do not use `-Porg.gradle.parallel=false` and don't use `--parallel` when publishing.

## Documentation

Documentation is done with [gradle-mkdocs-plugin](https://xvik.github.io/gradle-mkdocs-plugin/2.1.1/) and works best on Linux.
Expand Down
9 changes: 7 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@
*/
plugins {
id 'java'
id "org.shipkit.java" version "2.2.6"
id "com.github.hierynomus.license" version "0.15.0"
id 'com.diffplug.gradle.spotless' version '3.24.3'
id 'ru.vyarus.mkdocs' version '2.1.1'
id "io.github.gradle-nexus.publish-plugin" version "1.1.0"
id "org.shipkit.shipkit-auto-version" version "1.1.19"
//id 'org.inferred.processors' version '2.3.0'
}

apply from: "gradle/release.gradle"

mkdocs {
sourcesDir = projectDir
strict = true
Expand All @@ -32,11 +35,13 @@ spotless {

allprojects {
repositories {
jcenter()
mavenCentral()
}
}

// Root project shouldn't publish
tasks.withType(PublishToMavenRepository).configureEach { it.enabled = false }

subprojects { subproj ->
apply plugin: 'java'
apply plugin: 'com.diffplug.gradle.spotless'
Expand Down
23 changes: 0 additions & 23 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@
# http://creativecommons.org/publicdomain/zero/1.0/
#

version = 0.0.0
group = com.tersesystems.logback
artifactIdMaven = logback-core

org.gradle.parallel=true
org.gradle.caching=true

# Set to true to attach a debugger
Expand All @@ -22,26 +19,6 @@ org.gradle.debug=false
# Set the memory size of the daemon to be higher because animalsniffer needs it.
#org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# For the `signatory.keyId` error message, you need to set `signing.gnupg.keyName` if you
# are using GPG 2.1 and a Yubikey 4.
#
# https://docs.gradle.org/current/userguide/signing_plugin.html#sec:signatory_credentials
# https://github.com/gradle/gradle/pull/1703/files#diff-6c52391bbdceb4cca64ce7b03e78212fR6
#
# Note you need to use `gpg -K` and pick only the LAST EIGHT CHARS of the public signing key.
#signing.gnupg.keyName = D66D1D69

# Also note that if you are using a Yubikey, it'll require you to type in a PIN, which screws up Gradle.
# So you need to use pinentry-mode loopback, which is helpfully supplied by passphrase.
#
# https://github.com/sbt/sbt-pgp/pull/142
# https://wiki.archlinux.org/index.php/GnuPG#Unattended_passphrase
# https://github.com/gradle/gradle/pull/1703/files#diff-790036df959521791fdafe474b673924
#
# You want this specified only the command line, i.e.
# $ HISTCONTROL=ignoreboth ./gradlew clean sign -Psigning.gnupg.passphrase=123456 --info
# signing.gnupg.passphrase = [CENSORED]

bytebuddyVersion = 1.10.8
junitVersion = 4.12
junitJupiterVersion = 5.0.1
Expand Down
19 changes: 0 additions & 19 deletions gradle/release.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
//Plugin jars are added to the buildscript classpath in the root build.gradle file
apply plugin: "org.shipkit.shipkit-auto-version"
apply plugin: "org.shipkit.shipkit-changelog"

tasks.named("generateChangelog") {
previousRevision = project.ext.'shipkit-auto-version.previous-tag'
githubToken = System.getenv("GH_WRITE_TOKEN")
repository = "tersesystems/terse-logback"
}

apply plugin: "org.shipkit.shipkit-github-release"
tasks.named("githubRelease") {
dependsOn tasks.named("generateChangelog")
repository = "tersesystems/terse-logback"
changelog = tasks.named("generateChangelog").get().outputFile
githubToken = System.getenv("GH_WRITE_TOKEN")
newTagRevision = System.getenv("GITHUB_SHA")
}

apply plugin: "io.github.gradle-nexus.publish-plugin" //https://github.com/gradle-nexus/publish-plugin/
nexusPublishing {
repositories {
Expand Down
33 changes: 0 additions & 33 deletions gradle/shipkit.gradle

This file was deleted.

2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#

#Fri Mar 06 17:39:40 PST 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
Expand Down
3 changes: 1 addition & 2 deletions version.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@

#Version of the produced binaries. This file is intended to be checked-in.
#It will be automatically bumped by release automation.
version=0.17.0
previousVersion=0.16.2
version=1.0.*

0 comments on commit 0360031

Please sign in to comment.