module.exports = function (grunt) {
  require('load-grunt-tasks')(grunt);

  grunt.initConfig({
    bower: {
      install: {
        options: {
          targetDir: 'app/lib',
          verbose: true
        }
      }
    },
    copy: {
      closureLibrary: {
        files: [
          {
            expand: true,
            cwd: 'node_modules/',
            src: [
              'google-closure-library/closure/goog/**/*.js',
              'google-closure-library/third_party/closure/goog/**/*.js'
            ],
            dest: 'app/lib/'
          }
        ]
      }
    },
    shell: {
      buildDebug: {
        command: [
          'java -jar node_modules/google-closure-compiler/compiler.jar',

          '--only_closure_dependencies',
          '--closure_entry_point=KeepMeContributing',

          '--create_source_map=app/js/output.js.map',
          '--source_map_location_mapping=app\\|',
          '--output_wrapper "%output%\n//# sourceMappingURL=/js/output.js.map"',

          '--language_in=ECMASCRIPT6',
          '--language_out=ECMASCRIPT5_STRICT',

          '--jscomp_error=constantProperty',
          '--jscomp_error=const',
          '--jscomp_error=checkRegExp',
          '--warning_level=VERBOSE',
          '--jscomp_warning=checkDebuggerStatement',

          '--js=app/lib/google-closure-library/closure/goog/**.js',
          '--js=!app/lib/google-closure-library/closure/goog/**test.js',
          '--js=app/lib/google-closure-library/third_party/closure/goog/**.js',
          '--js=!app/lib/google-closure-library/third_party/closure/goog/**test.js',
          '--js=app/js/KeepMeContributing/**.js',
          '--js_output_file=app/js/app.js'
        ].join(' ')
      },
      testServer: { command: 'js-dev-server -S app/ -W app/ --port 9876' },
      lint: { command: 'eslint Gruntfile.js app/js/' }
    },
    watch: {
      buildDebug: {
        files: ['app/js/KeepMeContributing/*.js'],
        tasks: ['shell:buildDebug', 'notify:buildDebug'],
        options: { interrupt: true }
      }
    },
    notify: {
      buildDebug: {
        options: {
          title: 'buildDebug',
          message: 'Finished to build js/app.js.\nCheck the terminal to check for warnings.'
        }
      }
    }
  });

  grunt.registerTask('install', [
    'bower:install',
    'copy:closureLibrary'
  ]);
  grunt.registerTask('test', [
    'shell:buildDebug',
    'shell:testServer'
  ]);

  grunt.registerTask('default', [
    'shell:lint',
    'shell:buildDebug'
  ]);
};

@@ -1716,20 +1716,21 @@
 ,%0A      
-test
+build
 Server: 
@@ -1745,49 +1745,71 @@
 d: '
-js-dev-server -S app/ -W app/ --port 9876
+mvn compile' %7D,%0A      testServer: %7B command: 'foreman start web
 ' %7D,
@@ -2061,147 +2061,515 @@
    %7D
-%0A    %7D,%0A    notify: %7B%0A      buildDebug: %7B%0A        options: %7B%0A          title: 'buildDebug',%0A          message: 'Finished to build js/app.js
+,%0A      buildServer: %7B%0A        files: %5B'src/main/java/**/*.java'%5D,%0A        tasks: %5B'shell:buildServer', 'notify:buildServer'%5D,%0A        options: %7B interrupt: true %7D%0A      %7D%0A    %7D,%0A    notify: %7B%0A      buildDebug: %7B%0A        options: %7B%0A          title: 'buildDebug',%0A          message: 'Finished to build js/app.js.%5CnCheck the terminal to check for warnings.'%0A        %7D%0A      %7D,%0A      buildServer: %7B%0A        options: %7B%0A          title: 'buildServer',%0A          message: 'Finished to build the server application
 .%5CnC

add server build job