【问题标题】:How to run npm script in maven which invokes rimraf, copyfiles and webpack commands如何在 maven 中运行调用 rimraf、copyfiles 和 webpack 命令的 npm 脚本
【发布时间】:2016-11-15 19:54:52
【问题描述】:

我的 package.json

中有以下脚本
"clean": "rimraf dist/*"
"copy": "copyfiles -f ./src/index.html ./src/favicon.ico ./dist"
"dist": "npm run copy & webpack --env=dist"

我希望在 Jenkins 中构建 maven 来执行 dist 脚本。 maven 需要哪些插件才能处理这个问题?因此,基本上 Jenkins 构建构建后端并捆绑 UI,并将 UI 工件复制到 Web 应用程序的 webapp 文件夹

【问题讨论】:

    标签: maven jenkins build npm webpack


    【解决方案1】:

    您可以使用 exec-maven-plugin 执行 npm,但您需要安装 npm 并在您的路径上可用:

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.3.2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <phase>initialize</phase>
                        <configuration>
                             <executable>cmd</executable>
                            <workingDirectory>${whatever Directory}</workingDirectory>
                            <arguments>
                                <argument>/C</argument>
                                <argument>npm</argument>
                                <argument>dist</argument>
                            </arguments>
                        </configuration>
                    </execution>
                 </executions>
            </plugin>
    

    【讨论】:

    • 当插件尝试执行 npm 时出现以下错误:CreateProcess 错误=193,%1 不是有效的 Win32 应用程序。文件夹正确,npm 从命令行运行良好
    猜你喜欢
    • 1970-01-01
    • 2021-07-22
    • 2018-02-05
    • 2016-08-28
    • 2020-11-28
    • 2017-05-10
    • 2019-11-30
    • 1970-01-01
    • 2023-01-17
    相关资源
    最近更新 更多