title: Unable to execute mojo: Command execution failed. Process exited with an error: 3 when using maven grunt plugin on Angular 2 typescript
body: <p>My goal is to set up a maven springboot project with Typescript Angular 2 framework. Eventually after I hit command ("mvn install"), corresponding js files will get compiled from the ts files.</p>
  
  <p>This is the error I get after hitting that command.</p>
  
  <pre><code>[INFO] Compiling 2 source files to C:\workspace_angular\springbootAngular2\target\classes
  [INFO]
  [INFO] --- grunt-maven-plugin:1.0.2:grunt (compile) @ springbootAngular2 ---
  [INFO] OS Name: Windows 10
  Running "typescript:compile" (typescript) task
  The 'base_path' option will be obsoleted. Please use the 'basePath'.
  &gt;&gt; C:/workspace_angular/springbootAngular2/src/main/ts/app.component.ts(1,1):
  &gt;&gt; error TS1008: Unexpected token; 'module, class, interface, enum, import or statement' expected.
  &gt;&gt; C:/workspace_angular/springbootAngular2/src/main/ts/app.component.ts(1,25):
  &gt;&gt; error TS1005: ';' expected.
  &gt;&gt; C:/workspace_angular/springbootAngular2/src/main/ts/app.component.ts(2,1):
  &gt;&gt; error TS1001: Unexpected character "@".
  &gt;&gt; C:/workspace_angular/springbootAngular2/src/main/ts/app.component.ts(2,1):
  &gt;&gt; error TS1008: Unexpected token; 'module, class, interface, enum, import or statement' expected.
  Warning: Task "typescript:compile" failed. Use --force to continue.
  
  Aborted due to warnings.
  [INFO] ------------------------------------------------------------------------
  [INFO] BUILD FAILURE
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time: 03:01 min
  [INFO] Finished at: 2016-04-24T13:32:09-04:00
  [INFO] Final Memory: 29M/441M
  [INFO] ------------------------------------------------------------------------
  [ERROR] Failed to execute goal pl.allegro:grunt-maven-plugin:1.0.2:grunt (compile) on project springbootAngular2: Unable to execute mojo: Command execution failed. Process exited with an error: 3 (Exit value: 3) -&gt; [Help 1]
  org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal pl.allegro:grunt-maven-plugin:1.0.2:grunt (compile) on project springbootAngular2: Unable to execute mojo
          at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
          at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
          at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
          at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
          at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
          at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
          at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
          at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
          at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
          at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
          at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
          at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
          at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:498)
          at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
          at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
          at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
          at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
  Caused by: org.apache.maven.plugin.MojoExecutionException: Unable to execute mojo
          at org.twdata.maven.mojoexecutor.MojoExecutor.executeMojo(MojoExecutor.java:96)
          at pl.allegro.tdr.gruntmaven.AbstractExecutableMojo.execute(AbstractExecutableMojo.java:77)
          at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
          at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
          ... 20 more
  Caused by: org.apache.maven.plugin.MojoExecutionException: Command execution failed.
          at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:362)
          at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
          at org.twdata.maven.mojoexecutor.MojoExecutor.executeMojo(MojoExecutor.java:94)
          ... 23 more
  Caused by: org.apache.commons.exec.ExecuteException: Process exited with an error: 3 (Exit value: 3)
          at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:377)
          at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:160)
          at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:610)
          at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:352)
          ... 25 more
  [ERROR]
  [ERROR] Re-run Maven using the -X switch to enable full debug logging.
  [ERROR]
  [ERROR] For more information about the errors and possible solutions, please read the following articles:
  [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
  </code></pre>
  
  <p>I have 2 simple ts files to compile. I believe the ts codes are correct since they runs in the "npm way".</p>
  
  <p>And I will continue to share my configuration related to the matter.</p>
  
  <p><strong>springbootAngular2/package.json</strong></p>
  
  <pre><code>{
    "name": "springbootAngular2",
    "version": "0.0.1-SNAPSHOT",
    "devDependencies": {
      "concurrently": "^2.0.0",
      "lite-server": "^2.2.0",
      "typescript": "^1.8.10",
      "typings":"^0.7.12"
    },
    "devDependencies": {
      "grunt": "~0.4.1",
      "grunt-typescript": "~0.2.4",
      "grunt-contrib-clean": "~0.5.0",
      "grunt-contrib-jasmine": "~0.5.2",
      "grunt-contrib-yuidoc": "~0.5.0",
      "grunt-template-jasmine-istanbul": "~0.2.5",
      "grunt-template-jasmine-requirejs": "~0.1.7",
      "grunt-contrib-uglify": "~0.2.5",
      "angular2": "2.0.0-beta.15",
      "systemjs": "0.19.26",
      "es6-shim": "^0.35.0",
      "reflect-metadata": "0.1.2",
      "rxjs": "5.0.0-beta.2",
      "zone.js": "0.6.10"
    }
  }
  </code></pre>
  
  <p><strong>springbootAngular2/tsconfig.json</strong></p>
  
  <pre><code>{
    "compilerOptions": {
      "target": "es5",
      "module": "system",
      "moduleResolution": "node",
      "sourceMap": true,
      "emitDecoratorMetadata": true,
      "experimentalDecorators": true,
      "removeComments": false,
      "noImplicitAny": false
    },
    "exclude": [
      "node_modules",
      "typings/main",
      "typings/main.d.ts"
    ]
  }
  </code></pre>
  
  <p><strong>springbootAngular2/typings.json</strong></p>
  
  <pre><code>{
    "ambientDependencies": {
      "es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#7de6c3dd94feaeb21f20054b9f30d5dabc5efabd",
      "jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#7de6c3dd94feaeb21f20054b9f30d5dabc5efabd"
    }
  }
  </code></pre>
  
  <p><strong>springbootAngular2/Gruntfile.js</strong>  (code fragment for dir definition and typescript:compile part)</p>
  
  <pre><code>// define some directories to be used during build
  dir: {
  
      // location of all source files
      "source": "src",
  
      // location where TypeScript source files are located
      "source_ts": "src/main/ts",
      // location where TypeScript/Jasmine test files are located
      "source_test_ts": "src/test/ts",
  
      // location where all build files shall be placed
      "target": "target",
  
      // location to place (compiled) javascript files
      //Chrystian note: target file directory is changed
      "target_js": "target/js",
      //"target_js" : "src/main/resources/public/app",
      // location to place (compiles) javascript test files
      "target_test_js": "target/js-test",
      // location to place documentation, etc.
      "target_report": "target/report"
  },
  typescript: {
  
      // Compiles main code. Add declaration file files
      compile: {
          src: ['&lt;%= dir.source_ts %&gt;/**/*.ts'],
          dest: '&lt;%= dir.target_js %&gt;',
          options: {
              base_path: '&lt;%= dir.source_ts %&gt;',
              target: 'es5',
              declaration: true,
              comments: true,
              module: 'amd'
          }
      },
  
      // Compiles the tests (and the module code again so that import paths are working).
      compile_test: {
          src: ['&lt;%= dir.source_test_ts %&gt;/**/*.ts','&lt;%= dir.source_ts %&gt;/**/*.ts'],
          dest: '&lt;%= dir.target_test_js %&gt;',
          options: {
              base_path: '&lt;%= dir.source %&gt;',
              target: 'es5',
              module: 'amd'
          }
      }
  },
  </code></pre>
  
  <p>and the grunt plugin defined in the <strong>pom.xml</strong></p>
  
  <pre><code>            &lt;plugin&gt;
                  &lt;groupId&gt;pl.allegro&lt;/groupId&gt;
                  &lt;artifactId&gt;grunt-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;1.0.2&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;gruntBuildDirectory&gt;${project.build.directory}/grunt&lt;/gruntBuildDirectory&gt;
                  &lt;/configuration&gt;
                  &lt;executions&gt;
  
                      &lt;!--
                         Maven "validate" phase: Prepare everything that is required to run grunt
                      --&gt;
                      &lt;execution&gt;
                          &lt;id&gt;validate&lt;/id&gt;
                          &lt;phase&gt;validate&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;!--&lt;goal&gt;create-resources&lt;/goal&gt;--&gt;
                              &lt;goal&gt;npm&lt;/goal&gt;&lt;!-- setup grunt and plugin --&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
  
                      &lt;!--
                         Maven "compile" phase: Do the real stuff by running grunt with target "compile"
                      --&gt;
                      &lt;execution&gt;
                          &lt;id&gt;compile&lt;/id&gt;
                          &lt;phase&gt;compile&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;grunt&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;configuration&gt;
                              &lt;target&gt;compile&lt;/target&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
  .
  .
  </code></pre>
  
  <p>In addition, the folder <strong>typings</strong> did not get generated as it would under the "npm way".</p>
  
  <p>Hope the information is sufficient.</p>