[英]Migrate frontend-maven-plugin from maven to gradle
I have a com.github.eirslett:frontend-maven-plugin
in my maven
project. 我的
maven
项目中有一个com.github.eirslett:frontend-maven-plugin
。
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>0.0.27</version>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<phase>generate-resources</phase>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>bower install</id>
<goals>
<goal>bower</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<arguments>install</arguments>
<workingDirectory>${basedir}/src/main/webapp</workingDirectory>
</configuration>
</execution>
</executions>
<configuration>
<nodeVersion>v4.2.4</nodeVersion>
<npmVersion>2.7.1</npmVersion>
<nodeDownloadRoot>https://nodejs.org/dist/</nodeDownloadRoot>
<npmDownloadRoot>https://registry.npmjs.org/npm/-/</npmDownloadRoot>
<workingDirectory>${basedir}/src/main/webapp</workingDirectory>
</configuration>
</plugin>
Now I need to migrate it into gradle
but I can't find examples how to do it. 现在我需要将它迁移到
gradle
但我找不到示例如何做到这一点。 Grade migration tool translates only dependencies but not plugins. 成绩迁移工具仅转换依赖项,但不转换插件。 Is there some examples, how can I use
frontend-maven-plugin
in gradle
? 是否有一些例子,如何在
gradle
使用frontend-maven-plugin
?
Google found the Gradle Frontend Plugin for me. Google为我找到了Gradle Frontend插件 。 The plugin description simply says:
插件描述简单地说:
Set of tasks which wraps common frontend-tools and provide its binaries.
包含常见前端工具并提供其二进制文件的任务集。
The documentation (as at March 2016) describes the 4 tasks ( installnode
, npm
, grunt
and gulp
) and examples of their use. 文档(截至2016年3月)描述了4个任务(
installnode
, npm
, grunt
和gulp
)及其使用的例子。
An alternative (provided by @Timofei) is the Gradle Plugin for Node . 替代方案(由@Timofei提供)是节点的Gradle插件 。 The description says:
描述说:
This plugin enables you to use NodeJS-based technologies as part of your build without having NodeJS installed locally on your system.
此插件使您可以将基于NodeJS的技术用作构建的一部分,而无需在系统上本地安装NodeJS。 It integrates Gradle with NodeJS, Yarn, Grunt, and Gulp.
它将Gradle与NodeJS,Yarn,Grunt和Gulp集成在一起。
(Edited for clarity) (为清晰起见编辑)
Note that this plugin's Github repo is active while the previous one hasn't had any commits in the last two years. 请注意,此插件的Github存储库处于活动状态,而前一个存储库在过去两年中没有任何提交。
You may not find any example on how to use the frontend-maven-plugin
in Gradle, as it is dedicated to Maven. 您可能找不到任何关于如何在Gradle中使用
frontend-maven-plugin
示例,因为它专用于Maven。 But you may take a look at the Siouan Frontend Gradle plugin , which is an equivalent solution for Gradle, and allows to (from official website): 但是你可以看看Siouan Frontend Gradle插件 ,它是Gradle的等效解决方案,允许(来自官方网站):
Integrate your frontend NPM/Yarn build into Gradle.
将您的前端NPM / Yarn构建集成到Gradle中。
The usage and configuration seems close to your Maven configuration. 使用情况和配置似乎与Maven配置相近。 Define the Node/NPM/Yarn version in your
build.gradle
file, link the scripts you want to be run depending on the Gradle lifecycle task (clean/assemble/check), and that's all. 在
build.gradle
文件中定义Node / NPM / Yarn版本,根据Gradle生命周期任务(清理/汇编/检查)链接要运行的脚本,这就是全部。 Below is a typical usage under Gradle 5.4 with NPM, taken from the docs: 以下是使用NPM的Gradle 5.4下的典型用法,取自文档:
// build.gradle
plugins {
id 'org.siouan.frontend' version '1.1.0'
}
frontend {
nodeVersion = '10.15.3'
// See 'scripts' section in your 'package.json file'
cleanScript = 'run clean'
assembleScript = 'run assemble'
checkScript = 'run check'
}
You'll notice: 你会注意到:
frontend-maven-plugin
, there's no declaration/configuration to trigger the frontend build with Gradle, as it is already provided out of the box. frontend-maven-plugin
相反,没有声明/配置来触发使用Gradle构建前端,因为它已经开箱即用。 The download, installation of Node/NPM/Yarn requires no declaration/configuration - except the version numbers, as well as the build tasks. 6.2.1
. 6.2.1
。 So your initial configuration with 4.2.4
will require to migrate Node. 4.2.4
的初始配置将需要迁移Node。 Regards 问候
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.