jameshfisher
jameshfisher

Reputation: 36403

What are .pom files in Maven build artifacts?

You can see from browsing any repository that Maven build artifacts contain .pom files. The contents of these files look a whole lot like pom.xml files. Where do these files come from? What are they used for? Additionally, build artifacts have maven-metadata.xml files, at least on search.maven.org, and these files have substantially the same content as the .pom files. What's the deal with that?

Upvotes: 5

Views: 11097

Answers (2)

datv
datv

Reputation: 617

The best answer I have found so far is in this SO thread. Here is an exact quote, highlighting the crux of the explanation:

Every jar needs to have a pom file describing it, you can just add something simple like this:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>aGroup</groupId>
    <artifactId>aArtifactId</artifactId>
    <version>aVersion</version>
    <packaging>jar</packaging>
    <name>a Name</name>
</project>

Another good explanation:

POM that is installed to Nexus will describe the jar. Used to pull the dependencies that are associated to corresponding jar. When we add the jar as dependency to our project, all the jars required for the included jar will be identified through the corresponding pom.

Upvotes: 0

khmarbaise
khmarbaise

Reputation: 97399

The files are the pom files from within the project. Those are deployed to the maven repository during the release build or by other build tools as well (gradle, ivy, etc.). Those files are needed to describe the dependencies of the appropriate artifact otherwise you have no other opportunity to store such kind of information.

In your particular example (really old 2005) this is a pom file which is created at a time of times where maven was not such distributed. In this case the file does not contain any dependencies.

If you take a look here:

http://search.maven.org/#browse%7C-77609479

you see a number of versions of a single artifact. If you now take a look into the maven-metadata.xml you will see list of available versions.

Upvotes: 2

Related Questions