I try to make my Project offline and build the project with an in-project-repo. So the ~/.m2/ directory is empty at the beginning. I added the following into my poms:
<repositories>
<repository>
<id>project</id>
<url>file://${basedir}/lib</url>
</repository>
<repository>
<id>central</id>
<name>Maven Repository Switchboard</name>
<layout>default</layout>
<url>http://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Maven Plugin Repository</name>
<url>http://repo1.maven.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
</pluginRepository>
<pluginRepository>
<id>project</id>
<url>file://${basedir}/lib</url>
</pluginRepository>
</pluginRepositories>
Then I deleted everything in my .m2 folder and build my project with internet with the option
-dependency:go-offline
This works. Then I copy everything out of the .m2/repository directory into my lib directory in my project and delete the content in .m2/repository. Now I disconnect from the internet and try to build my project with the option -o. This dont work and I get the following error:
[ERROR] Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.5: The repository system is offline but the artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.5 is not available in the local repository. -> [Help 1]
In my lib folder(in-project-repo) exist this plugin and all the other plugins. I have some sources who are not availbable in the internet. I copyed them to my lib folder(in-project-repo) and they get copyed into the local m2 repository when I build my project. So I guess my in-project-repo is working. I don't understand this. If I let the content int the ~/.m2 folder I can build my project without internet.
I hope someone can help me!
Kindly Regards
EDIT: I made it work with the option:
-Dmaven.repo.local=/path/to/project/lib clean package -X -o
Is there a better way?