2012-11-21 74 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插件;) –