allegro / grunt-maven-plugin

Grunt + Maven integration done right
Other
213 stars 32 forks source link

Run grunt from root with local grunt-cli #5

Closed filaraujo closed 11 years ago

filaraujo commented 11 years ago

As of right now if I wish to use grunt from root with references to a root level node_modules, I need to do a good amount of configuration mischief - see below. Is this intended and if not is it possible to provide a useRoot flag that allows for root node_modules.

Use Case

When committing node_modules to a repo to prevent from asset fetching during the build process

File system

<!--
    not using the valid configuration, modified so
    that it has invalid configuration so it is kicks off grunt
    from root instead of gruntBuildDirectory
-->
<sourceDirectory>/src/main/node/</sourceDirectory>
<jsSourceDirectory>grunt</jsSourceDirectory>
<gruntBuildDirectory>target/grunt</gruntBuildDirectory>
<gruntExecutable>../../node_modules/grunt-cli/bin/grunt</gruntExecutable>
<runGruntWithNode>true</runGruntWithNode>
adamdubiel commented 11 years ago

Hm, first of all i am not convinced committing node_modules to repo is a good idea.

grunt-maven-plugin separates target-grunt/ from usual Maven target/ to minimize assert fetching. This way developer usually needs to download assets once, right after cloning project. If you are concerned about node_modules versions stability, use npm shrinkwrap.

If you have a valid case not to use this, we can try to solve the problem in some other way.

filaraujo commented 11 years ago

Thanks for the quick response. I reviewed shrinkwrap documentation would not help as our build environments have a security restriction that does not allow us to pull external resources (I do not entirely agree, but I understand the company's decision on the restriction).

I am open to any alternatives if possible.

adamdubiel commented 11 years ago

Okay, now i get it. Maybe you should invest in npm lazy deployed in internal network then? We can solve this problem now, but i guess it's kind of pain for any other project in your company. You probably have some Maven nexus, that's not so much different.

Anyway i know deploying any nice solution can take time, so let's try and solve this problem with local node_modules.

After some research i think the simplest solution is to include maven-juntion-plugin into your build. This plugin creates links (*nix ln -s). Using links you can cheat Grunt into thinking that he has all node modules in place. Configure maven-junction-plugin to run before grunt-maven-plugin and to create link from /.node_modules to /target/grunt/node_modules. Configure grunt-maven-plugin not to run npm install (just delete this goal from execution).

Let me know if it works for you. If it does i guess i might add support for this in 1.0.3 - its simple, elegant and does not ruin grunt-maven-plugin workflow.

filaraujo commented 11 years ago

Thank you very much!

adamdubiel commented 11 years ago

@filaraujo i just release 1.0.3 version which should fix your issue without need for additional tools.