allegro / grunt-maven-plugin

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

maven-grunt-npm #57

Closed dbclkclk closed 9 years ago

dbclkclk commented 9 years ago

Trying to following the documentation https://github.com/allegro/grunt-maven-npm and it said there were properties file generated by this module.

_These tasks depend on properties file produced by grunt-maven-plugin, which contains paths and options derived from projects pom.xml_.

Not sure where these reside.

adamdubiel commented 9 years ago

It is created by grunt-maven-plugin and it resides in target-grunt, you don't need to worry about it at all. Actually if you just follow grunt-maven-plugin doc it should be enough, unless you have some specific problem - then maybe i can help you :)

dbclkclk commented 9 years ago

@adamdubiel Thanks for the reply. Just that within the Gruntfile.js there is gruntMavenProperties: grunt.file.readJSON('grunt-maven.json'),. So I figure this is referenced in the current directory as the Gruntfile.js (src/webapps/resources/js/Gruntfile.js). Also, I believe to populate grunt-maven.json, I need to get files referenced in whatever file is generated by maven-grunt-plugin.

Also I might be confuse where the actual work directory (where I should be making the modification to my frontend) reside. I believe it should be src/webapps/resources/js/.

How I understand the maven-grunt-plugin to work is that it actually copies resources from /src/webapps/resources/js/ to /target-grunt however, reading the maven-grunt-npm, is that it also copies from the webapp directory to target/grun (under mavenPrepare), why is that?

Also, again regardin

adamdubiel commented 9 years ago

Yeah, you are right - with grunt-maven-npm there is slight mix of concerns - on the one hand frontend (grunt) and backend (maven) should be separated, but then there is this magical grunt-maven.json that is generated by backend part. I didn't want to commit it to src/, since it's content might change and so i wanted to keep it generated per build. I agree that this might be misleading, but i didn't think of any better way to make it work - i'm open for suggestions.

As to the other part - mavenPrepare copies changed files. It slightly duplicates prepare phase of grunt-maven-plugin itself, but it was designed to be used together with grunt watch, so frontend resources are refreshed in target-grunt (and war) each time you change sth in src/webapp . I could not run maven each time something changes (since maven is terribly slow compared to grunt), so i needed to create a grunt task mimicking this behavior.

dbclkclk commented 9 years ago

@adamdubiel OK so the grunt-maven.json is added to src/main/webapp/resources/js dynamically and removed at the end of the build? If not, where does it actually exist at the end of the build cycle or maven phase?

Also, with the maen-grunt-plugin, it does not create a node_modules or bower_components in my webapps directory. It essentially creates those within the target-grunt/ directory?

dbclkclk commented 9 years ago

Answering my own question, grunt-maven.json is found in the target-grunt/ directory. Seems this is created during one of the maven-grunt-plugin's phase (npm, bower, etc). Also, node_modules or bower_components isn't created in the webapps directory. It's created in the target-grunt/ directory.

adamdubiel commented 9 years ago

Yes, thats exactly how it works. target-grunt is the working directory. Maven does not compile sources in src - it does so in target, grunt-maven compiles stuff in target-grunt.

It was 2am here when you posted additional question, couldn't get to it quicker ;)