Maven: How to install a plugin in offline mode

泪湿孤枕 提交于 2019-12-01 06:27:50

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

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/

I guess your security firewall doesn't allow you to download from maven central repo.So, you can simply specify mirrors in the settings.xml file in the maven_home. if you have any repository for your company say like nexus, give the server url of that nexus in the mirrors section in your settings.xml. Note that in case if you don't have any repo for your company you have to download all the dependencies offline and install using mvn install in the local repository in your build server.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!