问题描述
由于某些限制,我需要拥有一个完全脱机的Maven存储库.根据 http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException,仅在<pluginRepositories>
中搜索插件.所以我想知道如何配置Maven以在本地文件系统中查找插件.设置<url>
时,我尝试使用"file://"前缀,但这不起作用.
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
settings.xml
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>
推荐答案
最后,我发现了问题,在插件目录中有一个名为_maven.repositories的文件,删除该文件后,一切正常!
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://jira.codehaus.org/browse/MNG-5181
这篇关于如何设置Maven 3本地插件存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!