Maven前端构build为生成源阶段运行两次

我的POM文件包含构build前端构build的插件。 但是,当我们运行mvn clean install它会运行两次前端grunt / npm exec 。 我如何避免多次执行?

所有的帮助表示赞赏。 由于grunt构build需要时间,删除重复的运行将缩短构build时间。

  <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.4.0</version> <executions> <execution> <id>exec-npm-install</id> <phase>generate-sources</phase> <configuration> <executable>npm</executable> <arguments> <argument>install</argument> </arguments> <workingDirectory>src/main/raw_ui</workingDirectory> </configuration> <goals> <goal>exec</goal> </goals> </execution> <execution> <id>exec-bower-install</id> <phase>generate-sources</phase> <configuration> <executable>bower</executable> <arguments> <argument>install</argument> </arguments> <workingDirectory>src/main/raw_ui</workingDirectory> </configuration> <goals> <goal>exec</goal> </goals> </execution> <execution> <id>exec-grunt</id> <phase>generate-sources</phase> <configuration> <executable>grunt</executable> <arguments> <argument>build</argument> <argument>-f</argument> </arguments> <workingDirectory>src/main/raw_ui</workingDirectory> </configuration> <goals> <goal>exec</goal> </goals> </execution> </executions> </plugin> 

我不知道为什么这样可以解决这个问题,但是从“生成源”到“stream程类”的阶段完成后,现在只运行一次。

我在这里find了: Maven插件在构build期间执行多次 ,某些目标可以执行某些生命周期,这就是为什么我试图改变阶段来运行节点脚本。