找不到自定义 Maven 插件

Custom maven plugin not found

我有这个项目

+ 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安装mojo

问题: 如果我 运行 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]

他不是在寻找 bar,因为他甚至找不到 foo

运行

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

不要构建 bar,构建 foo! 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] ------------------------------------------------------------------------