Building an uberjar with bouncycastle

I’m trying to build 1 executable jar file with all my dependencies. One of my dependencies is bouncycastle. I’ve found multiple solutions, but none have worked for me yet. Here’s what I’ve tried:

Here are my relevant dependencies:

dependencies {
    // ... snip ...
    compile group: 'org.bouncycastle', name: 'bcpg-jdk15on', version: '1.52'
    compile group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.52'
    // ... snip ...
}

With this config:

jar {
    // thanks: https://stackoverflow.com/questions/22911190/gradle-build-dependancy-throwing-classnotfoundexception/23010014#23010014
    from {
        configurations.compile.collect {
            it.isDirectory() ? it : zipTree(it)
        }
    }
    manifest {
        attributes 'Main-Class': 'my.Main'
    }
}

I get the following exception when running the jar:

java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
        at sun.security.util.SignatureFileVerifier.processImpl(Unknown Source)
        at sun.security.util.SignatureFileVerifier.process(Unknown Source)
        at java.util.jar.JarVerifier.processEntry(Unknown Source)
        at java.util.jar.JarVerifier.update(Unknown Source)
        at java.util.jar.JarFile.initializeVerifier(Unknown Source)
        at java.util.jar.JarFile.getInputStream(Unknown Source)
        at sun.misc.URLClassPath$JarLoader$2.getInputStream(Unknown Source)
        at sun.misc.Resource.cachedInputStream(Unknown Source)
        at sun.misc.Resource.getByteBuffer(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Error: A JNI error has occurred, please check your installation and try again

With this config:

jar {
    from {
        configurations.compile.collect {
            it.isDirectory() ? it : zipTree(it)
        }
    }
    exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
    manifest {
        attributes 'Main-Class': 'my.Main'
    }
}

I get a PGPException…

org.bouncycastle.openpgp.PGPException: Exception decrypting key

…with the following underlying exception:

java.lang.SecurityException: JCE cannot authenticate the provider BC

It seems like I’m packaging bouncycastle’s signatures incorrectly, but I’m not sure how I should be doing this when making an uberjar.