How to configure artifact name from components.Java independent of module name when use ivy-publish plugin?


(Baiyan Huang) #1

Hi, All,

When using ivy-publish, I can publish artifact from components.java, as below:

publications {
        ivyJava(IvyPublication) {
            from components.java
        }
    }

And it is possible to change the artifact name by setting module:

publications {
        ivyJava(IvyPublication) {
            module = "modulename"
            from components.java
        }
    }

But this not only set the final artifact name, but also the module name in ivy file, which I don’t expect - is there a way just for me to configure the artifact name that from components.java when publish?


#2

You can access and modify the configured artifacts using ‘IvyPublication.getArtifacts()’ which provides an IvyArtifactSet.

publications {

ivyJava(IvyPublication) {

from components.java

artifacts.matching({

it.name == ‘original-name’

}).all({

it.name = ‘new-name’

}) }}





#3

You can access and modify the configured artifacts using ‘IvyPublication.getArtifacts()’ which provides an IvyArtifactSet.

publications {

ivyJava(IvyPublication) {

from components.java

artifacts.matching({

it.name == ‘original-name’

}).all({

it.name = ‘new-name’

}) }}





#4

You can access and modify the configured artifacts using ‘IvyPublication.getArtifacts()’ which provides an IvyArtifactSet.

publications {

ivyJava(IvyPublication) {

from components.java

artifacts.matching({

it.name == ‘original-name’

}).all({

it.name = ‘new-name’

}) }}





(Baiyan Huang) #5

Thanks Daz, this worked for me, here is what I used to be more accurate:

artifacts.matching({
                it.name == project.name &&
                it.type == 'jar' &&
                it.classifier == null
            }).all ({
                it.name = "new-name"
            })