首页 > 解决方案 > 如何将附加参数从 maven build 传递到 npm

问题描述

我有一个连接 maven 版本 3.6、exec-maven-plugin 版本 1.6.0、npm 版本 6.13.4 的问题

我的 pom.xml 文件中的插件定义如下所示

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.6.0</version>
        <executions>
          <execution>
            <id>exec-npm-install</id>
            <phase>generate-sources</phase>
            <configuration>
              <executable>npm</executable>
              <workingDirectory>../my-frontend-app</workingDirectory>
              <arguments>
                <argument>run</argument>
                <argument>build</argument>
              </arguments>
            </configuration>
            <goals>
              <goal>exec</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

感谢这个插件,我能够在我的 maven 构建期间运行npm run build。

我有问题是使用这个插件将额外的参数传递给我的 npm 构建。我想在 maven 构建期间将应用程序版本从 pom.xml 传递给 my-frontend-app。

任何机构都可以帮助我吗?

标签: mavennpmparameter-passingnpm-scriptsexec-maven-plugin

解决方案


推荐阅读