]>
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 * Location of the qooxdoo sdk.
32 * @parameter expression="${qooxdooSdk}"
34 private String qooxdooSdk
= "src" + File
.separator
+ "main"
35 + File
.separator
+ "webapp" + File
.separator
+ "qooxdoo-0.8-sdk";
38 * The build directory.
40 * @parameter expression="${project.build.directory}"
43 private File buildDirectory
;
46 * The directory for the pom
48 * @parameter expression="${basedir}"
53 public void execute() throws MojoExecutionException
, MojoFailureException
{
55 // File jythonBase = new File(buildDirectory, "jython");
56 // jythonBase.mkdirs();
57 // System.setProperty("python.home", jythonBase.getCanonicalPath());
59 File generateScript
= new File(baseDir
.getPath() + File
.separator
60 + qooxdooSdk
+ File
.separator
+ "tool" + File
.separator
61 + "bin", "generator.py");
62 // String[] jobArray = jobs.split(" ");
63 // String[] args = new String[jobArray.length + 1];
64 // args[0] = generateScript.getCanonicalPath();
65 // System.arraycopy(jobArray, 0, args, 1, jobArray.length);
66 // String[] args = { "generate.py", job };
67 getLog().info("Running Qooxdoo job: " + job
+ " ...");
70 Commandline cl
= new Commandline();
72 if (File
.separatorChar
== '\\') {// win
73 File pythonBase
= new File(buildDirectory
, "python-win32")
75 cl
.setExecutable(pythonBase
.getPath() + File
.separator
78 cl
.setExecutable("python");
79 cl
.setWorkingDirectory(baseDir
.getCanonicalPath());
80 cl
.createArgument().setValue(generateScript
.getCanonicalPath());
81 cl
.createArgument().setValue(job
);
83 StreamConsumer stdout
= new StdoutConsumer(getLog());
84 StreamConsumer stderr
= new StderrConsumer(getLog());
86 int result
= CommandLineUtils
.executeCommandLine(cl
, stdout
,
89 throw new MojoExecutionException("Qooxdoo job returned: \'"
92 } catch (CommandLineException e
) {
93 throw new MojoExecutionException("Unable to run Qooxdoo job", e
);
95 getLog().info("Finished Qooxdoo job: " + job
);
97 } catch (Exception e
) {
98 throw new MojoExecutionException(
99 "Unexpected exception when running Jython", e
);
105 * Consumer to receive lines sent to stdout. The lines are logged as info.
107 private class StdoutConsumer
implements StreamConsumer
{
108 /** Logger to receive the lines. */
115 * The logger to receive the lines
117 public StdoutConsumer(Log log
) {
125 * The line to consume
127 public void consumeLine(String string
) {
133 * Consumer to receive lines sent to stderr. The lines are logged as
136 private class StderrConsumer
implements StreamConsumer
{
137 /** Logger to receive the lines. */
144 * The logger to receive the lines
146 public StderrConsumer(Log log
) {
154 * The line to consume
156 public void consumeLine(String string
) {