开发者

install maven plugin locally

开发者 https://www.devze.com 2023-02-12 16:03 出处:网络
I believe there\'s a maven command you can execute to download and install a plugin in the local repository. Something like:

I believe there's a maven command you can execute to download and install a plugin in the local repository. Something like:

mvn plugin:download -DartifactId=maven-war-plugin 
-DgroupId=org.apache.maven.plugins -Dversion=2.1.1  
-Dmaven.repo.remote=http://www.ibiblio.org/maven,http://maven-plugins.sourceforge.net/repository

I know that this should normally happen when you build a project开发者_JS百科 whose pom.xml references this plugin, but the security policy where I work is abnormal, so I need to manually install plugins.

The syntax above doesn't seem to work, does anyone know how to do this under Maven 3.0.2?


The above syntax is for Maven 1.0, which operated very differently from Maven 2.0 and Maven 3.0. You should continue to reference the plugin as you would - via the POM in this case or via the command-line directly for some types of commands. To strictly control what artifacts get downloaded, you can use a repository manager (such as Apache Archiva, Artifactory or Nexus) to intervene (as well as add several interesting features).

Here is how to force Maven to use the managed repository instead: http://archiva.apache.org/docs/1.3.4/userguide/using-repository.html

You can either add only the artifacts you want to use to that, or configure rules about what can be retrieved externally (e.g. http://archiva.apache.org/docs/1.3.4/adminguide/proxy-connectors.html)


The optimal way to deal with plugin and other artifact installation is to implement an instance of a Maven repository on your LAN. Products such as Nexus are open-source and easy to set up. Once up and running, upload your Plugin manually to Nexus. Then add your own local Nexus instance as a plugin repository inside of the settings.xml file for the developers who need it:

<pluginRepositories>
    <pluginRepository>
        <id>mycorp-plugin-release</id>
        <name>My Companys Nexus repository for plugin artifact releases</name>
        <url>https://intranet.mycorp.com/nexus/content/repositories/releases</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>

Seriously...it'll take a day to set up initially, but will make your life easier and shouldn't violate ANY security policy. It'll also help to ensure that all developers are using the exact same version of the plugin.

0

精彩评论

暂无评论...
验证码 换一张
取 消