]> git.argeo.org Git - gpl/argeo-slc.git/blob - maven/maven-argeo-qooxdoo-plugin/src/main/java/org/argeo/slc/maven/plugins/qooxdoo/GenerateMojo.java
Introduce generate goal
[gpl/argeo-slc.git] / maven / maven-argeo-qooxdoo-plugin / src / main / java / org / argeo / slc / maven / plugins / qooxdoo / GenerateMojo.java
1 package org.argeo.slc.maven.plugins.qooxdoo;
2
3 import java.io.File;
4
5 import org.apache.maven.plugin.AbstractMojo;
6 import org.apache.maven.plugin.MojoExecutionException;
7 import org.apache.maven.plugin.MojoFailureException;
8 import org.python.util.jython;
9
10 /**
11 * Calls Qooxdoo python tool chain
12 *
13 * @goal generate
14 * @execute goal="env"
15 */
16 public class GenerateMojo extends AbstractMojo {
17 /**
18 * The Qooxdoo build target.
19 *
20 * @parameter expression="${job}"
21 * @required
22 */
23 private String job;
24
25 /**
26 * The build directory.
27 *
28 * @parameter expression="${project.build.directory}"
29 * @required
30 */
31 private File buildDirectory;
32
33 /**
34 * The directory for the pom
35 *
36 * @parameter expression="${basedir}"
37 * @required
38 */
39 private File baseDir;
40
41 public void execute() throws MojoExecutionException, MojoFailureException {
42 try {
43 File jythonBase = new File(buildDirectory, "jython");
44 jythonBase.mkdirs();
45 System.setProperty("python.home", jythonBase.getCanonicalPath());
46
47 File generateScript = new File(baseDir, "generate.py");
48 // String[] jobArray = jobs.split(" ");
49 // String[] args = new String[jobArray.length + 1];
50 // args[0] = generateScript.getCanonicalPath();
51 // System.arraycopy(jobArray, 0, args, 1, jobArray.length);
52 String[] args = { generateScript.getCanonicalPath(), job };
53 getLog().info("Running Qooxdoo job: " + job + " ...");
54 jython.main(args);
55 getLog().info("Finished Qooxdoo job: " + job);
56 } catch (Exception e) {
57 throw new MojoExecutionException(
58 "Unexpected exception when running Jython", e);
59 }
60
61 }
62
63 }