这是我从Maven注入项目属性的方法
@Parameter(defaultValue = "${project}", readonly = true, required = true)
private MavenProject project;
当且仅当通过自动Eclipse Maven Builder构建时,代码抛出IllegallStateException。当我构建命令行或使用定义的运行配置时,没关系。
public void execute() throws MojoExecutionException {
if (project == null) {
throw new IllegalStateException();
}
}
这就是我映射自定义插件生命周期的方法
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>com.github.fracpete</groupId>
<artifactId>latex-maven-plugin</artifactId>
<versionRange>[1.4.3,)</versionRange>
<goals>
<goal>latex</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>true</runOnIncremental>
</execute>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
当通过Maven Project Builder m2e使用而不使用命令行或定义的运行配置时,项目是否为空是否有任何原因?