Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven: How to install a plugin in offline mode

Tags:

maven-2

I'm sitting behind a firewall and therefore maven can't connect to central repositories (error message is given below).

However, I can connect to the internet via HTTP.

How can I install a maven plugin (e. g. archetype) in offline mode (i. e. download some file in a browser and then install the plugin by executing some commands) ?

Thanks in advance

Dmitri

P. S.: Here is the error message:

E:\>mvn archetype:generate -DarchetypeGroupId=com.vaadin
 -DarchetypeArtifactId=vaadin-archetype-clean -DarchetypeVersion=LATEST -DgroupI
d=at.swdev -DartifactId=pcc -Dversion=1.0 -Dpackaging=war
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] org.apache.maven.plugins: checking for updates from central
[WARNING] repository metadata for: 'org.apache.maven.plugins' could not be retri
eved from repository: central due to an error: Error transferring file: Connecti
on refused: connect
[INFO] Repository 'central' will be blacklisted
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] The plugin 'org.apache.maven.plugins:maven-archetype-plugin' does not exi
st or no valid version could be found
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Thu Jul 22 15:17:00 CEST 2010
[INFO] Final Memory: 1M/15M
[INFO] ------------------------------------------------------------------------
like image 809
Dmitrii Pisarenko Avatar asked Jul 22 '10 18:07

Dmitrii Pisarenko


People also ask

Can you use maven offline?

The go-offline goal of the Maven Dependency plugin downloads all the required dependencies and plugins for the project, based on the pom file. The –o option tells Maven to work offline and not check the Internet for anything.

What is MVNW dependency go-offline?

In order to prepare for offline mode, we can use the go-offline goal from the maven-dependency-plugin: mvn dependency:go-offline. This goal resolves all project dependencies — including plugins and reports and their dependencies. After running this goal, we can safely work in offline mode.

What does maven dependency plugin do?

The dependency plugin provides the capability to manipulate artifacts. It can copy and/or unpack artifacts from local or remote repositories to a specified location.

Which of the following command is used to build a project offline?

☑️Open a project that you want to build offline. ☑️Run the following command: mvndependency:go-offline.


1 Answers

I'm sitting behind a firewall and therefore maven can't connect to central repositories (error message is given below). However, I can connect to the Internet via HTTP.

Maybe you should clarify a bit because Maven uses HTTP as well. If you connect through some kind of proxy, you CAN configure Maven to do so by declaring the proxy in your ~/.m2/settings.xml. See Configuring a proxy.

How can I install a maven plugin (e. g. archetype) in offline mode (i. e. download some file in a browser and then install the plugin by executing some commands)?

You can install any jar in your local repository using the install:install-file goal (see the Usage page). But this is only a small part of the story, you'll need to install dependencies of the plugin too. And then dependencies of dependencies. This will very quickly become a real nightmare and unmanageable task (that Maven precisely tries to solve). So either:

  • Configure Maven to access Internet if this is possible ~or~
  • Setup a corporate repository (like Nexus) on a dedicated machine, see with your admins how to allow it to access Internet) and configure your Maven client to use it ~or~
  • Copy a "pre-populated" local repository from an existing machine to your machine and run maven offline (with all the limitations this implies) ~or~
  • Don't use Maven
like image 137
Pascal Thivent Avatar answered Oct 07 '22 01:10

Pascal Thivent