1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package de.akquinet.innovation.play.maven;
17
18 import org.apache.commons.exec.CommandLine;
19 import org.apache.commons.exec.DefaultExecutor;
20 import org.apache.commons.exec.ExecuteWatchdog;
21 import org.apache.maven.artifact.factory.ArtifactFactory;
22 import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
23 import org.apache.maven.artifact.repository.ArtifactRepository;
24 import org.apache.maven.artifact.resolver.ArtifactCollector;
25 import org.apache.maven.artifact.resolver.ArtifactResolver;
26 import org.apache.maven.plugin.MojoExecutionException;
27 import org.apache.maven.plugin.dependency.CopyDependenciesMojo;
28
29 import java.io.File;
30 import java.io.IOException;
31 import java.util.List;
32
33
34
35
36
37
38
39 public class Play2CompilationMojo
40 extends AbstractPlay2Mojo {
41
42
43 public void execute()
44 throws MojoExecutionException {
45
46 String line = getPlay2().getAbsolutePath();
47
48 CommandLine cmdLine = CommandLine.parse(line);
49 cmdLine.addArgument("compile");
50 DefaultExecutor executor = new DefaultExecutor();
51
52 if (timeout > 0) {
53 ExecuteWatchdog watchdog = new ExecuteWatchdog(timeout);
54 executor.setWatchdog(watchdog);
55 }
56
57 executor.setExitValue(0);
58 executor.setWorkingDirectory(project.getBasedir());
59 try {
60 executor.execute(cmdLine, getEnvironment());
61 } catch (IOException e) {
62 throw new MojoExecutionException("Error during compilation", e);
63 }
64 }
65 }