13

I have the following dependency in my pom.xml

<dependency>
    <groupId>aGroup</groupId>
    <artifactId>anArtifact</artifactId>
    <version>aVersion</version>
</dependency>

I also have the anArtifact-aVersion.jar file in ~/.m2/repository/aGroup/anArtifact/aVersion directory.

When I start building the project, maven looks for a .pom file instead of using the .jar file and attempts to download the following

http://repo1.maven.org/maven2/aGroup/anArtifact/aVersion/anArtifact-aVersion.pom

How can I configure maven to use the existing .jar file?

Raihan
  • 10,095
  • 5
  • 27
  • 45
  • Did you put that jar in your local repository (~/.m2/repository)? Or did Maven download it? – Daniel Oct 17 '11 at 14:57

5 Answers5

7

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>
HefferWolf
  • 3,894
  • 1
  • 23
  • 29
  • 2
    Does it mean that in the repository there should be this kind of ".pom" file next to jar while there are already files pom.xml and plugin.xml inside the jar file itself? Should it be a copy of one of those? – Dima Oct 17 '12 at 14:34
  • 1
    yes the pom needs to be there and yes I can be just a copy of an included pom. Local repositories like artifactory actually just extract an included pom if you upload a jar. – HefferWolf Oct 19 '12 at 08:46
4

the best way to install an artifact to the local repository which were not built by Maven ist to use

mvn install:install-file ...

have a look at the install:install goal.

slowessam
  • 115
  • 1
  • 3
  • 10
4

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.

sreddy
  • 49
  • 3
4

Run your build using the "-o" switch to use Maven in offline mode. In offline mode, Maven will not check for updates of snapshot dependencies in remote repositories.

Daniel
  • 10,115
  • 3
  • 44
  • 62
3

It is looking for the pom to, among other things, resolve the transitive dependencies.

smp7d
  • 4,947
  • 2
  • 26
  • 48