繁体   English   中英

如何设置 maven 3 本地插件库

[英]How to set up maven 3 local plugin repository

由于某些限制,我需要一个完全离线的 Maven 存储库。 根据http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException ,只搜索<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

设置.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>

终于找到问题了,plugin目录下有个_maven.repositories文件,我把这个文件删掉后,一切正常!

更多详情,请查看以下链接:

从 Maven 3.1-alpha-1 开始,命令行选项-llr/--legacy-local-repository或系统属性-Dmaven.legacyLocalRepo=true应该会有所帮助

有关使用 maven 离线工作的一般答案,请参见此处

这个问题让我非常恼火,以至于我修补了 war 插件以添加一个 disableOverlaying 参数。 你可以在这里找到它 - 从原版分叉出来: https : //github.com/crowdcode-de/maven-war-plugin

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM