Hi,
I’m publishing a third party jar and a subset of sources to our Artifactory gradle repository with the following build script:
apply plugin: 'ivy-publish' group = 'com.group' version = libversion publishing { publications { lib(IvyPublication) { module 'lib' artifact file("$buildDir/lib.jar") artifact source: libSourcesJar, type: 'source' } } repositories { ivy { url "http://localhost:8082/artifactory/ext-release-local" } } }
For projects that require these dependencies, I just have a simple build script like so:
apply plugin: 'java' repositories { ivy { url "http://localhost:8082/artifactory/ext-release-local" } } dependencies { compile 'com.group:lib:libversion' }
This works, but the problem is that in eclipse, the source jar gets added to the classpath separately as if it were a library jar itself.
I’ve looked at the docs for modules with multiple artifacts, and it looks like the solution is to put the source jar in a configuration other than default.
I attempted to set the sources jar to a different configuration with this:
publishing { publications { lib(IvyPublication) { module 'lib' configurations { runtime } artifact file("$buildDir/lib.jar") artifact source: libSourcesJar, type: 'source', conf: 'runtime' }
This publishes fine, but when my other projects try to resolve the dependencies I get errors that the default configuration is missing.
So I tried adding a default configuration, but default is a reserved word in groovy, so I had to end up with this:
publishing { publications { lib(IvyPublication) { module 'lib' configurations { it."default" runtime } artifact source: file("$buildDir/lib.jar"), conf: 'default' artifact source: libSourcesJar, type: 'source', conf: 'runtime' }
This now technically works, but it feels kind of hacky. I’ve looked at examples in the docs, and they don’t seem to have to declare a default configuration as I have. Is there something I’m overlooking? What’s the correct way to handle this?
Thanks,