uploadArtifacts skips ASC files during upload of multiple artifacts in multi-module project

I have a multi-module project where different test suites (unit, integration, functional) and main source are separate modules. Upon successful build, I generate 4 artifacts from my main sources (main module): uber, skinny, sources and javadoc JARs.

I use gradle-nexus-plugin to sign the artifacts and upload them to Nexus. Before the upload I do see in my main module’s ‘’‘target/libs’’’ the 4 artifact JARs and their generated signatures, the .ASC files.

Since it is a multi-artifact upload process, I configure filters for mavenDeployer in order to generate multiple POMs. After the upload process has finished, I do not see ASC files uploaded to Nexus. Only the JARs, their md5, sha1, POM and its sha1, md5 get uploaded.

In order to “force” the upload of ASC, I add the generated .asc files as artifacts to ‘’‘mavenDeployer’’’ using the ‘’‘beforeDeployment’’’ closure. I created a custom class ‘’‘AscSignature’’’ that implements PublishArtifact interface for this purpose.

This solution works, but I am not happy. I still do not understand why ASC files skipped during upload. I am not sure what I am missing and where I am going wrong. I wish not to create custom classes and hacky solutions.

Could you please advise what could be the problem. Most probably the information provided was not sufficient, please let me know if you need to know anything specific. I am using Gradle v1.5. Thank you

uploadArchives {
   repositories {
      mavenDeployer {
         beforeDeployment { MavenDeployment deployment ->
            def baseName = "${projectName}-${version}"
            def basePath = "$buildDir/libs/" + baseName
            def ext = "jar.asc"
            deployment.addArtifact(new AscSignature(baseName, ext, ext, "sources", file(basePath + "-sources." + ext)))
            deployment.addArtifact(new AscSignature(baseName, ext, ext, "javadoc", file(basePath + "-javadoc." + ext)))
            deployment.addArtifact(new AscSignature(baseName, ext, ext, "no-dependencies", file(basePath + "-no-dependencies." + ext)))
            deployment.addArtifact(new AscSignature(baseName, ext, ext, "", file(basePath + "." + ext)))
         }
           def jarPom = addFilter('jar') {artifact, file -> artifact.ext == "jar" }
         jarPom.version = "$version"
         jarPom.artifactId = "$projectName"
         jarPom.groupId = "$projectGroup"
         jarPom.project {
            .......
        }
     }
   }
}

The ‘gradle-nexus-plugin’ seems to leverage the ‘signing’ plugin to generate signature files. The ‘signing’ plugin actually adds PublishArtifact instances for each of the generated signatures to the signed configuration, which for the ‘gradle-nexus-plugin’ is ‘archives’. So the question is why these PublishArtifacts are not being included in your deployment automatically. I think you’ll need to look at using the PublishFilter class to include multiple artifacts in your deployment.

FYI Gradle is actually only “uploading” the jar artifact: it is also ignoring your .sha1 and .md5 files. The ones that end up on the server are actually generated by the MavenDeployer.

Daz…

Thank you… What you explained I was already aware of, I guess I thought as long as I provided filter for the JARs as per my example above, the ASC will be included as well automatically… Which is obviously not the case. I should have added another filter for ASC.

So, adding the missing filter to ‘’‘mavenDeployer { … }’’’ did the jobs nicely:

def ascPom = addFilter('asc') {artifact, file -> artifact.ext == "asc" }
         ascPom.version = "$version"
         ascPom.artifactId = "$projectName"
         ascPom.groupId = "$projectGroup"

Now the mavenDeployer configuration is as follows:

uploadArchives {
   repositories {
      mavenDeployer {
           def ascPom = addFilter('asc') {artifact, file -> artifact.ext == "asc" }
         ascPom.version = "$version"
         ascPom.artifactId = "$projectName"
         ascPom.groupId = "$projectGroup"
           def jarPom = addFilter('jar') {artifact, file -> artifact.ext == "jar" }
         jarPom.version = "$version"
         jarPom.artifactId = "$projectName"
         jarPom.groupId = "$projectGroup"
         jarPom.project {
          ............. //Modifying the POM ......
          }
      }
   }
}

The signatures are uploaded alongside JARs.

Thank you

I’m having the same issue with publishing to Sonatype. I followed the advice here and got it to upload the asc files for the sources and javadoc jar files, but it’s still skipping the main .jar.asc file.

As a little note, Just doing the above didn’t work for me, it resulted in an error from Ant that had to do with the “artifacts” being non-existent.

To get the javadoc and sources asc files along with the jars, I had to do something like this:

configurations {
 releaseArtifacts {}
}
signing {
 sign configurations.releaseArtifacts
}
artifacts {
 releaseArtifacts jar
 releaseArtifacts javadocJar
 releaseArtifacts sourcesJar
 releaseArtifacts file("build/libs/${name}-${version}-javadoc.jar.asc")
 releaseArtifacts file("build/libs/${name}-${version}-sources.jar.asc")
 releaseArtifacts file("build/libs/${name}-${version}.jar.asc")
}

I didn’t need to add the filter at all - just adding them to the artifacts closure worked for me.

EXCEPT!! and this is a big EXCEPT!!, please don’t ignore this question.

The “build/libs/${name}-${version}.jar.asc” file is not being uploaded - no idea way.

I tried adding the filters - it doesn’t help.

Any help here would be greatly appreciated.

Hi Elberry,

Th following is not exactly the solution you are looking for, but:

When you said “Just doing the above didn’t work for me, it resulted in an error from Ant that had to do with the “artifacts” being non-existent.”, were you aware that I am using ‘gradle-nexus-plugin’ to sign the artifacts and upload them to Nexus?

In other words, the solution I have mentioned earlier that HAS worked for me, I used in conjunction with ‘gradle-nexus-plugin’… I have not tried to create my own configuration (like your self) to upload the artifacts…

Alexander, I did see that, but for some reason my brain tricked me into thinking it was the same plugin as the bintray plugin: https://bitbucket.org/davidmc24/gradle-bintray-plugin

Which I tried but didn’t get to work.

The nexus plugin you linked to looks better. Thanks very much for pointing it out again. I will give it a try.

Cheers.

I also could not get the upload[configuration] to upload artifact signatures. I worked around with the following

group = 'org.voltdb'
version = file('version.txt').text[0..-2]
description = 'VoltDB client interface libraries'
  configurations {
   clientArchives
   ascSignatures
}
  // jar tasks ...
  artifacts {
  clientArchives clientDocJar
  clientArchives copyClient
}
  signing {
  sign configurations.clientArchives
}
  uploadClientArchives {
    repositories {
        mavenDeployer {
            beforeDeployment { MavenDeployment mvnd ->
               signing.signPom(mvnd)
              configurations.clientArchives.artifacts.each { ca ->
                def ascfile = file(ca.file.path + '.asc')
                def ascartf = project.artifacts.add('ascSignatures', ascfile) {
                  classifier = ca.classifier
                  extension = ca.extension + '.asc'
                  type = ca.type + '.asc'
                }
                mvnd.addArtifact(ascartf)
              }
            }
               repository(url: "file://localhost/Users/stefano/tmp/m2repo/")
               pom.project {
               name 'voltdbclient'
               packaging 'jar'
               description 'VoltDB client interface libraries'
               url 'http://www.voltdb.com/'
                  scm {
                   url 'scm:git@github.com:VoltDB/voltdb.git'
                   connection 'scm:git@github.com:VoltDB/voltdb.git'
                   developerConnection 'scm:git@github.com:VoltDB/voltdb.git'
               }
                  licenses {
                   license {
                       name 'GNU Affero General Public License Version 3'
                       url 'http://www.gnu.org/licenses/agpl.txt'
                       distribution 'repo'
                   }
               }
                  developers {
                   developer {
                       id 'vtkstef'
                       name 'Stefano Santoro'
                   }
               }
            }
        }
    }
}
  uploadClientArchives.dependsOn {
  [signClientArchives]
}

-Stefano

1 Like