Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to compile grunt project from maven?

I'm trying to execute grunt tasks from within maven without needing to install Node.js or anything. This is because I wan't my artifact to be packaged by Jenkins and I can't install Node.js on that machine.

I know that it's easy with npm and a few commands to get it working, but I also think that it should be easy to integrate with maven, the problem is that I don't know where to start since I'm new to npm.

like image 994
gfournier Avatar asked Feb 18 '13 18:02

gfournier


People also ask

Is grunt deprecated?

grunt. util. _ is deprecated and we highly encourage you to npm install lodash and var _ = require('lodash') to use lodash .

What maven compile do?

mvn compile: Compiles source code of the project. mvn test-compile: Compiles the test source code. mvn test: Runs tests for the project. mvn package: Creates JAR or WAR file for the project to convert it into a distributable format.


1 Answers

Yes, using the frontend-maven-plugin, you can compile Grunt projects via Maven (found via the NodeJS mailing list).

As the documentation points out, the plugin has the following features:

  • Let you keep your frontend and backend builds as separate as possible, by reducing the amount of interaction between them to the bare minimum; using only 1 plugin.
  • Let you use Node.js and its libraries in your build process without installing Node/NPM globally for your build system
  • Let you ensure that the version of Node and NPM being run is the same in every build environment

I've walked through the code and it's fairly simple. Thank goodness someone finally put this together; it's an elegant solution. The repository includes an example that uses a regular Gruntfile.js to invoke jshint analysis.

like image 57
blong Avatar answered Sep 25 '22 10:09

blong