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.