I have a com.github.eirslett:frontend-maven-plugin
in my maven
project.
<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. Grade migration tool translates only dependencies but not plugins. Is there some examples, how can I use frontend-maven-plugin
in gradle
?
To convert Maven to Gradle, the only step is to run gradle init in the directory containing the POM. This will convert the Maven build to a Gradle build, generating a settings. gradle file and one or more build.
You can't use a Maven plugin as-is in Gradle; you'll have to port it to a Gradle plugin. How difficult this is depends on how many Maven APIs the plugin is using. Another strategy might be to call into Maven via Gradle's Exec task.
Short answer: yes. There's no conflict between having two independent build scripts for the same project, one in Maven and one in Gradle.
You may not find any example on how to use the frontend-maven-plugin
in Gradle, as it is dedicated to 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):
Integrate your frontend NPM/Yarn build into Gradle.
The usage and configuration seems close to your Maven configuration. 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. Below is a typical usage under Gradle 5.4 with NPM, taken from the docs:
// 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. The download, installation of Node/NPM/Yarn requires no declaration/configuration - except the version numbers, as well as the build tasks. Just provide the NPM/Yarn command line to clean/assemble/check your frontend.6.2.1
. So your initial configuration with 4.2.4
will require to migrate Node.Regards
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With