Closed eli-darkly closed 6 years ago
Do you get an error?
You can run Gradle with the “-i” or “-d” flags to get more information on what it is doing.
I don't get an error with the script shown above; it just doesn't publish any of the signature files.
When I try changing the signing
task to say sign publishing.publications.shadow
(which the docs for signing
seemed to suggest ought to work), I get an error: Could not get unknown property 'shadow' for Publication container of type org.gradle.api.publish.internal.DefaultPublicationContainer.
I did try running Gradle with -i
and -d
but unfortunately didn't get any useful information, except that it was at least executing the signing task. However, I'm now even more puzzled because, while I know for sure that I saw it executing that task yesterday and was seeing signature files generated locally (but not published), this is no longer the case - I haven't changed anything but now I get no signature files.
Again, I have no idea whether this is actually related to Shadow but I would love to know if there is any example of a project successfully using Shadow + maven-publish
+ signing.
The other thing I tried was to specify all the artifacts individually:
signing {
sign jar
sign sourcesJar
sign javadocJar
sign shadowJar
}
Doesn't help, though.
Sorry, please ignore the part that says "this is no longer the case - I haven't changed anything but now I get no signature files." I had just forgotten that I need to explicitly tell Gradle to run the signArchives
task before publishing (I didn't need to do that when I was using the maven
plugin, but apparently I do now). So, yes, I still do get signature files generated locally, but they are still not published.
Well, my confusion about why sign publishing.publications.shadow
didn't work has been partly answered. I had put signing
above publications
and it doesn't like forward references. When I switch the order, it no longer complains that it can't find "shadow", but it fails with a different error:
Could not find method sign() for arguments [org.gradle.api.publish.maven.internal.publication.DefaultMavenPublication_Decorated@44a50910] on object of type org.gradle.plugins.signing.SigningExtension.
However, this error happens even if I completely remove Shadow from my build, so it seems more like the signing plugin not playing nicely with the maven-publish plugin for some reason.
AHA! I see what's going on and it does not have anything to do with Shadow. It's just that the ability to sign a maven-publish
publication in the way that the signing
plugin docs tell you to do was not actually implemented in Gradle until a few months ago, and I was using an older version. Sorry for the red herring.
@eli-darkly Do you have a link to github of the latest build.gradle example you posted above? I'm trying to come up w/ with just a simple hello world fat jar publish. TIA
@cekvenich My build file won't be useful for a simple example - it's not simple at all, since we're building multiple distributions, adding an OSGi manifest, and various other things. But if you're curious it's here.
Shadow Version
2.0.1
Gradle Version
4.2.1
Expected Behavior
Jars will be signed as I specified in build.gradle
Actual Behavior
Jars were being signed, but after I made a change in the publishing configuration involving Shadow, I stopped getting signatures (see below).
Gradle Build Script(s)
Content of Shadow JAR (
jar tf <jar file>
- post link to GIST if too long)n/a (the jar's contents are correct, that's not the problem)
This may not really be a Shadow issue per se, but I'm unclear on how to make things work as they should given the way we're using Shadow.
The issue is this. Our configuration used to be mostly the same as the above except that we were publishing via the
maven
plugin, rather thanmaven-publish
. We changed because we were having a problem with the POM for the shaded jar - it was showing dependencies that should be hidden - and that problem went away once we started usingmaven-publish
. The Shadow documentation made it pretty clear what config changes we had to make for this.However, after changing to
maven-publish
, we stopped getting signatures. I think this has something to do with the task and publication objects behaving differently. For instance, without Shadow, we would be able to specifysign publishing.publications.mavenJava
causing all artifacts for the publication to be signed. Butsign publishing.publications.shadow
does not work— I can't figure out what the name of the publication object is supposed to be. So I tried referencing the artifacts collectively asarchives
but that doesn't seem to do anything, even though the signature task is definitely running.Basically I'm just wondering if you have any example of a build file that uses both Shadow and signing. I'm sure that ours has some weird qualities that are unrelated to Shadow, since we're not Gradle experts, so it may not be worthwhile to go through it in detail, but if I see something that's known to work I can try to adapt to that.