Parwinder Singh
Parwinder Singh

Reputation: 41

How to configure maven without internet access

While converting dynamic web project into maven project I'm getting this error:

"CoreException: Could not calculate build plan: 
 Plugin org.apache.maven.plugins:maven-compiler-plugin"

I can't access the internet to download any jars and plugins while converting because I'm on a restricted network with no internet access. Is there is any way to make a Maven project with no internet access?

I'm using:

Eclipse kepler
Maven 3.0.4
JDK 1.6

Upvotes: 4

Views: 10953

Answers (6)

jonathan
jonathan

Reputation: 432

You can try copying your .m2 folder to the machine without internet... and then running maven offline.

Upvotes: 0

Srihari
Srihari

Reputation: 766

Maven is a dependency management system which downloads the required dependencies from the internet or a mirror of the central maven repository. Incase you do not have both - connection to internet (Central Maven Repository) or a local mirror (Nexus is the most used replicator of the central maven repository in a Enterprise setting) - then maven is bound to get the dependencies off your local hard disk from the .m2 folder under your logged in user directory.

Hence, in order for maven to work, manually register all dependencies which you have listed in the pom(s) as described in the maven guide :

mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>

Upvotes: 0

Kevin He
Kevin He

Reputation: 63

About half year ago, when I worked as an intern in a company, we also encountered with virtually the same problem as you ------ we were in the restricted network, and our computers couldn't access the internet, but we still needed to use maven to update the project dependencies. Here is our solution:

  1. Find a server that can access the internet, and also you can access the server in your restricted network.
  2. Establish a sonatype nexus server on the server you found above.
  3. The sonatype nexus serer is just a private repository in your environment. You can upload your own packages into the repository, and also the nexus server can download required packages from the central maven repository.
  4. The last thing you need to do is to change the repository address in your pom.xml to the nexus server address

Hopefully, this can help you. And if you have any questions, please feel free to ask me again.

Upvotes: 4

raman rayat
raman rayat

Reputation: 414

I think without internet you can not download it, initially you need an internet connection because maven need bunch of dependency and it all depend on your project. if you download them manually one by one there is some chance that you could miss some dependency and error will resolve one by one it will take more time and research to search dependency over internet and fix them one by one. so I prefer instead of downloading manually go for internet connection it will download all the dependency automatically.

if you have restricted access download it at home and replace that folder with your work area folder

Upvotes: 0

Ankur Singhal
Ankur Singhal

Reputation: 26067

mvn clean -o install

Running in Offline Mode

If you ever need to use Maven without having access to a network, you should use the following option to prevent any attempt to check for updates to plugins or dependencies over a network:

-o, --offline 

When running with the offline option enabled, Maven will not attempt to connect to a remote repository to retrieve artifacts.

refer here and here for more options

Upvotes: 2

Ruchira Gayan Ranaweera
Ruchira Gayan Ranaweera

Reputation: 35557

You can manually download or some how find required artifacts.(jars) Then copy them into your local maven repository.

Now you can use

mvn clean install -o  // off-line build 

to build your project without internet.

Upvotes: 6

Related Questions