0

How to publish an artifact with a given (prêt-à-porter) POM file? if it is possible, please, advise when and how to set it before calling the publishing task.

1 Answers1

0

In Gradle, having artifact jar and the corresponding customized POM, you cannot publish them just like in Maven:

 mvn deploy:deploy-file 
  -DgroupId=<group-id> 
  -DartifactId=<artifact-id> 
  -Dversion=<version> 
  -DpomFile=<path-to-pom>   <====== customized POM
  -Dfile=<path-to-file> 
  -DrepositoryId=<id-to-map-on-server-section-of-settings.xml> 
  -Durl=<url-of-the-repository-to-deploy>

You cannot do it from build.gradle script and I think even any plugin could not do that.

The functionality could be in AbstractPublisher class, but you cannot subclass the class, add the functionality implementation and plug in the customized publisher for publishPublicationToMavenRepository task.

What you can do (if you have the project for the jar with dependencies) is to hack the build phase, exactly jaring step:

jar.finalizedBy(project.tasks.setYourPom)

where in

task setYouPom(type: DefaultTask  ){

.....you substitute your JAR by renaming
and the POM you are getting for free ;) in the Publication

}