View Javadoc

1   package de.akquinet.innovation.play.maven;
2   
3   import org.apache.commons.exec.CommandLine;
4   import org.apache.commons.exec.DefaultExecutor;
5   import org.apache.maven.plugin.MojoExecutionException;
6   
7   import java.io.IOException;
8   
9   /**
10   * Launch the Play application in debug mode (play debug run)
11   *
12   * @goal debug
13   * @requiresProject false
14   * @requiresDependencyResolution provided
15   */
16  public class Play2DebugMojo extends AbstractPlay2Mojo {
17  
18      public void execute() throws MojoExecutionException {
19  
20          String line = getPlay2().getAbsolutePath();
21  
22          CommandLine cmdLine = CommandLine.parse(line);
23  
24          cmdLine.addArgument("debug");
25          cmdLine.addArguments(getPlay2SystemPropertiesArguments(), false);
26          cmdLine.addArgument("run");
27          DefaultExecutor executor = new DefaultExecutor();
28  
29          // As where not linked to a project, we can't set the working directory.
30          // So it will use the directory where mvn was launched.
31  
32          executor.setExitValue(0);
33          try {
34              executor.execute(cmdLine, getEnvironment());
35          } catch (IOException e) {
36              // Ignore.
37          }
38      }
39  }