带有npm安装的exec maven插件
我尝试在我的项目中使用execmaven插件 这是密码带有npm安装的exec maven插件,maven,maven-plugin,Maven,Maven Plugin,我尝试在我的项目中使用execmaven插件 这是密码 <plugin> <artifactId>exec-maven-plugin</artifactId> <groupId>org.codehaus.mojo</groupId> <version>1.6.0</version> <executions
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<version>1.6.0</version>
<executions>
<execution>
<id>npm install</id>
<goals>
<goal>exec</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<executable>${node.directory}/${npm.executable}</executable>
<arguments>
<argument>install</argument>
</arguments>
<workingDirectory>src/main/angular2/tourism</workingDirectory>
<target>
<echo message="Npm install" />
</target>
</configuration>
</execution>
</executions>
</plugin>
你能帮帮我吗
我使用KnowFrontEndMaven插件
这是密码
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.6</version>
<configuration>
<workingDirectory>src/main/angular5/tourism</workingDirectory>
<!-- where to install npm -->
<installDirectory>src/main/angular5/tourisml</installDirectory>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<nodeVersion>v8.11.3</nodeVersion>
<npmVersion>6.3.0</npmVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<!-- Optional configuration which provides for running any npm command -->
<configuration>
<arguments>install</arguments>
<workingDirectory>src/main/angular5/tourism</workingDirectory>
</configuration>
</execution>
<execution>
<id>prod</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run-script build</arguments>
<workingDirectory>src/main/angular5/tourism</workingDirectory>
</configuration>
<phase>generate-resources</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<finalName>${project.artifactId}-${project.version}.zip</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>cfg-main-resources</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
<configuration>
<descriptors>
<descriptor>${basedir}/src/main/angular5/tourism/assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
通常我应该获得一个zip文件(${project.artifactId}-${project.version}.zip),我认为它失败了,因为其中没有文件。这是正确的吗?我建议您不要使用
exec-maven-plugin
,而是查看使用npm-install
构建节点源的方法
使用该插件,您不需要在您的计算机上安装npm
或node
:该插件自行管理所有内容,因此您不应该遇到类似command not found
的问题。类似以下的配置应该可以工作:
com.github.eirslett
前端maven插件
1.6
src/main/angular5/旅游
${project.build.directory}/install
安装节点和npm
安装节点和npm
v${node.version}
${npm.version}
npm安装
npm
安装
最后,我使用了前端maven插件
下面是pom.xml的摘录
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.6</version>
<configuration>
<workingDirectory>src/main/angular5/tourism</workingDirectory>
<!-- where to install npm -->
<installDirectory>temp</installDirectory>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<nodeVersion>v8.11.3</nodeVersion>
<npmVersion>6.3.0</npmVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<!-- Optional configuration which provides for running any npm command -->
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>prod</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run-script build</arguments>
</configuration>
<phase>generate-resources</phase>
</execution>
</executions>
</plugin>
com.github.eirslett
前端maven插件
1.6
src/main/angular5/旅游
临时雇员
安装节点和npm
安装节点和npm
产生资源
v8.11.3
6.3.0
npm安装
npm
安装
戳
npm
运行脚本生成
产生资源
感谢您的回答我已经安装了node,并将安装的文件夹移动到${project.baseUri}/node/下 这个错误现在已经解决了,我可以在命令提示符下使用下面的命令进行npm安装
c:\main\prjt\apphost_prjt>mvn frontend:npm
您好,我尝试使用前端maven插件,但我遇到了相同的问题(我获得了相同的目录结构):[ERROR]无法执行goal com.github.eirslett:ProjectTourism web上的前端maven插件:1.6:npm(npm安装):无法运行任务:“npm安装”失败。java.io.IOException:无法运行程序“/Users/admin/Application-Marwen/workspace/Tourism/Tourism-Web/src/main/angular5/Tourism/node/node”(目录“/Users/admin/Application-Marwen/workspace/Tourism/Tourism-Web/src/main/angular5/Tourism”):错误=2,没有此类文件或目录->[帮助1]@flamant刚刚用一个配置示例更新了答案如果你在公司代理的后面工作,那么前端maven插件将不是理想的,因为它会导致代理错误Shello norbjd,我在第一篇帖子中添加了更多信息,我建议你接受上面的答案,以便(1)其他人在查找内容时不会感到困惑,(2)在这里分享知识的人会感到感激。
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.4:single (cfg-main-resources) on project tourism-web: Failed to create assembly: Error creating assembly archive distribution: You must set at least one file. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.4:single (cfg-main-resources) on project tourism-web: Failed to create assembly: Error creating assembly archive distribution: You must set at least one file.
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.6</version>
<configuration>
<workingDirectory>src/main/angular5/tourism</workingDirectory>
<!-- where to install npm -->
<installDirectory>temp</installDirectory>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<nodeVersion>v8.11.3</nodeVersion>
<npmVersion>6.3.0</npmVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<!-- Optional configuration which provides for running any npm command -->
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>prod</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run-script build</arguments>
</configuration>
<phase>generate-resources</phase>
</execution>
</executions>
</plugin>
c:\main\prjt\apphost_prjt>mvn frontend:npm