]>
git.argeo.org Git - gpl/argeo-slc.git/blob - maven-argeo-qooxdoo-plugin/src/main/java/org/argeo/slc/maven/plugins/qooxdoo/GenerateMojo.java
61988cbd0cbe8d6472f52ae173cd599ed850914a
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}" default-value="src/qooxdoo-sdk"
33 private String qooxdooSdk
;
36 * The build directory.
38 * @parameter expression="${project.build.directory}"
41 private File buildDirectory
;
44 * The directory for the pom
46 * @parameter expression="${basedir}"
51 public void execute() throws MojoExecutionException
, MojoFailureException
{
53 File generateScript
= new File(baseDir
.getPath() + File
.separator
54 + qooxdooSdk
+ File
.separator
+ "tool" + File
.separator
55 + "bin", "generator.py");
56 getLog().info("Running Qooxdoo job: " + job
+ " ...");
58 Commandline cl
= new Commandline();
60 cl
.setExecutable("python");// python needs to be installed
61 cl
.setWorkingDirectory(baseDir
.getCanonicalPath());
62 cl
.createArgument().setValue(generateScript
.getCanonicalPath());
63 cl
.createArgument().setValue(job
);
65 StreamConsumer stdout
= new StdoutConsumer(getLog());
66 StreamConsumer stderr
= new StderrConsumer(getLog());
68 int result
= CommandLineUtils
.executeCommandLine(cl
, stdout
,
71 throw new MojoExecutionException("Qooxdoo job returned: \'"
74 } catch (CommandLineException e
) {
75 throw new MojoExecutionException("Unable to run Qooxdoo job", e
);
77 getLog().info("Finished Qooxdoo job: " + job
);
79 } catch (Exception e
) {
80 throw new MojoExecutionException(
81 "Unexpected exception when running Python", e
);
87 * Consumer to receive lines sent to stdout. The lines are logged as info.
89 private class StdoutConsumer
implements StreamConsumer
{
90 /** Logger to receive the lines. */
97 * The logger to receive the lines
99 public StdoutConsumer(Log log
) {
107 * The line to consume
109 public void consumeLine(String string
) {
115 * Consumer to receive lines sent to stderr. The lines are logged as
118 private class StderrConsumer
implements StreamConsumer
{
119 /** Logger to receive the lines. */
126 * The logger to receive the lines
128 public StderrConsumer(Log log
) {
136 * The line to consume
138 public void consumeLine(String string
) {