Is it possible to compile grunt project from maven?

后端 未结 9 1269
滥情空心
滥情空心 2021-01-30 16:55

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

9条回答
  •  醉梦人生
    2021-01-30 17:24

    UPDATE 2014-09-19: This is no longer the most accurate answer - please take a look at some of the other answers below. It was accurate at the time when I answered the question, but there seems to have been a good deal of progress in this area since then.

    I'm afraid you're out of luck. Grunt is built using node and needs to be installed using npm. You might be able to copy an existing installation of Grunt from another machine if you don't want to use npm, but will still use the grunt executable and all of its dependencies on your build server.

    In addition to that, many of the Grunt tasks are implemented as Node.js modules, and you will have to install them as well. Again, you might be able to copy them from another server, where you've done the Node.js/Grunt installation, but at one point, you have to do it.

    For running Grunt from Maven, your best bet is to use the Maven exec plugin and then execute the grunt executable from there.

    As an alternative, there are several Maven plugins that allow you to do things similar to Grunt in a Java-based fashion. They require additional configuration not compatible with Grunt, so YMMV. One that I've used in the past is http://code.google.com/p/wro4j/, which comes with a Maven plugin as well: http://code.google.com/p/wro4j/wiki/MavenPlugin

    Any particular reason why you can't install Node.js on your build server?

提交回复
热议问题