1

I work on a standalone development network that has no connection to the internet. I've been putting off using Maven for years because it seems to require an internet connection, but I've finally got fed up with not having the dependencies required by JARs I've manually downloaded off Maven Central, and by documentation assuming that you can use Maven.

Therefore I'm trying to set up my own Maven server on the development network, and periodically clone across projects and their dependencies via CD/USB.

Being a Maven 'newbie' though, I'm struggling to find the information I need to do this. Is someone able to provide me with a guide to achieving the above?

James Baker
  • 1,143
  • 17
  • 39

5 Answers5

3

You can setup a Nexus repository, see http://www.sonatype.org/nexus/.

There is also this useful answer that address a similar problem.

Community
  • 1
  • 1
zerologiko
  • 1,993
  • 1
  • 18
  • 21
2

You would have to need to install each artifact on your local repository or use a repository manager like nexus or artifactory.

mvn org.apache.maven.plugins:maven-install-plugin:2.5.1:install-file  \
-Dfile=path-to-your-artifact-jar \                                                                                 
-DgroupId=your.groupId \                                                                                
-DartifactId=your-artifactId \
-Dversion=version \
-Dpackaging=jar \
-DlocalRepositoryPath=path-to-specific-local-repo

Maven loads its own plugins using the same mechanism as for other resources. You need at least those plugins in your local repository (in $HOME/.m2). Suggestion would be to use a network enabled computer, setup/build your project, execute mvn dependency:go-offline and then transfer the $HOME/.m2 repository to your USB. Then, if you want to package, mvn -o package, o for offline.

Anyway, this is not something I would recommend as using maven in such a setup will probably result in quite some pain.

2

Your need is not very rare. Many organizations work like to this for security and tractability reasons.

Your first need is to setup a maven repository manager that will host your downloaded remote repositories and keep your released artifacts.

Look into Nexus or Artifactory. Both are great repository managers and have a free version.

After that, you need to get all your maven installations to look at the repository manager and not to the public internet. This is done be editing the M2_HOME/conf/settings.xml. You can see documentations with maven or with the repository manager you install.

Follow all the documentation and you'll be good to go.

I hope this helps.

Eldad Assis
  • 10,464
  • 11
  • 52
  • 78
2

Ok, so here's a step-by-step guide to what I ended up doing. The answers were helpful, but none of them really provided the information I needed as a newbie to get it up and running.



1) Download and Install Sonatype Nexus on a machine connected to the internet

2) Install another version of Sonatype Nexus on the offline development network

3) Create an 'empty' Maven project in Eclipse

4) Add the following to $USER_HOME\.m2\settings.xml (the location of this folder is specified in Eclipse in Preferences->Maven->User Settings)

<settings> ... <mirrors> <mirror> <id>central-nexus</id> <name>Central (Nexus)</name> <url>http://localhost:8081/nexus/content/repositories/central/</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors> ... </settings>

5) Add required dependencies to the pom.xml - e.g. (The brackets around the version number will tell it to download newer versions too.)

<dependency> <groupId>org.apache.tika</groupId> <artifactId>tika-parsers</artifactId> <version>[1.5,)</version> </dependency>

6) Compile the project. This will cause Nexus to cache all the JARs and their dependencies.

7) Transfer the $NEXUS_ROOT\sonatype-work\nexus\storage folder to the offline network and replace the files in there with the copied files



I haven't yet worked out if there's a smarter way to do the copying so only the updates are copied, but it's got me started at least.

Thanks for the pointers in the right direction, and hopefully these instructions will be clear enough for other Maven newbies to follow.

James Baker
  • 1,143
  • 17
  • 39
0

I offer you to use an application such as Apache Archiva for that purpose. It can be used to mirror maven central repository. It has a very nice documentation here : http://archiva.apache.org/docs/2.0.0/

Özgür Eroğlu
  • 1,230
  • 10
  • 16