2012-11-21 40 views
10

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

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. 

[email protected]:> 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> 

+1

我不确定,但是这篇文章可能对您有所帮助:http://stackoverflow.com/questions/5141211/maven-without-remote-repository –

+0

您的配置无法正常工作,因为您正在定义源存储库与目标存储库(.m2 /存储库)相同。你需要有一个初始引导带从哪里开始,并且毕竟你的构建工作正常,你可以进行安装。 – khmarbaise

+0

hi khmarbaise,你能详细解释一下吗?你是什​​么意思“源代码库”?所需的插件已经在我的本地存储库中。我尝试删除settings.xml中除之外的所有行,但它也不起作用。 – SunLiWei

回答

4

由于Maven的3.1-α-1, 命令行选项-llr/--legacy-local-repository 或系统属性-Dmaven.legacyLocalRepo=true shoul d帮助

+0

不错的提示找到本地回购(文件系统)中的Maven插件;) –