Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set up maven 3 local plugin repository

I need to have a completely offline maven repository due to some limitations. According to http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException , only <pluginRepositories> are searched for plugins. So I am wondering how to configure maven to look up plugins in a local file system. I tried using "file://" prefix when setting <url> but it doesn't work.

DEBUG] Verifying availability of /home/dsun/.m2/repository/org/apache/karaf/tooling/features-maven-plugin/2.3.0/features-maven-plugin-2.3.0.jar from [central (http://repo1.maven.org/maven2, releases=true, snapshots=false, managed=false)]
[ERROR] Plugin org.apache.karaf.tooling:features-maven-plugin:2.3.0 or one of its dependencies could not be resolved: The repository system is offline but the artifact org.apache.karaf.tooling:features-maven-plugin:jar:2.3.0 is not available in the local repository. -> [Help 1]
org.apache.maven.plugin.PluginResolutionException: Plugin org.apache.karaf.tooling:features-maven-plugin:2.3.0 or one of its dependencies could not be resolved: The repository system is offline but the artifact org.apache.karaf.tooling:features-maven-plugin:jar:2.3.0 is not available in the local repository.

dsun@localhost:> ls /home/dsun/.m2/repository/org/apache/karaf/tooling/features-maven-plugin/2.3.0/features-maven-plugin-2.3.0.jar
/home/dsun/.m2/repository/org/apache/karaf/tooling/features-maven-plugin/2.3.0/features-maven-plugin-2.3.0.jar

The settings.xml

<settings>      
<offline>true</offline>
  <profiles>
  <profile>
    <id>local</id>
    <pluginRepositories>
      <pluginRepository>
      <id>central</id>
      <url>file://${env.HOME}/.m2/repository</url>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </pluginRepository>
  </pluginRepositories>
   </profile>
 </profiles>
<activeProfiles>
  <activeProfile>local</activeProfile>
</activeProfiles>

<localRepository>${env.HOME}/.m2/repository</localRepository>

like image 378
SunLiWei Avatar asked Nov 21 '12 16:11

SunLiWei


People also ask

How do I access my local Maven repository?

Maven central repository is located on the web. It has been created by the apache maven community itself. The path of central repository is: http://repo1.maven.org/maven2/. The central repository contains a lot of common libraries that can be viewed by this url http://search.maven.org/#browse.

What is the local Maven repository?

Maven's local repository is a directory on the local machine that stores all the project artifacts. When we execute a Maven build, Maven automatically downloads all the dependency jars into the local repository. Usually, this directory is named .

Where do I put Maven plugins?

Introduction. In Maven, there are two kinds of plugins, build and reporting: Build plugins are executed during the build and configured in the <build/> element. Reporting plugins are executed during the site generation and configured in the <reporting/> element.


1 Answers

Finally, I found the problem, there's a file called _maven.repositories in the plugin directory, after I delete the file, all works well!

More details, see the following links:

  • http://maven.40175.n5.nabble.com/Maven-3-maven-repositories-and-lastUpdated-td4927537.html

  • http://jira.codehaus.org/browse/MNG-5181

like image 92
SunLiWei Avatar answered Oct 12 '22 10:10

SunLiWei