Difference in uploading jar vs zip

Hi,

I’m trying to publish different files with different configurations (needed for other project dependencies), but I see some odd behavior. When creating a zipfile in a custom configuration, it works without a problem. However creating a jar in a custom configuration does not get uploaded. Is this expected behavior?

apply plugin: "java"
apply plugin: "maven"
  group = "org.test"
version = "0.0.0-SNAPSHOT"
  task (uploadTask, type:Upload) {
      configuration = project.configurations.archives
      repositories {
        mavenDeployer {
          repository(url: "file:///tmp/my-repo")
        }
      }
    }
    task extraZip1(type: Zip) {
 from "extra1"
 classifier "extra1"
}
  task extraZip2(type: Jar) {
 from "extra2"
 classifier "extra2"
}
    configurations {
 conf1
 conf2
}
  artifacts {
  conf1 extraZip1
  conf2 extraZip2
}

Executing the uploadTask task:

:uploadTask
Uploading: org/test/gradletest/0.0.0-SNAPSHOT/gradletest-0.0.0-20130813.201431-9.jar to repository remote at file:///tmp/my-repo
Transferring 0K from remote
Uploaded 0K
Uploading: org/test/gradletest/0.0.0-SNAPSHOT/gradletest-0.0.0-20130813.201431-9-extra1.zip to repository remote at file:///tmp/my-repo
Transferring 0K from remote
Uploaded 0K
  BUILD SUCCESSFUL

–> so the zip gets uploaded, but the jar doesn’t?

You’ll want to upload ‘configurations.conf1/conf2’, not ‘configurations.archives’. Presumable, the Zip is automatically added to ‘archives’ as well, whereas the Jar is not because ‘archives’ already contains a Jar (the one produced by the Java plugin).

That makes sense… However I can’t figure out a way to upload both configurations.conf1 and conf2 correctly. As far as I understand the Upload task can only handle 1 configuration? So that leaves me up to creating multiple upload tasks. However if I do so I get problems with the maven number schema. Only the configuration that contains an artifact without a classifier will get correctly SNAPSHOT replaced by a version number.

So I wonder: is there a way to add the artifacts from conf2 to the archives configuration like it’s done with the zipfile? Or should I look at the incubating maven-deployed plugin, maybe that helps me out?

The solution depends on what exactly you want to achieve (e.g. one Maven module with two artifacts or two modules with one artifact each). Instead of declaring your own ‘Upload’ task, you can use/configure the task that’s autogenerated for each configuration (e.g. ‘uploadConfig1’). Maybe this will also solve your snapshot problems. To add the Jar to the ‘archives’ configuration, it should be enough to say so in the ‘artifacts’ block.

Basically the only reason why I want the extra configuration is that I want to be able to refer to it from another project. This in order to build projects recursively if desired instead of binary dependencies

dependencies {
  if(compileFromSource) {
    debugApk project(path:':otherproject', configuration: "androidDebug")
  }
  else {
    debugApk
  group: "org.test", name: 'myName',
       version: version, classifier: 'native-android-debug'
  }
}

As you can’t use the classifier for a project dependency I have to go for configurations.

So from your reply I believe it’s not harm to add the jar file twice to a configuration. Once to the archives configuration (for the upload task), and once to the androidDebug configuration (for the project dependency). That will work for me, thanks!