2015-09-10 135 views
0

我有這個項目自定義Maven插件沒有找到

+ foo 
    pom.xml 
    + bar 
    src/main/java/foo/mojo.java 
    pom.xml 

第二POM是:

<project> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>foo.bar</groupId> 
    <artifactId>mojo</artifactId> 
    <packaging>maven-plugin</packaging> 
    <parent> 
    <groupId>com</groupId> 
    <artifactId>foo</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <relativePath>..</relativePath> 
    </parent> 
    .... 
</project> 

mojo.java

public class Mojo extends AbstractMojo { 
    public void execute() throws MojoExecutionException, MojoFailureException { 
    System.out.print("Hi"); 
    } 
} 

然後我跑c:\workspace\foo\bar\mvn clean install安裝的魔力。

問題: 如果我運行c:\workspace\foo\bar\mvn foo.bar:mojo:1.0-SNAPSHOT:mojo它說:

[ERROR] Plugin foo.bar:Mojo:1.0-SNAPSHOT or one of its dependencies could not be resolved: Failed to read artifact descriptor for foo.bar:Mojo:1.0-SNAPSHOT: Could not find artifact foo:bar:pom:1.0-SNAPSHOT in repo.jenkins-ci.org (http://repo.jenkins-ci.org/public/) -> [Help 1] 
+0

你有沒有檢查root/parent pom info版本(應該是「1.0-SNAPSHOT」)? – boly38

+0

是的,我檢查了根/父母的pom。 –

回答

0

他是不是找酒吧,因爲他甚至無法找到FOO

運行

c:\workspace\foo\mvn clean install 
instead of 
c:\workspace\foo\bar\mvn clean install 

待辦事項不建吧,建富! Foo會自動建立吧!

C:\workspace\foo>mvn foo.bar:mojo:1.0-SNAPSHOT:mojo 
[INFO] Scanning for projects... 
[INFO] ------------------------------------------------------------------------ 
[INFO] Reactor Build Order: 
[INFO] 
[INFO] --- foo.bar:mojo:1.0-SNAPSHOT:mojo (default-cli) @ foo --- 
Hi 
[INFO] Finish. 
[INFO] 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- foo.bar:mojo:1.0-SNAPSHOT:mojo (default-cli) @ foo --- 
[INFO] ------------------------------------------------------------------------ 
[INFO] Reactor Summary: 
[INFO] 
[INFO] foo ................................................ SUCCESS [ 0.014 s] 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESS 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 08:30 min 
[INFO] Finished at: 2015-09-10T16:51:18+02:00 
[INFO] Final Memory: 20M/838M 
[INFO] ------------------------------------------------------------------------ 
+0

順便說一句:如果你有一個吞下插件的本地連接器,記得把連接器放到你的本地'settings.xml'的''中。 –