How to publish a jar and a jpi file at the same time

Hi,

I am using the gradle-jpi-plugin to publish the job-dsl-plugin plugin. The maven plugin for publishing jenkins plugins also publishes the jar and the javadoc besides the jpi file. To do the same for the gradle plugin I changed the build files like this: https://github.com/jenkinsci/job-dsl-plugin/commit/872f554429278edf0407de86152ad5f9e2f27464#diff-c197962302397baf3a4cc36463dce5ea But then, the packaging element of the pom gets lost and the plugin is not found anymore by the jenkins tooling which drives the update center. How can I publish the jar and keep the packaging element? I already tried setting

install.repositories.mavenInstaller.pom.whenConfigured { pom ->
    pom.packaging = 'jpi'
}

which gives me the error

* What went wrong:
Execution failed for task ':job-dsl-plugin:install'.
> Could not publish configuration 'archives'
   > For artifact {org.jenkins-ci.plugins:job-dsl:1.19-SNAPSHOT:jpi}: An attached artifact must have a different ID than its corresponding main artifact.

Side note, why would we want to publish the plugin as a jar? A jpi is not too different from a war. A project, in my mind, is either a jar or a war, not both. The job-dsl-core is a separate artifact which can act as a dependency, which is properly being published: http://repo.jenkins-ci.org/releases/org/jenkins-ci/plugins/job-dsl-core/1.18/

If you have another plugin which would have the job-dsl-plugin as a dependency, then the jar needs to be there to put it on the compile classpath. At least this is how I think it works. Right now, no other plugin can depend on the job-dsl-plugin.

Publishing two artifacts just differing in their extension is currently not supported in gradle. One workaround would be to change the artifact name of your jar (maybe job-dsl-plugin-lib) or just add a classifier (like lib) to your jar

The related Jira issues is GRADLE-2999