How to force the MavenDeployer to push artifacts with type='jar'?

Hello,

The jar we are publishing under Artifactory have so far no Maven type or Gradle ext specifiers, how can I specify this property to be able to distinguish with the zip we are publishing at the same GVA location ?

I am using Gradle 1.2.

Thanks,

Jean-Pierre

So far I am using the following to upload the jars:

uploadArchives.doFirst() {
  logger.lifecycle path + " Project Version: " + project.version
  repositories.mavenDeployer {
   name = 'artifactory'
   def repositoryRootUpload = 'http://13.24.19.71:80/artifactory/'
            if (version.endsWith('SNAPSHOT')) {
                repository(url: repositoryRootUpload + 'libs-snapshot-local') {
                    authentication(userName: "xxxxx", password: "yyyyy")
                }
            } else {
                repository(url: repositoryRootUpload + 'libs-release-local') {
                    authentication(userName: "xxxxx", password: "yyyyy")
                }
            }
  }
 }

And I am using the following to upload the zip files:

task uploadZip(type: Upload) {
      configurations {
        zipConf
    }
      artifacts {
        def pathToZip = "${buildDir}/distributions/" + project.name + "-" + version + ".zip"
        zipConf file(pathToZip)
    }
    configuration = configurations.zipConf
    repositories.mavenDeployer {
        name = 'artifactory'
        if (version.endsWith('SNAPSHOT')) {
            repository(url: repositoryRootUploadZip + 'libs-snapshot-local') {
                authentication(userName: "xxxxx", password: "yyyyyyy")
            }
        } else {
            repository(url: repositoryRootUploadZip + 'libs-release-local') {
                authentication(userName: "xxxxxx", password: "yyyyyyy")
            }
        }
    }

I don’t understand the question. If you are asking why there is no ‘<packaging>jar</packaging>’ in the generated POM, the answer is that it is redundant and therefore omitted. In any case, the two artifacts will have to have at least a different classifier.

The problem is that the jar is published with no classifier, and the zip is published with a zip classifier. And when a dependency is asked from gradle with no classifier specified, we get the zip instead of the jar we wanted. So I need a solution to distinguish both artifacts with the jar classifier that I am struggling to set.

  1. jar published under Artifactory:
compile(group: 'com.alcatel.asn', name: 'asn-nem-server', version: '1.1.3.4.8-SNAPSHOT')

or

<dependency>
    <groupId>com.alcatel.asn</groupId>
    <artifactId>asn-nem-server</artifactId>
    <version>1.1.3.4.8-SNAPSHOT</version>
</dependency>
  1. zip published under Artifactory:
compile(group: 'com.alcatel.asn', name: 'asn-nem-server', version: '1.1.3.4.8-SNAPSHOT', ext: 'zip')

or

<dependency>
    <groupId>com.alcatel.asn</groupId>
    <artifactId>asn-nem-server</artifactId>
    <version>1.1.3.4.8-SNAPSHOT</version>
    <type>zip</type>
</dependency>

And when a dependency is asked from gradle with no classifier specified, we get the zip instead of the jar we wanted.

That’s strange. Maybe there is a problem lurking in your build script(s). For one thing, ‘ext:’ is not the same as ‘classifier:’. I recommend to try with the latter. I also recommend to try with the latest Gradle version.

One way to set a classifier for a Jar is ‘someJarTask.classifier = “myClassifier”’. This is supposed to be honored when publishing. Although I don’t think it should be necessary to solve your problem.

Normally, Gradle will determine the extension/type of an artifact from the supplied file name. I’m not sure why that’s not working for you.

You can specifically set the attributes of a file artifact, as documented in the user guide. The set of values that you can configure are documented in the javadoc.