How do I upload an external jar to an ivy repo?

(Ken Diep) #1

How do I upload an external jar to an ivy repo?

I am currently investigating the migration from ant to gradle. One of the thing I’d like to accomplish is executing a custom task to install an external jar to an ivy repo.

Currently in Ant I would execute “ant install-repo -Dart=artifact -Drev=1.2” this will install the said file to an ivy repo with the assoicated ivy.xml file. How can this be achieved in gradle?



There are 2 mechanisms: - The original publishing support - The new ivy-publish plugin

Either would serve your purposes, I think.

(Ken Diep) #3

Thanks for the tips. I’ve tried the new ivy-publish module, so far it is half working. I can now specify the source jar and artifact name from the command line ie “gradle publishExternalJarPublicationToIvyRepository -Psrc=sample.jar -Part=foobarOne”.

However, I have yet to be able to specify the group and version. These values I can set via a variable in the build script as shown below. But when I attempt to set it in the installExternalJar task, it has no effect. group = ‘foo’ version = ‘1.2’

task installExternalJar {

project.set(“src”, “$src”)

project.set(“art”, “$art”)

project.set(“group”, "foo) //this doesn’t seem to work }

publishing {

publications {

externalJar(IvyPublication) {

artifact source: project.get(“src”),

name: project.get(“art”),

extension: ‘jar’,

builtBy: installExternalJar


repositories {

ivy {

url “file://${rootDir}/lib/repository”



} } are there anything that i am missing?


The ‘group’ and ‘version’ values are taken directly from the project. There’s not currently any way to override this using the ‘ivy-publish’ plugin. Customising the publish coordinates is next on the list once we get back to working on the new publishing support. (Currently we’re busy getting things ready for the Android team).

(Ken Diep) #5

thanks Daz,

I suppose I’ll use the work around of using ant/ivy from gradle while I wait for the new ivy-publish module.