Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Maven build仅安装一次节点,而不是每次_Maven_Gruntjs - Fatal编程技术网

使用Maven build仅安装一次节点,而不是每次

使用Maven build仅安装一次节点,而不是每次,maven,gruntjs,Maven,Gruntjs,我需要一个人帮忙 我正在使用grunt编译CSS/JS 我有一个问题,我的节点包是在每次构建时创建的,它在Jenkins中占用了很多空间。我也在使用maven前端插件 我希望最初只创建一次节点包,而不是在每个maven构建中再次创建 <id>grunt</id> <build> <plugins> <plugin>

我需要一个人帮忙

我正在使用grunt编译CSS/JS

我有一个问题,我的节点包是在每次构建时创建的,它在Jenkins中占用了很多空间。我也在使用maven前端插件

我希望最初只创建一次节点包,而不是在每个maven构建中再次创建

 <id>grunt</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <version>0.0.26</version>
                        <!-- optional -->
                        <configuration>
                            <workingDirectory>DIR
                            </workingDirectory>
                            <nodeVersion>v4.2.1</nodeVersion>
                            <npmVersion>3.5.1</npmVersion>
                            <installDirectory>node</installDirectory>
                        </configuration>
                      <executions>
                            <execution>
                                <id>node and npm install</id>
                                <goals>
                                    <goal>install-node-and-npm</goal>
                                </goals>
                                <configuration>
                                    <arguments>install</arguments>
                                    <installDirectory>node</installDirectory>
                                </configuration>
                            </execution>
                            <execution>
                                <id>npm install</id>
                                <goals>
                                    <goal>npm</goal>
                                </goals>
                                <configuration>
                                    <arguments>install</arguments>
                                    <installDirectory>node</installDirectory>
                                </configuration>
                            </execution>
                            <execution>
                                <id>grunt build</id>
                                <goals>
                                    <goal>grunt</goal>
                                </goals>
                                <configuration>
                                    <arguments>build</arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
grunt
com.github.eirslett
前端maven插件
0.0.26
迪尔
v4.2.1
3.5.1
节点
节点和npm安装
安装节点和npm
安装
节点
npm安装
npm
安装
节点
咕噜声
咕哝
建造
我们正在使用maven-p grunt进行构建。它正在为每个maven构建创建和安装节点

 <id>grunt</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <version>0.0.26</version>
                        <!-- optional -->
                        <configuration>
                            <workingDirectory>DIR
                            </workingDirectory>
                            <nodeVersion>v4.2.1</nodeVersion>
                            <npmVersion>3.5.1</npmVersion>
                            <installDirectory>node</installDirectory>
                        </configuration>
                      <executions>
                            <execution>
                                <id>node and npm install</id>
                                <goals>
                                    <goal>install-node-and-npm</goal>
                                </goals>
                                <configuration>
                                    <arguments>install</arguments>
                                    <installDirectory>node</installDirectory>
                                </configuration>
                            </execution>
                            <execution>
                                <id>npm install</id>
                                <goals>
                                    <goal>npm</goal>
                                </goals>
                                <configuration>
                                    <arguments>install</arguments>
                                    <installDirectory>node</installDirectory>
                                </configuration>
                            </execution>
                            <execution>
                                <id>grunt build</id>
                                <goals>
                                    <goal>grunt</goal>
                                </goals>
                                <configuration>
                                    <arguments>build</arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
对于全局拥有节点,我尝试使用maven-p grunt-g,但它不起作用

在GitHub小组中,我看到有人提到我们不能使用maven前端插件,所以我尝试了maven exec插件

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <executions>
      <execution>
        <id>prepare-dist-npm-runtime-dependency</id>
        <phase>prepare-package</phase>
        <goals>
          <goal>exec</goal>
        </goals>
        <configuration>
          <executable>node/node</executable>
          <workingDirectory>dist</workingDirectory>
          <arguments>
            <argument>../node/npm/cli.js</argument>
            <argument>install</argument>
            <argument>--production</argument>
          </arguments>
        </configuration>
      </execution>
    </executions>
  </plugin>

org.codehaus.mojo
execmaven插件
准备dist npm运行时依赖项
准备包装
执行官
节点/节点
距离
../node/npm/cli.js
安装
--生产
但我看不到它起作用。有人能帮助我们如何运行maven,让它在全局节点安装中工作,而不是在每个构建中安装节点吗


如果有任何其他建议只安装一次节点而不是全局安装,我们将不胜感激。

您不能使用
前端maven插件
全局安装节点或NPM。如果我们看一下,我们将看到插件的全部目的是能够在一个独立的环境中安装Node和NPM,只用于构建,而不影响机器的其余部分

节点/npm将仅在项目的本地“安装”。不会的 在整个系统上全局安装(并且不会干扰 已存在任何节点/npm安装。)

不打算取代Node-frontend的开发人员版本 开发人员仍将在笔记本电脑上安装Node,但后端 开发人员可以运行干净的构建,而无需在其上安装节点 电脑

不打算安装节点以供生产使用。节点使用率为 作为前端构建的一部分,运行常见的javascript任务 例如缩小、模糊、压缩、包装、测试 等等

您可以尝试使用两种不同的配置文件运行插件,一种用于安装,另一种用于安装后的日常使用。在下面的示例中,您应该能够通过运行以下命令来安装Node和NPM:

mvn clean install -PinstallNode
然后每次构建之后:

mvn clean install -PnormalBuild
或者因为默认情况下
normalBuild
设置为active,只需:

mvn clean install
请注意,安装目标不在日常配置文件中:

<profiles>
    <profile>
        <id>installNode</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>com.github.eirslett</groupId>
                    <artifactId>frontend-maven-plugin</artifactId>
                    <version>0.0.26</version>
                    <!-- optional -->
                    <configuration>
                        <workingDirectory>DIR</workingDirectory>
                        <nodeVersion>v4.2.1</nodeVersion>
                        <npmVersion>3.5.1</npmVersion>
                        <installDirectory>node</installDirectory>
                    </configuration>
                  <executions>
                        <execution>
                            <id>node and npm install</id>
                            <goals>
                                <goal>install-node-and-npm</goal>
                            </goals>
                            <configuration>
                                <arguments>install</arguments>
                                <installDirectory>node</installDirectory>
                            </configuration>
                        </execution>
                        <execution>
                            <id>npm install</id>
                            <goals>
                                <goal>npm</goal>
                            </goals>
                            <configuration>
                                <arguments>install</arguments>
                                <installDirectory>node</installDirectory>
                            </configuration>
                        </execution>
                        <execution>
                            <id>grunt build</id>
                            <goals>
                                <goal>grunt</goal>
                            </goals>
                            <configuration>
                                <arguments>build</arguments>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
    <profile>
        <id>normalBuild</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>com.github.eirslett</groupId>
                    <artifactId>frontend-maven-plugin</artifactId>
                    <version>0.0.26</version>
                    <!-- optional -->
                    <configuration>
                        <workingDirectory>DIR</workingDirectory>
                        <nodeVersion>v4.2.1</nodeVersion>
                        <npmVersion>3.5.1</npmVersion>
                        <installDirectory>node</installDirectory>
                    </configuration>
                    <executions>
                        <execution>
                            <id>grunt build</id>
                            <goals>
                                <goal>grunt</goal>
                            </goals>
                            <configuration>
                                <arguments>build</arguments>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

安装节点
com.github.eirslett
前端maven插件
0.0.26
迪尔
v4.2.1
3.5.1
节点
节点和npm安装
安装节点和npm
安装
节点
npm安装
npm
安装
节点
咕噜声
咕哝
建造
正常构建
真的
com.github.eirslett
前端maven插件
0.0.26
迪尔
v4.2.1
3.5.1