参数' project'目标......缺失或无效

时间:2015-10-26 07:36:45

标签: maven

假设您有插件,您在此配置了pom:

  <build>
    <plugins>
      <plugin>
        <groupId>com.github.vbmacher</groupId>
        <artifactId>cup-maven-plugin</artifactId>
        <version>1.0.1</version>
        <executions>
          <execution>
            <goals>
              <goal>generate</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>

当你建立时,你会收到这个错误:

$ mvn compile
...
[ERROR] Failed to execute goal com.github.vbmacher:cup-maven-plugin:1.0.1:generate (default) on project jac-core: The parameters 'project' for goal com.github.vbmacher:cup-maven-plugin:1.0.1:generate are missing or invalid -> [Help 1]

你不明白,因为你在一个项目中运行!

2 个答案:

答案 0 :(得分:0)

插件Mojo的项目声明如下:

/**
 * @parameter property="project"
 * @required
 */
private MavenProject project;

这显然是错误的,并且不使用您的项目来填充Mojo。所以我把它改成了以下内容:

/**
 * @parameter default-value="${project}"
 * @required
 */
private MavenProject project;

现在进展顺利: - )

答案 1 :(得分:-1)

如果您需要放置&lt;插件&gt; &lt; pluginManagement&gt;内的声明在你的pom中:

<build>
  <pluginManagement>
    <plugins>
      <plugin>
        <groupId>com.github.vbmacher</groupId>
        <artifactId>cup-maven-plugin</artifactId>
        <version>1.0.1</version>
        <executions>
          <execution>
            <goals>
              <goal>generate</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </pluginManagement>
</build>