2016-05-12 76 views
0

我遇到Maven問題,不尊重我用戶的settings.xml文件中的<localRepository>值。Maven在用戶的settings.xml文件中忽略localrepository設置

我的環境是使用Chef配置的Vagrant實例。我已經使用廚師Maven cookbook安裝了Maven。

Maven的運行,除了一個事實,即它無視我在SSH用戶的settings.xml中定義的本地倉庫罰款:

[email protected]:/vagrant$ cat ~/.m2/settings.xml 
<?xml version="1.0" encoding="UTF-8"?> 

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> 

    <localRepository>/vagrant/.m2/repository</localRepository> 

</settings> 

正如你所看到的,我試圖之間共享本地資源庫主機操作系統,並通過將Maven的本地存儲庫作爲該文件夾下的子目錄中由主機操作系統和客戶機操作系統共享的客戶機操作系統:/vagrant/.m2/repository

然而,當我運行Maven與調試選項設置:mvn -X的Maven通知我它正確讀取settings.xml文件,但是對於一些原因不正確設置本地的資源庫:

[email protected]:/vagrant$ mvn -X 
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T16:41:47+00:00) 
Maven home: /usr/local/maven 
Java version: 1.8.0_65, vendor: Oracle Corporation 
Java home: /usr/lib/jvm/jdk1.8.0_65/jre 
Default locale: en_US, platform encoding: UTF-8 
OS name: "linux", version: "3.13.0-85-generic", arch: "amd64", family: "unix" 
[DEBUG] Created new class realm maven.api 
[DEBUG] Importing foreign packages into class realm maven.api 
[DEBUG] Imported: javax.enterprise.inject.* < plexus.core 
[DEBUG] Imported: javax.enterprise.util.* < plexus.core 
[DEBUG] Imported: javax.inject.* < plexus.core 
[DEBUG] Imported: org.apache.maven.* < plexus.core 
[DEBUG] Imported: org.apache.maven.artifact < plexus.core 
[DEBUG] Imported: org.apache.maven.classrealm < plexus.core 
[DEBUG] Imported: org.apache.maven.cli < plexus.core 
[DEBUG] Imported: org.apache.maven.configuration < plexus.core 
[DEBUG] Imported: org.apache.maven.exception < plexus.core 
[DEBUG] Imported: org.apache.maven.execution < plexus.core 
[DEBUG] Imported: org.apache.maven.execution.scope < plexus.core 
[DEBUG] Imported: org.apache.maven.lifecycle < plexus.core 
[DEBUG] Imported: org.apache.maven.model < plexus.core 
[DEBUG] Imported: org.apache.maven.monitor < plexus.core 
[DEBUG] Imported: org.apache.maven.plugin < plexus.core 
[DEBUG] Imported: org.apache.maven.profiles < plexus.core 
[DEBUG] Imported: org.apache.maven.project < plexus.core 
[DEBUG] Imported: org.apache.maven.reporting < plexus.core 
[DEBUG] Imported: org.apache.maven.repository < plexus.core 
[DEBUG] Imported: org.apache.maven.rtinfo < plexus.core 
[DEBUG] Imported: org.apache.maven.settings < plexus.core 
[DEBUG] Imported: org.apache.maven.toolchain < plexus.core 
[DEBUG] Imported: org.apache.maven.usability < plexus.core 
[DEBUG] Imported: org.apache.maven.wagon.* < plexus.core 
[DEBUG] Imported: org.apache.maven.wagon.authentication < plexus.core 
[DEBUG] Imported: org.apache.maven.wagon.authorization < plexus.core 
[DEBUG] Imported: org.apache.maven.wagon.events < plexus.core 
[DEBUG] Imported: org.apache.maven.wagon.observers < plexus.core 
[DEBUG] Imported: org.apache.maven.wagon.proxy < plexus.core 
[DEBUG] Imported: org.apache.maven.wagon.repository < plexus.core 
[DEBUG] Imported: org.apache.maven.wagon.resource < plexus.core 
[DEBUG] Imported: org.codehaus.classworlds < plexus.core 
[DEBUG] Imported: org.codehaus.plexus.* < plexus.core 
[DEBUG] Imported: org.codehaus.plexus.classworlds < plexus.core 
[DEBUG] Imported: org.codehaus.plexus.component < plexus.core 
[DEBUG] Imported: org.codehaus.plexus.configuration < plexus.core 
[DEBUG] Imported: org.codehaus.plexus.container < plexus.core 
[DEBUG] Imported: org.codehaus.plexus.context < plexus.core 
[DEBUG] Imported: org.codehaus.plexus.lifecycle < plexus.core 
[DEBUG] Imported: org.codehaus.plexus.logging < plexus.core 
[DEBUG] Imported: org.codehaus.plexus.personality < plexus.core 
[DEBUG] Imported: org.codehaus.plexus.util.xml.Xpp3Dom < plexus.core 
[DEBUG] Imported: org.codehaus.plexus.util.xml.pull.XmlPullParser < plexus.core 
[DEBUG] Imported: org.codehaus.plexus.util.xml.pull.XmlPullParserException < plexus.core 
[DEBUG] Imported: org.codehaus.plexus.util.xml.pull.XmlSerializer < plexus.core 
[DEBUG] Imported: org.eclipse.aether.* < plexus.core 
[DEBUG] Imported: org.eclipse.aether.artifact < plexus.core 
[DEBUG] Imported: org.eclipse.aether.collection < plexus.core 
[DEBUG] Imported: org.eclipse.aether.deployment < plexus.core 
[DEBUG] Imported: org.eclipse.aether.graph < plexus.core 
[DEBUG] Imported: org.eclipse.aether.impl < plexus.core 
[DEBUG] Imported: org.eclipse.aether.installation < plexus.core 
[DEBUG] Imported: org.eclipse.aether.internal.impl < plexus.core 
[DEBUG] Imported: org.eclipse.aether.metadata < plexus.core 
[DEBUG] Imported: org.eclipse.aether.repository < plexus.core 
[DEBUG] Imported: org.eclipse.aether.resolution < plexus.core 
[DEBUG] Imported: org.eclipse.aether.spi < plexus.core 
[DEBUG] Imported: org.eclipse.aether.transfer < plexus.core 
[DEBUG] Imported: org.eclipse.aether.version < plexus.core 
[DEBUG] Imported: org.slf4j.* < plexus.core 
[DEBUG] Imported: org.slf4j.helpers.* < plexus.core 
[DEBUG] Imported: org.slf4j.spi.* < plexus.core 
[DEBUG] Populating class realm maven.api 
[INFO] Error stacktraces are turned on. 
[DEBUG] Reading global settings from /usr/local/maven/conf/settings.xml 
[DEBUG] Reading user settings from /home/vagrant/.m2/settings.xml 
[DEBUG] Reading global toolchains from /usr/local/maven/conf/toolchains.xml 
[DEBUG] Reading user toolchains from /home/vagrant/.m2/toolchains.xml 
[DEBUG] Using local repository at /home/vagrant/.m2/repository 
[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10.0 for /home/vagrant/.m2/repository 

的Maven錯誤地設置了本地存儲庫的默認/home/vagrant/.m2/repository

我不認爲這是文件夾在客戶操作系統和主機操作系統之間共享的問題,因爲正在運行的mvn -Dmaven.repo.local=/vagrant/.m2/repository正常運行。

在這種情況下Maven會不會正確讀取或解釋用戶settings.xml文件?

回答

0

像往常一樣,解釋問題導致我找到答案的路徑。對於任何人在這篇文章中絆倒的問題是,Chef Maven Cookbook有一個默認屬性node['maven']['mavenrc']['opts'],它將/etc/mavenrc/的值設置爲-Dmaven.repo.local=$HOME/.m2/repository -Xmx384m(自Cookbook的2.2.0版本開始)。這覆蓋了我在用戶的settings.xml文件中執行的本地存儲庫的所有配置。

爲了解決這個問題我在配方的默認屬性改變了這個屬性的默認值文件attributes/default.rbdefault[maven][mavenrc][opts] = ''