]>
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
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
20 public class GenerateMojo
extends AbstractMojo
{
22 * The Qooxdoo build target.
24 * @parameter expression="${job}"
30 * The build directory.
32 * @parameter expression="${project.build.directory}"
35 private File buildDirectory
;
38 * The directory for the pom
40 * @parameter expression="${basedir}"
45 public void execute() throws MojoExecutionException
, MojoFailureException
{
47 // File jythonBase = new File(buildDirectory, "jython");
48 // jythonBase.mkdirs();
49 // System.setProperty("python.home", jythonBase.getCanonicalPath());
51 File generateScript
= new File(baseDir
, "generate.py");
52 // String[] jobArray = jobs.split(" ");
53 // String[] args = new String[jobArray.length + 1];
54 // args[0] = generateScript.getCanonicalPath();
55 // System.arraycopy(jobArray, 0, args, 1, jobArray.length);
56 String
[] args
= { "generate.py", job
};
57 getLog().info("Running Qooxdoo job: " + job
+ " ...");
60 Commandline cl
= new Commandline();
62 if (File
.separatorChar
== '\\') {// win
63 File pythonBase
= new File(buildDirectory
, "python-win32")
65 cl
.setExecutable(pythonBase
.getPath() + File
.separator
68 cl
.setExecutable("python");
69 cl
.setWorkingDirectory(baseDir
.getCanonicalPath());
70 cl
.createArgument().setValue(generateScript
.getCanonicalPath());
71 cl
.createArgument().setValue(job
);
73 StreamConsumer stdout
= new StdoutConsumer(getLog());
74 StreamConsumer stderr
= new StderrConsumer(getLog());
76 int result
= CommandLineUtils
.executeCommandLine(cl
, stdout
,
79 throw new MojoExecutionException("Qooxdoo job returned: \'"
82 } catch (CommandLineException e
) {
83 throw new MojoExecutionException("Unable to run Qooxdoo job", e
);
85 getLog().info("Finished Qooxdoo job: " + job
);
87 } catch (Exception e
) {
88 throw new MojoExecutionException(
89 "Unexpected exception when running Jython", e
);
95 * Consumer to receive lines sent to stdout. The lines are logged as info.
97 private class StdoutConsumer
implements StreamConsumer
{
98 /** Logger to receive the lines. */
105 * The logger to receive the lines
107 public StdoutConsumer(Log log
) {
115 * The line to consume
117 public void consumeLine(String string
) {
123 * Consumer to receive lines sent to stderr. The lines are logged as
126 private class StderrConsumer
implements StreamConsumer
{
127 /** Logger to receive the lines. */
134 * The logger to receive the lines
136 public StderrConsumer(Log log
) {
144 * The line to consume
146 public void consumeLine(String string
) {