如何解决生命周期配置未涵盖的插件执行:org.codehaus.mojo:exec-maven- plugin:1.5.0:exec?

时间:2017-06-02 07:15:03

标签: maven eclipse-plugin

我使用maven将角度应用程序与java结合起来。 pom的一部分看起来像这样

<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.5.0</version>
            <executions>
                <execution>
                    <id>exec-npm-install</id>
                    <phase>generate-sources</phase>
                    <configuration>
                        <workingDirectory>${project.basedir}/src/main/angular-app</workingDirectory>
                        <executable>npm.cmd</executable>
                        <arguments>
                            <argument>install</argument>
                        </arguments>
                    </configuration>
                    <goals>
                        <goal>exec</goal>
                    </goals>
                </execution>
                <execution>
                    <id>exec-npm-ng-build</id>
                    <phase>generate-sources</phase>
                    <configuration>
                        <workingDirectory>${project.basedir}/src/main/angular-app</workingDirectory>
                        <executable>ng.cmd</executable>
                        <arguments>
                            <argument>build</argument>
                            <argument>--base-href=/testangularmaven/src/main/webapp/angular_build/</argument>
                        </arguments>
                    </configuration>
                    <goals>
                        <goal>exec</goal>
                    </goals>

                </execution>

            </executions>
        </plugin>       

mvn包运行良好,项目在war文件中编译,但是eclipse说pom不正确。使用标签的解决方案pluginManagement不匹配,因为它不会执行命令。 如何修复eclipse的问题?

1 个答案:

答案 0 :(得分:0)

通过映射解决

<?xml version="1.0" encoding="UTF-8"?>
<lifecycleMappingMetadata>
    <pluginExecutions>
        <pluginExecution>
            <pluginExecutionFilter>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <versionRange>[1.5.0,)</versionRange>
                <goals>
                    <goal>exec</goal>
                </goals>
            </pluginExecutionFilter>
            <action>
                <execute />
            </action>
        </pluginExecution>
    </pluginExecutions>
</lifecycleMappingMetadata>