Configured artifacts are not uploaded during uploadArchives

(Connor Garvey) #1

I can’t figure out why uploadArchives continues to try to upload a jar that doesn’t exist instead of the archive that I’ve configured in the artifacts closure. I would appreciate some suggestions.

def customPackage = tasks.custom.archive
  artifacts {
  println customPackage
  archives customPackage
  ['repoUser', 'repoPassword'].each { if (!project.hasProperty(it)) project.ext."$it" = '' }
  uploadArchives {
  repositories.mavenDeployer {
    uniqueVersion = false
    def credentials = [userName: project.repoUser, password: project.repoPassword]
    repository(url: "http://repo/releases/") {
    snapshotRepository(url: "http://repo/snapshots/") {

This is the output

:compileJava UP-TO-DATE
:compileGroovy UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
Uploading: com/company/project/1.0-SNAPSHOT/project-1.0-SNAPSHOT.jar to repository remote at http://repo/snapshots/
Transferring 0K from remote
  FAILURE: Build failed with an exception.
  * What went wrong:
Execution failed for task ':uploadArchives'.
> Could not publish configuration ':archives'.
   > Error deploying artifact '': Error deploying artifact: Failed to transfer file: http://repo/snapshots/com/company/project/project/1.0-SNAPSHOT/project-1.0-SNAPSHOT.jar. Return code is: 401

The 401 is expected, but the attempt to upload a jar is not. Any ideas?

Thank you, Connor

(Connor Garvey) #2

Some creative Googling led me to this, which removes the jar from the list of archives. The Java plugin adds this even if you don’t need it.

configurations.archives.artifacts.removeAll { jar }