Improving a Maven flow with Node Tools

One of the big problems I had with @encuestame it was the time of deployment, now we have plenty of tools running in Node.js, but, how to run Node.js environment into Maven? Well, my best option was the frontend-maven-plugin (https://github.com/eirslett/frontend-maven-plugin). That plugin is able to run npm, bower and grunt task safely in your maven life cycle.

So, I would like to enumerate and how this has changed a lot of things giving to the project an infinite of tools that could be used in our flow.

Libraries and Optimisation

One of my first goal was get rid of SASS, yeah, not easy to integrate in a Maven flow, aside of some articles which try to help you to do a save conversion it couldn’t be a easy task. Well, there are a lot of help in github, a good example is grunt-scss2less. The conversion is not perfect, even worse using compass, but that has a easy solution, use lesshat. Now, we don’t need to keep CSS pre-converted in the project due to it’s being converted as a grunt task.

Minimize code it could be a hard task using Java, is slow, Node is faster, replace yuicompressor by UglifyJS was a easy task as well. Others sub-projects was moved back to @encuestame thanks to the use of Node, other example is the widget-enme, I’m using browserify to build small library to display embedded widgets.

Testing

That was another topic hard to solve, all the JS was being tested in different project, now use InternJS is easy thanks to the maven plugin. That gives to the project the possibility to be tested in each build whether via continues integration tool or executed locally.

Dependencies

Update dependencies was other headache, due the speed that some libraries are updated and keep that track is hard, I tried with git submodules or downloading manually some of them dependencies, but that’s is hard to maintain. Yeah, bower was the right way to do it, just adding other grunt task and

Obviously that’s much better, in that way we don’t need to save those resources in our codebase and leave to Bower do that for us.

Dojo Build

It’s still remain a Javascript running with Rhino in the Maven flow, it works pretty good but is insanely slow, in my computer doing the same task with node (dojo allows to do that but not in straightforward way maybe) takes only 2 o 3 minutes, however, the Java needs around 7 minutes to finish. There are some tools over there but without any updates for a long time and I thought the best was create some tool for my own purpose and others of course, work in progress until now.

Final configuration

Certainly the configuration is not hard to follow, this plugin makes everything easy, I think there are no reason to explain step by step the code speak himself.

I won’t say this was a hard task, the migration took some days but I can say it worth it, I reduced my build times from 20 minutes to 7 locally, the LESS conversion with grunt takes only some seconds and in development time that means a lot, especially if you have a limited time, the productivity always comes with the right use tools that you have or use everyday.