我的 POM 文件包含构建前端版本的插件。但是,当我们运行 mvn clean install
时,它会运行前端 grunt
/npm exec
两次。如何避免多次执行?
感谢所有帮助。由于 grunt 构建需要时间,因此删除重复的运行将缩短构建时间。
<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>
最佳答案
我真的不知道为什么这可以解决问题,但是在将阶段从“生成源”更改为“进程类”之后,它现在只运行一次。
我在这里找到:Maven plugin executes multiple times during build某些目标可以执行某些生命周期,这就是为什么我尝试更改阶段来运行 Node 脚本。
关于node.js - Maven 前端构建在生成源阶段运行两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37574934/