You don't really need to point to a local repository.  By default Maven will 
use C:\Users\<username>\.m2\respository as the local repo.  (i.e. for a Windows 
host).

If you want to specify a different location for the local repo you can use this 
in your settings.xml:
<localRepository>
    C:\<anyplace>......
</localRepository>

Finally, to populate your local repo for the first time (i.e. when you ARE 
connected to the net), you can execute the Maven goal archetype:create to build 
a "hello world" app.  As long a you start with an empty local repository, 
wherever that happens to be i.e. the default location or somewhere else as per 
your settings.xml file, then Maven will attempt to get plugins and artifacts 
from the local repo first but since it is empty it will go to the default 
remote repo to get these and populate the local repo.  As long as you can 
access the location of the local repo from your VM's there is no need to copy 
anything!

Just one reminder, when you run Maven with the archetype:create goal DO NOT use 
the -o option!!!  After that, when you want to use the local repo only USE the 
-o option.

One last thought.  Using Maven in offline only mode may present you with some 
problems down the road, depending on what "external" artifacts your application 
uses.  If you only populate the local repo once then you will not be using 
updated artifacts as they become available.  If you are not using any 
"external" artifacts (e.g. XML parsers, log file libraries, etc.) in your app, 
this should not be a problem.

Other on the mailing list feel free to correct me if  I've given George any 
incorrect info.

Good luck!  And happy building.

Michael Tarullo
Contractor (Engility Corp)
Enterprise Architect
NSRR System Administrator
FAA WJH Technical Center
(609)485-5294


-----Original Message-----
From: George Karabotsos [mailto:kara...@gmail.com] 
Sent: Friday, September 04, 2015 10:27 AM
To: users@maven.apache.org
Subject: Creating local repository

Hello all,

Let me start by admitting I am by no means a maven expert :).

Now I have a need to create a local file-based repository to be used by maven 
when building my project.  I need this because I have no net access from a set 
of VMs I and colleagues have to use .

I was thinking of the following:
1) connected to the net, normally proceed and download all necessary artifacts
2) copy these jars with
          > cp -r Users/gkarabotsos/.m2/repository .
3) Add the following to my pom.xml
  <repositories>
    <repository>
      <id>localrepository</id>
      <url>file:///c:/repository/</url>
    </repository>
  </repositories>

I do know that it does not work--I am guessing my c:/repository
structure does not have the correct form.   

I have also seen, in the net, commands such as the following:

mvn install:install-file -Dfile=YOUR_JAR.jar -DgroupId=YOUR_GROUP_ID 
-DartifactId=YOUR_ARTIFACT_ID -Dversion=YOUR_VERSION -Dpackaging=jar 
-DlocalRepositoryPath=/var/www/html/mavenRepository

Is this the only correct way? I have yet to try it, primarily because I have a 
few dozen artifacts and doing so will take me a long time.

 
Cheers,
George

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org

Reply via email to