]>
git.argeo.org Git - gpl/argeo-slc.git/blob - maven-argeo-qooxdoo-plugin/src/main/java/org/argeo/slc/maven/plugins/qooxdoo/GenerateMojo.java
1 package org
.argeo
.slc
.maven
.plugins
.qooxdoo
;
5 import org
.apache
.maven
.plugin
.AbstractMojo
;
6 import org
.apache
.maven
.plugin
.MojoExecutionException
;
7 import org
.apache
.maven
.plugin
.MojoFailureException
;
8 import org
.apache
.maven
.plugin
.logging
.Log
;
9 import org
.codehaus
.plexus
.util
.cli
.CommandLineException
;
10 import org
.codehaus
.plexus
.util
.cli
.CommandLineUtils
;
11 import org
.codehaus
.plexus
.util
.cli
.Commandline
;
12 import org
.codehaus
.plexus
.util
.cli
.StreamConsumer
;
15 * Calls Qooxdoo python tool chain
19 public class GenerateMojo
extends AbstractMojo
{
21 * The Qooxdoo build target.
23 * @parameter expression="${job}"
29 * Location of the qooxdoo sdk.
31 * @parameter expression="${qooxdooSdk}"
33 private String qooxdooSdk
= "src" + File
.separator
+ "main"
34 + File
.separator
+ "webapp" + File
.separator
+ "qooxdoo-0.8-sdk";
37 * The build directory.
39 * @parameter expression="${project.build.directory}"
42 private File buildDirectory
;
45 * The directory for the pom
47 * @parameter expression="${basedir}"
52 public void execute() throws MojoExecutionException
, MojoFailureException
{
54 // File jythonBase = new File(buildDirectory, "jython");
55 // jythonBase.mkdirs();
56 // System.setProperty("python.home", jythonBase.getCanonicalPath());
58 File generateScript
= new File(baseDir
.getPath() + File
.separator
59 + qooxdooSdk
+ File
.separator
+ "tool" + File
.separator
60 + "bin", "generator.py");
61 // String[] jobArray = jobs.split(" ");
62 // String[] args = new String[jobArray.length + 1];
63 // args[0] = generateScript.getCanonicalPath();
64 // System.arraycopy(jobArray, 0, args, 1, jobArray.length);
65 // String[] args = { "generate.py", job };
66 getLog().info("Running Qooxdoo job: " + job
+ " ...");
69 Commandline cl
= new Commandline();
71 if (File
.separatorChar
== '\\') {// win
72 File pythonBase
= new File(buildDirectory
, "python-win32")
74 cl
.setExecutable(pythonBase
.getPath() + File
.separator
77 cl
.setExecutable("python");
78 cl
.setWorkingDirectory(baseDir
.getCanonicalPath());
79 cl
.createArgument().setValue(generateScript
.getCanonicalPath());
80 cl
.createArgument().setValue(job
);
82 StreamConsumer stdout
= new StdoutConsumer(getLog());
83 StreamConsumer stderr
= new StderrConsumer(getLog());
85 int result
= CommandLineUtils
.executeCommandLine(cl
, stdout
,
88 throw new MojoExecutionException("Qooxdoo job returned: \'"
91 } catch (CommandLineException e
) {
92 throw new MojoExecutionException("Unable to run Qooxdoo job", e
);
94 getLog().info("Finished Qooxdoo job: " + job
);
96 } catch (Exception e
) {
97 throw new MojoExecutionException(
98 "Unexpected exception when running Jython", e
);
104 * Consumer to receive lines sent to stdout. The lines are logged as info.
106 private class StdoutConsumer
implements StreamConsumer
{
107 /** Logger to receive the lines. */
114 * The logger to receive the lines
116 public StdoutConsumer(Log log
) {
124 * The line to consume
126 public void consumeLine(String string
) {
132 * Consumer to receive lines sent to stderr. The lines are logged as
135 private class StderrConsumer
implements StreamConsumer
{
136 /** Logger to receive the lines. */
143 * The logger to receive the lines
145 public StderrConsumer(Log log
) {
153 * The line to consume
155 public void consumeLine(String string
) {