2014-07-17 24 views
0

我剛剛在我的項目中添加了Maven加密,因此我的settings.xml文件中的所有密碼都已加密。當我嘗試做一個啓用Maven加密的Nexus訪問被拒絕

mvn clean install -DskipTests 

然後聯繫我的Nexus服務器的所有依存關係得到正確下載並生成成功。然而,當我通過只執行

mvn clean install 

然後運行測試以及何時開始測試階段和Maven嘗試聯繫紐帶,以獲得相關的測試依賴它似乎想承上啓下的訪問被拒絕,因爲如果surefire:test插件目標忽略了maven加密並嘗試使用錯誤的密碼連接到nexus。

樣本的例外是:

------------------------------------------------------- 

T E S T S 
------------------------------------------------------- 
Running com.activity.dashboard.DashboardActivityTest 
Downloading: org/robolectric/android-all/4.3_r2-robolectric-0/android-all-4.3_r2-robolectr 
ic-0.pom from repository nexus at http://xxx.xxx.xxx.xxx:7222/nexus/content/groups/public 
Access denied to: http://xxx.xxx.xxx.xxx:7222/nexus/content/groups/public/org/robolectric/a 
ndroid-all/4.3_r2-robolectric-0/android-all-4.3_r2-robolectric-0.pom 
[WARNING] Unable to get resource 'org.robolectric:android-all:pom:4.3_r2-robolectric-0' fr 
om repository nexus (http://xxx.xxx.xxx.xxx:7222/nexus/content/groups/public): Authorizatio 
n failed: Access denied to: http://xxx.xxx.xxx.xxx:7222/nexus/content/groups/public/org/rob 
olectric/android-all/4.3_r2-robolectric-0/android-all-4.3_r2-robolectric-0.pom 

編輯:

的settings.xml看起來是這樣的:

<settings> 

    <servers> 
     <server> 
      <id>nexus</id> 
      <username>maven</username> 
      <password>{encryptedpassword}</password> 
     </server> 
    </servers> 

    <mirrors> 
     <mirror> 
      <id>nexus</id> 
      <mirrorOf>*</mirrorOf> 
      <url>http://xxx.xxx.xxx.xxx:7222/nexus/content/groups/public</url> 
     </mirror> 
    </mirrors> 

    <profiles> 
     <profile> 
      <id>nexus</id> 
      <repositories> 
       <!--Overriding the central repo to allow snapshots.--> 
       <repository> 
        <id>central</id> 
        <!--Url will eventually get overridden by the mirror url.--> 
        <url>fake url</url> 
        <snapshots> 
         <enabled>true</enabled> 
        </snapshots> 
       </repository> 
      </repositories> 
     </profile> 
    </profiles> 

    <activeProfiles> 
     <activeProfile>nexus</activeProfile> 
    </activeProfiles> 

</settings> 

而且,我父母的pom.xml包含了配送管理部分可能相關:

<distributionManagement> 
    <snapshotRepository> 
     <uniqueVersion>true</uniqueVersion> 
     <id>nexus</id> 
     <name>Nexus Follower Snapshot Repository</name> 
     <url>http://xxx.xxx.xxx.xxx:7222/nexus/content/repositories/snapshots/</url> 
     <layout>default</layout> 
    </snapshotRepository> 
</distributionManagement> 

上傳和下載快照工作得很好。

+0

我們在工作中使用相同的設置,我們沒有這樣的問題。你確定你已經正確診斷了這個問題嗎?我們可以看到您的設置文件(當然,適當編輯)? –

+0

不太確定。問題是,只要我將settings.xml上的密碼更改爲未加密的密碼,那麼一切正常。 –

回答

0

有趣的是,在今天給加密另一個鏡頭之後,它只是沒有任何例外地工作。不知道是什麼原因造成了這種情況,可能是在Intellij中緩存的,甚至是Maven/Nexus版本。