node.js - Maven 前端构建在生成源阶段运行两次

标签 node.js maven

我的 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/

相关文章:

node.js - 渲染EJS并保存到Redis

java.lang.ClassNotFoundException : com. sun.jersey.core.spi.factory.ResponseImpl REST-FUL Web 服务

angularjs - 我可以使用 html5 本地存储来存储用户身份验证 session 信息吗

javascript - 如何将被拒绝的 promise 转换为异常并将其从 Express 路由处理程序中抛出?

javascript - 访问node.js中另一个类的构造函数值

node.js - "libsass bindings not found. Try reinstalling node-sass"

java - IntelliJ Idea 不创建 manifest.mf、pom.xml、pom.properties

java - Android Maven 错过了 jar 中的类(class)

java - 缺少 Artifact org.springframework :spring-context:jar:${org. springframework-version}

java - 通过批处理文件运行 maven java 项目时忽略 log4j 属性