2013-11-27 76 views
17

我想在我的pom.xml使用onejar - Maven的插件:如何強制Sonatype Nexus更新?

<plugin> 
    <groupId>org.dstovall</groupId> 
    <artifactId>onejar-maven-plugin</artifactId> 
    <version>1.4.4</version> 
    <executions> 
     <execution> 
      <configuration> 
       <mainClass>com.exmaple.myproj.MpPort_MpSoapPort_Client</mainClass> 
       <onejarVersion>0.97</onejarVersion> 
       <attachToBuild>true</attachToBuild> 
       <classifier>onejar</classifier> 
      </configuration> 
      <goals> 
       <goal>one-jar</goal> 
      </goals> 
     </execution> 
    </executions> 
</plugin> 

<pluginRepositories> 
    <pluginRepository> 
     <id>onejar-maven-plugin.googlecode.com</id> 
     <url>http://onejar-maven-plugin.googlecode.com/svn/mavenrepo</url> 
    </pluginRepository> 
</pluginRepositories> 

但由於某些原因,試圖通過Eclipse Maven插件來構建它(Maven的安裝)導致生成錯誤:

Downloading: https://mynexus.example.com/nexus/content/repositories/central/org/dstovall/onejar-maven-plugin/1.4.4/onejar-maven-plugin-1.4.4.pom 
[INFO] Unable to find resource 'org.dstovall:onejar-maven-plugin:pom:1.4.4' in repository onejar-maven-plugin.googlecode.com (http://onejar-maven-plugin.googlecode.com/svn/mavenrepo) 
Downloading: https://mynexus.example.com/nexus/content/repositories/central/org/dstovall/onejar-maven-plugin/1.4.4/onejar-maven-plugin-1.4.4.pom 
[INFO] Unable to find resource 'org.dstovall:onejar-maven-plugin:pom:1.4.4' in repository central (http://repo1.maven.org/maven2) 
Downloading: https://mynexus.example.com/nexus/content/repositories/central/org/dstovall/onejar-maven-plugin/1.4.4/onejar-maven-plugin-1.4.4.pom 
[INFO] Unable to find resource 'org.dstovall:onejar-maven-plugin:pom:1.4.4' in repository central (http://repo1.maven.org/maven2) 
[INFO] ------------------------------------------------------------------------ 
[ERROR] BUILD ERROR 
[INFO] ------------------------------------------------------------------------ 
[INFO] Error building POM (may not be this project's POM). 


Project ID: org.dstovall:onejar-maven-plugin 

Reason: POM 'org.dstovall:onejar-maven-plugin' not found in repository: Unable to download the artifact from any repository 

    org.dstovall:onejar-maven-plugin:pom:1.4.4 

from the specified remote repositories: 
    Nexus (https://mynexus.example.com/nexus/content/repositories/central) 

for project org.dstovall:onejar-maven-plugin 

所以我手動下載onejar-maven-plugin.jar並通過命令行安裝它,我似乎得到一個類似的錯誤:

C:\Users\daniel\myproj>mvn install:install-file -Dfile=onejar-maven-plugin-1.4.4.jar -DgroupId=com.jolira -DartifactId=onejar-maven-plugin -Dversion=1.4.4 -Dpackaging=jar 
[INFO] Scanning for projects... 
Downloading: https://mynexus.example.com/nexus/content/repositories/central/org/dstovall/onejar-maven-plugin/1.4.4/onejar-maven-plugin-1.4.4.pom 
[INFO] Unable to find resource 'org.dstovall:onejar-maven-plugin:pom:1.4.4' in repository onejar-maven-plugin.googlecode.com (http://onejar-maven-plugin.googlecode.com/svn/mavenrepo) 
Downloading: https://mynexus.example.com/nexus/content/repositories/central/org/dstovall/onejar-maven-plugin/1.4.4/onejar-maven-plugin-1.4.4.pom 
[INFO] Unable to find resource 'org.dstovall:onejar-maven-plugin:pom:1.4.4' in repository central (http://repo1.maven.org/maven2) 
Downloading: https://mynexus.example.com/nexus/content/repositories/central/org/dstovall/onejar-maven-plugin/1.4.4/onejar-maven-plugin-1.4.4.pom 
[INFO] Unable to find resource 'org.dstovall:onejar-maven-plugin:pom:1.4.4' in repository central (http://repo1.maven.org/maven2) 
[INFO] ------------------------------------------------------------------------ 
[ERROR] BUILD ERROR 
[INFO] ------------------------------------------------------------------------ 
[INFO] Error building POM (may not be this project's POM). 


Project ID: org.dstovall:onejar-maven-plugin 

Reason: POM 'org.dstovall:onejar-maven-plugin' not found in repository: Unable to download the artifact from any repository 

    org.dstovall:onejar-maven-plugin:pom:1.4.4 

from the specified remote repositories: 
    Nexus (https://mynexus.example.com/nexus/content/repositories/central) 

for project org.dstovall:onejar-maven-plugin 

我的理解是,因爲我們有一個不包含特定神器的Nexus鏡像,事情會變得困惑。

所以我試着按照How to force Sonatype Nexus Regenerate/Reindex its Metadata上的說明,但是「瀏覽索引」標籤沒有這樣的上下文菜單!我們的Sonatype Nexus上的

enter image description here

我讀here說,「只的Nexus緩存向客戶要求的工件。所以,你需要設置你的項目勁歌要求適當的版本」。但是這正是我一直在做的 - 結果沒有任何變化。

我該如何擺脫這個「雞蛋&雞蛋」的情況,並得到這個onejar-maven-plugin版本。 1.4.4到我的Nexus鏡像中?

(或者,我怎麼讓它進入我的本地緩存的.m2?)

回答

20

您可以強制Maven的更新,並要求再次依賴即使本地回購包含有關文物的元數據是不可用的-U

mvn clean install -U 

應該工作。

此外,你應該改變你的settings.xml指向公共組,而不是直接中央回購。更多可以找到in the Nexus book

你應該注意到Central Repository沒有你正在嘗試使用的onejar插件。退房search results,看看groupId如何com.joilira而不是org.dstovall

而且更多,如果你真的想用從org.dstovallonejar插件,你應該添加URL http://onejar-maven-plugin.googlecode.com/svn/mavenrepo/作爲代理庫的Nexus,它添加​​到公共組然後在你的公共組中使用公共組

+0

我還想建議臨時註釋他的'settings.xml'中的''元素(作爲一種解決方法,至少將包放入他的本地'.m2'緩存),但後來發現你的洞察力更強:他的Nexus指向'com.jolira',而不是'com.dstoval'。 +1! – sfinja

+1

它的pom.xml文件有錯誤的引用。與Nexus無關.. –

+0

但是,如果你看他提供的截圖,他的Nexus確實指向了'nejar-maven-plugin',只是它來自'jolira',而不是'dstoval'。這不是導致他的Maven安裝失敗的原因嗎? – sfinja