Maven pom.xml in META-INF vs pom.xml in Maven repository

Viewed 686

I'm trying to produce a Maven-compatible artefact using bazel. I noticed that mvn puts some files inside META-INF directory in JAR archive (file.jar/META-INF/maven/groupId/artifactId/pom.xml and file.jar/META-INF/maven/groupId/artifactId/pom.properties)

Questions:

  1. Are they needed to be able to successfully depend on my artifact from another project? I know you can disable them via a config option in pom.xml ref, which leads me to believe that you don't.
  2. Are they used by mvn in any case whatsoever?
  3. Can I use pom.xml inside on the JAR instead of pom.xml near my artifact in Maven repo?
1 Answers

We have several jars in your Maven repository that do not contain a pom.xml. For maven, the revelant pom.xml is the one that is outside your artifact. In Nexus, you deploy a jar always along with a pom.xml and that is the one that counts.

So you need to publish a pom.xml along with your jar if you want to use it from Maven, but you do not need to put it inside. AFAIK you cannot change this behaviour.

Related