tags:

views:

32

answers:

2

Hello!

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] ------------------------------------------------------------------------
A: 

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
Pascal Thivent
Thanks, configuring proxy helped!
@~dp-sw-dev: You're welcome. Glad it helped.
Pascal Thivent
A: 

If you can not use proxy, then you should download all dependencies of plugin as Pascal said. Easiest way to do this.

Download all dependencies using a machine with normal/proxied http connection. Maven dependency plug-in has a goal which can help you. mvn dependency:go-offline

For example I use it to get maven dependencies of app-fuse tutorial.

svn co (http here ) appfuse-demos.googlecode.com/svn/trunk/helloworld (check out source code) mvn install (install and see that it works in normal machine) mvn dependency:go-offline (it downloads everything. Help :tells Maven to resolve everything this project is dependent on (dependencies, plug-ins, reports) in preparation for going offline.)

after that in your local m2 repository (~/m2/repository) , you will find everything you need. Zip that folder. Get it inside your intranet. extract it to your local repository or corporate repository (nexus, artifactory ..)

you should be able to use that plug-in now.

http://maven.apache.org/plugins/maven-dependency-plugin/

Atilla Ozgur