uploadArchives breaks jar created with shadowJar

I’m trying to build an uberjar (as I was in this question: Building an uberjar with bouncycastle). this time I’ve decided to try johnrengelman/shadow to create the uberjar.

Everything goes as planned, and I have a working uberjar in build/libs/MyProject-version.jar after running gradle shadowJar.

Unfortunately, if I run gradle shadowJar uploadArchives, then the build/libs/MyProject-version.jar jar gives the following error when run:

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/bouncycastle/openpgp/PGPException

I get the same error if I download the freshly uploaded jar from our internal nexus (I’m assuming the same jar that was in build/libs/ was uploaded.

Am I misusing this plugin? Should I not be using uploadArchives to upload jars to nexus? I’m guessing changing the jar isn’t what uploadArchives is supposed to be doing. Here’s some of my config:

plugins {
  id 'java'
  id 'maven'
  id 'application'
  id 'com.github.johnrengelman.shadow' version '1.2.2'

// I don't want zip and tar files
distTar.enabled = false
distZip.enabled = false
// thanks: https://stackoverflow.com/questions/33774782/upload-only-war-jar-files-in-gradlerestrict-zip-tar-generation-and-upload/33931333#33931333
[distZip, distTar].each { task -> configurations.archives.artifacts.removeAll
  { it.class.simpleName == "ArchivePublishArtifact" && it.archiveTask == task }
  task.enabled = false

mainClassName = 'my.Main'

jar {
  manifest {
    // mainClassName wasn't being picked up by itself (I think the application plugin's supposed to see it), but seems to work if I specify it explicitly in the manifest here
    attributes("Main-Class": mainClassName)

shadowJar {
  // don't make project-version-all.jar, instead make project-version.jar
  classifier = ''

// this block doesn't make a difference (I've tried it with and without this block)
artifacts {
  archives shadowJar

uploadArchives {
  repositories.mavenDeployer {
    repository(url: 'http://internal.nexus.goes.here/repo/') {
      authentication(userName: 'user', password: 'pass')

    snapshotRepository(url: 'http://internal.nexus.goes.here/repo-snapshot/') {
      authentication(userName: 'user', password: 'pass')

    // not sure if this should be in the snapshotRepository or not. putting it there doesn't seem to make a difference, at least for this issue
    uniqueVersion = false
    pom.groupId = 'my.group'