如何设置maven 3本地插件库

时间:2012-11-21 16:54:49

标签: java maven build-automation maven-3

由于某些限制,我需要一个完全脱机的maven存储库。根据{{​​3}},只搜索<pluginRepositories>插件。所以我想知道如何配置maven来查找本地文件系统中的插件。我在设置<url>时尝试使用“file://”前缀,但它不起作用。

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

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>

3 个答案:

答案 0 :(得分:8)

最后,我发现了问题,插件目录中有一个名为_maven.repositories的文件,删除文件后,一切正常!

更多详情,请参阅以下链接:

答案 1 :(得分:6)

自Maven 3.1-alpha-1起, 命令行选项-llr/--legacy-local-repository 或系统属性-Dmaven.legacyLocalRepo=true 应该帮忙

答案 2 :(得分:0)

这个问题使我非常恼火,以至于我修补了war插件以使其具有disableOverlaying参数。您可能会在这里找到它-由原始的https://github.com/crowdcode-de/maven-war-plugin

分叉