How to avoid uploadArchives to upload the default jar file?


(Jiaqi Guan) #1

I have a project which has 2 modules. Let’s name them as ‘moduleA’ and ‘moduleB’.
Since I want to push them to Maven central repo, I give them both the same artifact ID and same archivesBaseName to ‘xxx’.
I did some configuration, so both of them will generate 3 kinds of jars.

moduleA will generate:
xxx-1.0.jar (automatically generated, I want to keep this)
xxx-1.0-sources.jar
xxx-1.0-javadoc.jar

moduleB will generate:
xxx-1.0.jar (automatically generated, I don’t want this)
xxx-1.0-test-util.jar
xxx-1.0-test-javadoc.jar

As they both generate the xxx-1.0.jar which have the same name, I’m only want to publish the one generated by moduleA. When I run “gradle uploadArchives”, it will only submit one xxx-1.0.jar. How can I make sure that it will submit the one generated by A?

I tried to use the configuration “jar.enable = false” in the build.gradle file in moduleB. It makes the moduleB not generate the xxx-1.0.jar file, but when I run “gradle uploadArchives” again, it failed.
I got the error message as follows:
Execution failed for task ‘:moduleB:uploadArchives’.

Could not publish configuration ‘archives’
Cannot publish artifact ‘xxx-1.0.jar’ (/Users/sss/Documents/project/moduleB/build/libs/xxx-1.0.jar) as it does not exist.

Could someone help me? Thanks.


(Jiaqi Guan) #2

@jjustinic Could you take a look at this? Many thanks.


(James Justinic) #3

Why do you need to be using the legacy publishing method? This should be fairly easy with the maven-publish plugin.


(Jiaqi Guan) #4

Because there isn’t many user cases that I can follow in the new plugin. And some of the tasks that I need is not in that plugin.


(James Justinic) #5

I’m not sure what you mean here. The maven-publish plugin was enhanced earlier in the summer to finally be able to fully replace the maven plugin, which is now deprecated. Looking solely at https://github.com/linkedin/parseq/pull/190/files, there doesn’t look to be anything that should be out of the ordinary with the current state of maven-publish, while only publishing the artifacts you want to publish.