allegro / grunt-maven-plugin

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

grunt watch doesn't work #68

Open keithkml opened 9 years ago

keithkml commented 9 years ago

I'm trying to run mvn grunt:grunt -Dtarget=watch. It hangs at "waiting..." forever, even after I change source files.

$ mvn grunt:grunt -Dtarget=watch
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building server 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- grunt-maven-plugin:1.4.1:grunt (default-cli) @ server ---
[INFO] OS Name: Mac OS X
Running "clean:0" (clean) task
Cleaning "build"...OK
Running "clean:1" (clean) task
Cleaning "bin"...OK
Running "html2js:app" (html2js) task
Successfully converted 1 html templates to js.
Running "html2js:common" (html2js) task
Successfully converted 1 html templates to js.
Running "jshint:src" (jshint) task
>> 8 files lint free.
Running "jshint:test" (jshint) task
>> 2 files lint free.
Running "jshint:gruntfile" (jshint) task
>> 1 file lint free.
Running "jshint:globals" (jshint) task
>> 0 files lint free.
Running "sass:build" (sass) task
Running "concat:build_css" (concat) task
File "build/assets/whamsite-0.1.0.css" created.
Running "copy:build_app_assets" (copy) task
Created 3 directories, copied 90 files
Running "copy:build_vendor_assets" (copy) task
Running "copy:build_appjs" (copy) task
Copied 8 files
Running "copy:build_vendorjs" (copy) task
Copied 5 files
Running "copy:build_vendorcss" (copy) task
Running "index:build" (index) task
Running "karma:unit" (karma) task
Running "delta" task
Waiting...

Here's the relevant part of my pom.xml:

            <plugin>
                <groupId>pl.allegro</groupId>
                <artifactId>grunt-maven-plugin</artifactId>
                <version>1.4.1</version>
                <configuration>
                    <jsSourceDirectory>homepage</jsSourceDirectory>                    
                    <gruntExecutable>node_modules/grunt-cli/bin/grunt</gruntExecutable>
                    <runGruntWithNode>true</runGruntWithNode>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>create-resources</goal>
                            <goal>npm</goal>
                            <goal>bower</goal>
                            <goal>grunt</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

And my build.config.js:

module.exports = {
  build_dir: 'build',
  compile_dir: 'bin',

  app_files: {
    js: [ 'src/**/*.js', '!src/**/*.spec.js', '!src/assets/**/*.js' ],
    jsunit: [ 'src/**/*.spec.js' ],

    atpl: [ 'src/app/**/*.tpl.html' ],
    ctpl: [ 'src/common/**/*.tpl.html' ],

    html: [ 'src/index.html' ],
    less: 'src/less/main.less'
  },

  test_files: {
    js: [
      'vendor/angular-mocks/angular-mocks.js'
    ]
  },

  vendor_files: {
    js: [
      'vendor/jquery/dist/jquery.js',
      'vendor/angular/angular.js',
      'vendor/angular-bootstrap/ui-bootstrap-tpls.min.js',
      'vendor/angular-placeholders/angular-placeholders.js',
      'vendor/angular-ui-router/release/angular-ui-router.js',
      'vendor/angular-ui-utils/modules/route/route.js'
    ],
    css: [
    ],
    assets: [
    ]
  },
};

AND some relevant parts of my Gruntfile:

    mavenPrepare: {
      options: {
        resources: ['**']
      },
      prepare: {}
    },

    mavenDist: {
      options: {
        warName: 'server-1.0-SNAPSHOT',
        // See https://github.com/allegro/grunt-maven-npm/issues/4
        deliverables: ['bin/**', '!non-deliverable.js'],
        gruntDistDir: 'dist'
      },
      dist: {}
    },

    gruntMavenProperties: grunt.file.readJSON('grunt-maven.json'),

    watch: {
      maven: {
        files: ['<%= gruntMavenProperties.filesToWatch %>'],
        tasks: 'default'
      }
    },
keithkml commented 9 years ago

PS: I don't have a grunt-maven.json file - am I supposed to?

adamdubiel commented 9 years ago

You should have grunt-maven.json file generated automatically in your target-grunt. Just check if it's there. Then - do you load gruntMavenProperties in Gruntfile? (https://github.com/allegro/grunt-maven-npm#watch)

keithkml commented 9 years ago

Yes, you can see in the original post that I do indeed include gruntMavenProperties.

keithkml commented 9 years ago

here's target-grunt/grunt-maven.json

{
    "filesToWatch": "/Users/keith/Code/wham/server-new-website/src/main/webapp/homepage/**",
    "directoryToWatch": "/Users/keith/Code/wham/server-new-website/src/main/webapp/homepage",
    "projectRootPath": "/Users/keith/Code/wham/server-new-website",
    "targetPath": "/Users/keith/Code/wham/server-new-website/target",
    "sourceDirectory": "src/main/webapp",
    "jsSourceDirectory": "homepage",
    "filteredFiles": ["**/node_modules.tar"]
}
adamdubiel commented 9 years ago

Sorry, i missed that part :) Could you run this via vanilla Grunt from target-grunt with debug flag to see what watch task thinks it watches?

keithkml commented 9 years ago

Not sure I see a watch path...

$ grunt -d watch
Running "clean:0" (clean) task
[D] Task source: /Users/keith/Code/wham/server-new-website/target-grunt/node_modules/grunt-contrib-clean/tasks/clean.js
Cleaning "build"...OK

Running "clean:1" (clean) task
[D] Task source: /Users/keith/Code/wham/server-new-website/target-grunt/node_modules/grunt-contrib-clean/tasks/clean.js
Cleaning "bin"...OK

Running "html2js:app" (html2js) task
[D] Task source: /Users/keith/Code/wham/server-new-website/target-grunt/node_modules/grunt-html2js/tasks/html2js.js
Successfully converted 1 html templates to js.

Running "html2js:common" (html2js) task
[D] Task source: /Users/keith/Code/wham/server-new-website/target-grunt/node_modules/grunt-html2js/tasks/html2js.js
Successfully converted 1 html templates to js.

Running "jshint:src" (jshint) task
[D] Task source: /Users/keith/Code/wham/server-new-website/target-grunt/node_modules/grunt-contrib-jshint/tasks/jshint.js
>> 9 files lint free.

Running "jshint:test" (jshint) task
[D] Task source: /Users/keith/Code/wham/server-new-website/target-grunt/node_modules/grunt-contrib-jshint/tasks/jshint.js
>> 2 files lint free.

Running "jshint:gruntfile" (jshint) task
[D] Task source: /Users/keith/Code/wham/server-new-website/target-grunt/node_modules/grunt-contrib-jshint/tasks/jshint.js
>> 1 file lint free.

Running "jshint:globals" (jshint) task
[D] Task source: /Users/keith/Code/wham/server-new-website/target-grunt/node_modules/grunt-contrib-jshint/tasks/jshint.js
>> 0 files lint free.

Running "sass:build" (sass) task
[D] Task source: /Users/keith/Code/wham/server-new-website/target-grunt/node_modules/grunt-contrib-sass/tasks/sass.js

Running "concat:build_css" (concat) task
[D] Task source: /Users/keith/Code/wham/server-new-website/target-grunt/node_modules/grunt-contrib-concat/tasks/concat.js
File "build/assets/whamsite-0.1.0.css" created.

Running "copy:build_app_assets" (copy) task
[D] Task source: /Users/keith/Code/wham/server-new-website/target-grunt/node_modules/grunt-contrib-copy/tasks/copy.js
Created 3 directories, copied 90 files

Running "copy:build_vendor_assets" (copy) task
[D] Task source: /Users/keith/Code/wham/server-new-website/target-grunt/node_modules/grunt-contrib-copy/tasks/copy.js

Running "copy:build_appjs" (copy) task
[D] Task source: /Users/keith/Code/wham/server-new-website/target-grunt/node_modules/grunt-contrib-copy/tasks/copy.js
Copied 9 files

Running "copy:build_vendorjs" (copy) task
[D] Task source: /Users/keith/Code/wham/server-new-website/target-grunt/node_modules/grunt-contrib-copy/tasks/copy.js
Copied 5 files

Running "copy:build_vendorcss" (copy) task
[D] Task source: /Users/keith/Code/wham/server-new-website/target-grunt/node_modules/grunt-contrib-copy/tasks/copy.js

Running "index:build" (index) task
[D] Task source: /Users/keith/Code/wham/server-new-website/target-grunt/Gruntfile.js

Running "delta" task
[D] Task source: /Users/keith/Code/wham/server-new-website/target-grunt/node_modules/grunt-contrib-watch/tasks/watch.js
Waiting...
adamdubiel commented 9 years ago

grunt -v watch this will show you all paths

keithkml commented 9 years ago

Seems to me that the issue is that it's looking in target-grunt for changes, not in my original source dir.

Running "delta" task
[D] Task source: /Users/keith/Code/wham/server-new-website/target-grunt/node_modules/grunt-contrib-watch/tasks/watch.js
Waiting...Options: interrupt=false, nospawn=false, event=["all"], target=undefined, cwd="/Users/keith/Code/wham/server-new-website/target-grunt", cliArgs=["-d","-v"], livereload
Verifying property delta exists in config...OK
Verifying property delta.gruntfile.files exists in config...OK
Verifying property delta.jssrc.files exists in config...OK
Verifying property delta.assets.files exists in config...OK
Verifying property delta.html.files exists in config...OK
Verifying property delta.tpls.files exists in config...OK
Verifying property delta.sass.files exists in config...OK
Verifying property delta.jsunit.files exists in config...OK
Live reload server started on port: 35729
Watching Gruntfile.js for changes.
Watching src/index.html for changes.
Watching src/assets/2AAF1C_0_0.eot for changes.
Watching src/assets/2AAF1C_0_0.ttf for changes.
Watching src/assets/2AAF1C_0_0.woff for changes.
Watching src/assets/2AAF1C_10_0.eot for changes.
Watching src/assets/2AAF1C_10_0.ttf for changes.
Watching src/assets/2AAF1C_10_0.woff for changes.
Watching src/assets/2AAF1C_11_0.eot for changes.
Watching src/assets/2AAF1C_11_0.ttf for changes.
Watching src/assets/2AAF1C_11_0.woff for changes.
Watching src/assets/2AAF1C_12_0.eot for changes.
Watching src/assets/2AAF1C_12_0.ttf for changes.
Watching src/assets/2AAF1C_12_0.woff for changes.
Watching src/assets/2AAF1C_13_0.eot for changes.
Watching src/assets/2AAF1C_13_0.ttf for changes.
Watching src/assets/2AAF1C_13_0.woff for changes.
Watching src/assets/2AAF1C_14_0.eot for changes.
Watching src/assets/2AAF1C_14_0.ttf for changes.
Watching src/assets/2AAF1C_14_0.woff for changes.
Watching src/assets/2AAF1C_15_0.eot for changes.
Watching src/assets/2AAF1C_15_0.ttf for changes.
Watching src/assets/2AAF1C_15_0.woff for changes.
Watching src/assets/2AAF1C_1_0.eot for changes.
Watching src/assets/2AAF1C_1_0.ttf for changes.
Watching src/assets/2AAF1C_1_0.woff for changes.
Watching src/assets/2AAF1C_2_0.eot for changes.
Watching src/assets/2AAF1C_2_0.ttf for changes.
Watching src/assets/2AAF1C_2_0.woff for changes.
Watching src/assets/2AAF1C_3_0.eot for changes.
Watching src/assets/2AAF1C_3_0.ttf for changes.
Watching src/assets/2AAF1C_3_0.woff for changes.
Watching src/assets/2AAF1C_4_0.eot for changes.
Watching src/assets/2AAF1C_4_0.ttf for changes.
Watching src/assets/2AAF1C_4_0.woff for changes.
Watching src/assets/2AAF1C_5_0.eot for changes.
Watching src/assets/2AAF1C_5_0.ttf for changes.
Watching src/assets/2AAF1C_5_0.woff for changes.
Watching src/assets/2AAF1C_6_0.eot for changes.
Watching src/assets/2AAF1C_6_0.ttf for changes.
Watching src/assets/2AAF1C_6_0.woff for changes.
Watching src/assets/2AAF1C_7_0.eot for changes.
Watching src/assets/2AAF1C_7_0.ttf for changes.
Watching src/assets/2AAF1C_7_0.woff for changes.
Watching src/assets/2AAF1C_8_0.eot for changes.
Watching src/assets/2AAF1C_8_0.ttf for changes.
Watching src/assets/2AAF1C_8_0.woff for changes.
Watching src/assets/2AAF1C_9_0.eot for changes.
Watching src/assets/2AAF1C_9_0.ttf for changes.
Watching src/assets/2AAF1C_9_0.woff for changes.
Watching src/assets/2AAF1C_A_0.eot for changes.
Watching src/assets/2AAF1C_A_0.ttf for changes.
Watching src/assets/2AAF1C_A_0.woff for changes.
Watching src/assets/2AAF1C_B_0.eot for changes.
Watching src/assets/2AAF1C_B_0.ttf for changes.
Watching src/assets/2AAF1C_B_0.woff for changes.
Watching src/assets/2AAF1C_C_0.eot for changes.
Watching src/assets/2AAF1C_C_0.ttf for changes.
Watching src/assets/2AAF1C_C_0.woff for changes.
Watching src/assets/2AAF1C_D_0.eot for changes.
Watching src/assets/2AAF1C_D_0.ttf for changes.
Watching src/assets/2AAF1C_D_0.woff for changes.
Watching src/assets/2AAF1C_E_0.eot for changes.
Watching src/assets/2AAF1C_E_0.ttf for changes.
Watching src/assets/2AAF1C_E_0.woff for changes.
Watching src/assets/2AAF1C_F_0.eot for changes.
Watching src/assets/2AAF1C_F_0.ttf for changes.
Watching src/assets/2AAF1C_F_0.woff for changes.
Watching src/assets/README.md for changes.
Watching src/assets/_fonts.css for changes.
Watching src/assets/clients-section for changes.
Watching src/assets/colorsplotches-02.png for changes.
Watching src/assets/confused-section for changes.
Watching src/assets/feature_icons-01.png for changes.
Watching src/assets/feature_icons-02.png for changes.
Watching src/assets/feature_icons-03.png for changes.
Watching src/assets/feature_icons-04.png for changes.
Watching src/assets/feature_icons-05.png for changes.
Watching src/assets/feature_icons-06.png for changes.
Watching src/assets/feature_icons-07.png for changes.
Watching src/assets/feature_icons-08.png for changes.
Watching src/assets/feature_icons-09.png for changes.
Watching src/assets/feature_icons-10.png for changes.
Watching src/assets/feature_icons-11.png for changes.
Watching src/assets/feature_icons-12.png for changes.
Watching src/assets/feature_icons-13.png for changes.
Watching src/assets/clients-section/icon-x-nocircle.png for changes.
Watching src/assets/clients-section/info-button-hover.png for changes.
Watching src/assets/clients-section/info-button.png for changes.
Watching src/assets/clients-section/play-button-hover.png for changes.
Watching src/assets/clients-section/play-button.png for changes.
Watching src/assets/confused-section/features-pricing-icon.png for changes.
Watching src/assets/confused-section/lightshow-editor-icon.png for changes.
Watching src/assets/confused-section/live-events-icon.png for changes.
Watching src/app/about/about.tpl.html for changes.
Watching src/app/clients-section/clients-section.tpl.html for changes.
Watching src/app/confused-section/confused-section.tpl.html for changes.
Watching src/app/features-section/features-section.tpl.html for changes.
Watching src/app/home/home.tpl.html for changes.
Watching src/app/how-section/how-section.tpl.html for changes.
Watching src/app/signup-section/signup-section.tpl.html for changes.
Watching src/app/about/about.js for changes.
Watching src/app/app.js for changes.
Watching src/app/clients-section/clients-section.js for changes.
Watching src/app/confused-section/confused-section.js for changes.
Watching src/app/features-section/features-section.js for changes.
Watching src/app/home/home.js for changes.
Watching src/app/how-section/how-section.js for changes.
Watching src/app/signup-section/signup-section.js for changes.
Watching src/common/plusOne/plusOne.js for changes.
Watching src/app/clients-section/_clients-section.scss for changes.
Watching src/app/confused-section/_confused-section.scss for changes.
Watching src/app/features-section/_features-section.scss for changes.
Watching src/app/how-section/_how-section.scss for changes.
Watching src/app/signup-section/_signup-section.scss for changes.
Watching src/scss/_variables.scss for changes.
Watching src/scss/main.scss for changes.
Watching src/scss/bourbon/_bourbon-deprecated-upcoming.scss for changes.
Watching src/scss/bourbon/_bourbon.scss for changes.
Watching src/scss/bourbon/addons/_button.scss for changes.
Watching src/scss/bourbon/addons/_clearfix.scss for changes.
Watching src/scss/bourbon/addons/_directional-values.scss for changes.
Watching src/scss/bourbon/addons/_ellipsis.scss for changes.
Watching src/scss/bourbon/addons/_font-family.scss for changes.
Watching src/scss/bourbon/addons/_hide-text.scss for changes.
Watching src/scss/bourbon/addons/_html5-input-types.scss for changes.
Watching src/scss/bourbon/addons/_position.scss for changes.
Watching src/scss/bourbon/addons/_prefixer.scss for changes.
Watching src/scss/bourbon/addons/_retina-image.scss for changes.
Watching src/scss/bourbon/addons/_size.scss for changes.
Watching src/scss/bourbon/addons/_timing-functions.scss for changes.
Watching src/scss/bourbon/addons/_triangle.scss for changes.
Watching src/scss/bourbon/addons/_word-wrap.scss for changes.
Watching src/scss/bourbon/css3/_animation.scss for changes.
Watching src/scss/bourbon/css3/_appearance.scss for changes.
Watching src/scss/bourbon/css3/_backface-visibility.scss for changes.
Watching src/scss/bourbon/css3/_background-image.scss for changes.
Watching src/scss/bourbon/css3/_background.scss for changes.
Watching src/scss/bourbon/css3/_border-image.scss for changes.
Watching src/scss/bourbon/css3/_border-radius.scss for changes.
Watching src/scss/bourbon/css3/_box-sizing.scss for changes.
Watching src/scss/bourbon/css3/_calc.scss for changes.
Watching src/scss/bourbon/css3/_columns.scss for changes.
Watching src/scss/bourbon/css3/_filter.scss for changes.
Watching src/scss/bourbon/css3/_flex-box.scss for changes.
Watching src/scss/bourbon/css3/_font-face.scss for changes.
Watching src/scss/bourbon/css3/_font-feature-settings.scss for changes.
Watching src/scss/bourbon/css3/_hidpi-media-query.scss for changes.
Watching src/scss/bourbon/css3/_hyphens.scss for changes.
Watching src/scss/bourbon/css3/_image-rendering.scss for changes.
Watching src/scss/bourbon/css3/_keyframes.scss for changes.
Watching src/scss/bourbon/css3/_linear-gradient.scss for changes.
Watching src/scss/bourbon/css3/_perspective.scss for changes.
Watching src/scss/bourbon/css3/_placeholder.scss for changes.
Watching src/scss/bourbon/css3/_radial-gradient.scss for changes.
Watching src/scss/bourbon/css3/_transform.scss for changes.
Watching src/scss/bourbon/css3/_transition.scss for changes.
Watching src/scss/bourbon/css3/_user-select.scss for changes.
Watching src/scss/bourbon/functions/_assign.scss for changes.
Watching src/scss/bourbon/functions/_color-lightness.scss for changes.
Watching src/scss/bourbon/functions/_flex-grid.scss for changes.
Watching src/scss/bourbon/functions/_golden-ratio.scss for changes.
Watching src/scss/bourbon/functions/_grid-width.scss for changes.
Watching src/scss/bourbon/functions/_modular-scale.scss for changes.
Watching src/scss/bourbon/functions/_px-to-em.scss for changes.
Watching src/scss/bourbon/functions/_px-to-rem.scss for changes.
Watching src/scss/bourbon/functions/_strip-units.scss for changes.
Watching src/scss/bourbon/functions/_tint-shade.scss for changes.
Watching src/scss/bourbon/functions/_transition-property-name.scss for changes.
Watching src/scss/bourbon/functions/_unpack.scss for changes.
Watching src/scss/bourbon/helpers/_convert-units.scss for changes.
Watching src/scss/bourbon/helpers/_gradient-positions-parser.scss for changes.
Watching src/scss/bourbon/helpers/_is-num.scss for changes.
Watching src/scss/bourbon/helpers/_linear-angle-parser.scss for changes.
Watching src/scss/bourbon/helpers/_linear-gradient-parser.scss for changes.
Watching src/scss/bourbon/helpers/_linear-positions-parser.scss for changes.
Watching src/scss/bourbon/helpers/_linear-side-corner-parser.scss for changes.
Watching src/scss/bourbon/helpers/_radial-arg-parser.scss for changes.
Watching src/scss/bourbon/helpers/_radial-gradient-parser.scss for changes.
Watching src/scss/bourbon/helpers/_radial-positions-parser.scss for changes.
Watching src/scss/bourbon/helpers/_render-gradients.scss for changes.
Watching src/scss/bourbon/helpers/_shape-size-stripper.scss for changes.
Watching src/scss/bourbon/helpers/_str-to-num.scss for changes.
Watching src/scss/bourbon/settings/_asset-pipeline.scss for changes.
Watching src/scss/bourbon/settings/_prefixer.scss for changes.
Watching src/scss/bourbon/settings/_px-to-em.scss for changes.
Watching src/app/app.spec.js for changes.
Watching src/app/home/home.
adamdubiel commented 9 years ago

Hm, thats weird - see sandbox project - the output there shows:

Watching ../src/main/webapp/static for changes.
Watching ../src/main/webapp/static/bin for changes.
Watching ../src/main/webapp/static/test for changes.
Watching ../src/main/webapp/static/Gruntfile.js for changes.

Notice that it first goes up one ../src/... to watch files in src. Can you check if sandbox works for you?

keithkml commented 9 years ago

Yep, sandbox works great. What do you think the difference might be?

adamdubiel commented 9 years ago

I dont see much of a differemce, can you enter path for files to be watchhed manually and see if it catches the right files? Lets debug it step by step, first we rule out grun-maven.json fault.

keithkml commented 9 years ago

Sure, enter those paths where?

adamdubiel commented 9 years ago

Just enter path from filesToWatch property from grunt-maven.json to watch task files in gruntfile (instead of template).

adamdubiel commented 9 years ago

What i mean is to use:

watch: {
      maven: {
        files: ['/Users/keith/Code/wham/server-new-website/src/main/webapp/homepage/**'],
        tasks: 'default'
      }
    }

I couldn't write it while replying via mobile :)