]>
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
.MojoExecutionException
;
6 import org
.apache
.maven
.plugin
.MojoFailureException
;
7 import org
.apache
.maven
.plugin
.logging
.Log
;
8 import org
.codehaus
.plexus
.util
.cli
.CommandLineException
;
9 import org
.codehaus
.plexus
.util
.cli
.CommandLineUtils
;
10 import org
.codehaus
.plexus
.util
.cli
.Commandline
;
11 import org
.codehaus
.plexus
.util
.cli
.StreamConsumer
;
14 * Calls Qooxdoo python tool chain
18 public class GenerateMojo
extends AbstractQooxdooMojo
{
20 * The Qooxdoo build target.
22 * @parameter expression="${job}"
27 public void execute() throws MojoExecutionException
, MojoFailureException
{
29 File generateScript
= new File(srcBase
+ File
.separator
30 + sdkDirName
+ File
.separator
+ "tool" + File
.separator
31 + "bin", "generator.py");
32 getLog().info("Running Qooxdoo job: " + job
+ " ...");
34 Commandline cl
= new Commandline();
36 cl
.setExecutable("python");// python needs to be installed
37 cl
.setWorkingDirectory(baseDir
.getCanonicalPath());
38 cl
.createArgument().setValue(generateScript
.getCanonicalPath());
39 cl
.createArgument().setValue(job
);
41 StreamConsumer stdout
= new StdoutConsumer(getLog());
42 StreamConsumer stderr
= new StderrConsumer(getLog());
44 int result
= CommandLineUtils
.executeCommandLine(cl
, stdout
,
47 throw new MojoExecutionException("Qooxdoo job returned: \'"
50 } catch (CommandLineException e
) {
51 throw new MojoExecutionException("Unable to run Qooxdoo job", e
);
53 getLog().info("Finished Qooxdoo job: " + job
);
55 } catch (Exception e
) {
56 throw new MojoExecutionException(
57 "Unexpected exception when running Python", e
);
63 * Consumer to receive lines sent to stdout. The lines are logged as info.
65 private class StdoutConsumer
implements StreamConsumer
{
66 /** Logger to receive the lines. */
73 * The logger to receive the lines
75 public StdoutConsumer(Log log
) {
85 public void consumeLine(String string
) {
91 * Consumer to receive lines sent to stderr. The lines are logged as
94 private class StderrConsumer
implements StreamConsumer
{
95 /** Logger to receive the lines. */
102 * The logger to receive the lines
104 public StderrConsumer(Log log
) {
112 * The line to consume
114 public void consumeLine(String string
) {