java 如何设置 maven 3 本地插件库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13498186/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to set up maven 3 local plugin repository
提问by SunLiWei
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.
由于某些限制,我需要一个完全离线的 Maven 存储库。根据http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException,只<pluginRepositories>
搜索插件。所以我想知道如何配置 maven 在本地文件系统中查找插件。我在设置时尝试使用“file://”前缀,<url>
但它不起作用。
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
设置.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>
回答by SunLiWei
Finally, I found the problem, there's a file called _maven.repositories in the plugin directory, after I delete the file, all works well!
终于找到问题了,plugin目录下有一个_maven.repositories文件,我把这个文件删除后,一切正常!
More details, see the following links:
更多详情,请查看以下链接:
回答by user1767316
Since Maven 3.1-alpha-1,
the command line option -llr/--legacy-local-repository
or the system property -Dmaven.legacyLocalRepo=true
should help
从 Maven 3.1-alpha-1 开始,命令行选项-llr/--legacy-local-repository
或系统属性-Dmaven.legacyLocalRepo=true
应该会有所帮助
回答by gorefest
This problem annoyed me so much that I patched the war plugin to have a disableOverlaying parameter. You may find it here - forked from the original : https://github.com/crowdcode-de/maven-war-plugin
这个问题让我非常恼火,以至于我修补了 war 插件以增加一个 disableOverlaying 参数。你可以在这里找到它 - 从原版分叉出来:https: //github.com/crowdcode-de/maven-war-plugin