I've been asked to look at an old project that requires Maven 2.1 and a couple JARs that are not (and will not) stored in our Nexus.
I'm trying to follow the advice from @Nikita Volkov in this post about creating a project repo to hold the JARs as artifacts. The idea being I can check this repo into source control. I can then check it out on any machine and have it build without any special configuration.
To start with I've created a repo and added my first Jar to it by running:
mvn install:install-file -DlocalRepositoryPath=repo -DcreateChecksum=true -Dpackaging=jar -Dfile=lib/myJar.jar -DgroupId=my.group -DartifactId=myArtifact -Dversion=0.0.1
I then create POM that looks like:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>my.group</groupId>
<artifactId>MyApp</artifactId>
<packaging>ear</packaging>
<version>1.0-SNAPSHOT</version>
<repositories>
<repository>
<id>my-repo</id>
<url>file://${project.basedir}/repo</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>my.group</groupId>
<artifactId>myArtifact</artifactId>
<version>0.0.1</version>
</dependency>
</dependencies>
<build>
</build>
</project>
When I view this in Eclipse if flags the dependency with error
Missing artifact my.group:myArtifact:jar:0.0.1.
When I run it from the command line Iget the error
Unable to find resource 'my.group:myArtifact:pom:0.0.1' in repository my-repo
Clearly I've not understood something in the original post, but I don't see what
So, can anybody provide a working example of how to create a in-project Maven Repo?
Update The files stored in my local repo are:
- my/group/myArtifact/0.0.1/myArtifact-0.0.1.jar
- my/group/myArtifact/0.0.1/myArtifact-0.0.1.jar.md5
- my/group/myArtifact/0.0.1/myArtifact-0.0.1.jar.sha1
- my/group/myArtifact/0.0.1/myArtifact-0.0.1.pom
- my/group/myArtifact/0.0.1/myArtifact-0.0.1.pom.md5
- my/group/myArtifact/0.0.1/myArtifact-0.0.1.pom.sha1
- my/group/myArtifact/maven-metadata-local.xml
- my/group/myArtifact/maven-metadata-local.xml.md5
- my/group/myArtifact/maven-metadata-local.xml.sha1
Update The contents of my .m2/settings file is:
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://192.168.152.78:5000/nexus/content/groups/public/</url>
</mirror>
</mirrors>
</settings>