[Buix-commits] r749 - in trunk/lutinjaxx/maven/src/main/java: jaxx org/codelutin/jaxx
Author: tchemit Date: 2008-07-22 15:35:13 +0000 (Tue, 22 Jul 2008) New Revision: 749 Added: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorGoal.java Removed: trunk/lutinjaxx/maven/src/main/java/jaxx/JaxxGeneratorGoal.java Log: move to our package org.codelutin.jaxx Deleted: trunk/lutinjaxx/maven/src/main/java/jaxx/JaxxGeneratorGoal.java =================================================================== --- trunk/lutinjaxx/maven/src/main/java/jaxx/JaxxGeneratorGoal.java 2008-07-21 13:21:26 UTC (rev 748) +++ trunk/lutinjaxx/maven/src/main/java/jaxx/JaxxGeneratorGoal.java 2008-07-22 15:35:13 UTC (rev 749) @@ -1,197 +0,0 @@ -/* *##% - * Copyright (C) 2007 - * JaxxPlugin, Code Lutin - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *##%*/ - -package jaxx; - -import jaxx.compiler.CompilerOptions; -import jaxx.compiler.JAXXCompiler; -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugin.logging.Log; -import org.codehaus.plexus.util.DirectoryScanner; - -import java.io.File; -import java.net.URL; - -/** - * Classe permettant de transformer des sources jaxx vers du source java. - * - * @author chemit - * @goal generate - * @phase process-resources - */ -public class JaxxGeneratorGoal extends AbstractMojo { - - /** - * @description R�pertoire sources des fichiers jaxx � g�n�rer. - * @parameter expression="${jaxx.src}" default-value="${basedir}/src/uimodel" - */ - protected File src; - /** - * @description R�pertoire de destination des fichiers � g�n�rer. - * @parameter expression="${jaxx.out}" default-value="${basedir}/target/gen/java" - */ - protected File out; - /** - * @description R�pertoire de destination des fichiers � compiler. - * @parameter expression="${jaxx.classOut}" default-value="${basedir}/target/test-classes" - */ - protected File classOut; - /** - * @description pour optimizer le code compil� ou g�n�r� ? - * @parameter expression="${jaxx.optimize}" default-value="false" - */ - protected boolean optimize; - - /** - * @description les options de la compilation - * @parameter expression="${jaxx.javaOpts}" - */ - protected String javaOpts = null; - - /** - * @description pour filter - * @parameter expression="${jaxx.includes}" - */ - protected String[] includes; - - /** - * @description verbose - * @parameter expression="${jaxx.verbose}" default-value="${maven.verbose}" - */ - protected boolean verbose; - - protected String[] files; - - private static final String[] INCLUDES = {"**\\/*.jaxx"}; - - public void execute() throws MojoExecutionException, MojoFailureException { - - DirectoryScanner ds; - ds = new DirectoryScanner(); - ds.setBasedir(getSrc()); - boolean noIncludes = includes == null || includes.length == 0; - ds.setIncludes(noIncludes ? INCLUDES : includes); - ds.scan(); - files = ds.getIncludedFiles(); - log.info("jaxx - found " + files.length + " file(s) to generate. "); - CompilerOptions options = toCompilerOptions(); - if (verbose) { - log.debug("classPath: " + options.getClassPath()); - log.debug("javaOut : " + options.getTargetDirectory()); - log.debug("classOut : " + options.getJavacTargetDirectory()); - log.debug("javacOpts: " + options.getJavacOpts()); - log.debug("optiomize: " + options.getOptimize()); - for (String file : files) { - log.debug(file); - } - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - log.debug(cl.toString()); - if (cl.getClass().getSimpleName().equals("RealmClassLoader")) { - try { - java.lang.reflect.Method m = cl.getClass().getDeclaredMethod("getURLs"); - m.setAccessible(true); - URL[] urls = (URL[]) m.invoke(cl); - - for (URL url : urls) { - log.debug("ulr in class loader " + url); - } - } catch (Exception e) { - log.warn("??? : " + e.getMessage(), e); - } - } - } - - if (!JAXXCompiler.compile(src, files, options)) { - throw new MojoFailureException("Aborting due to errors reported by jaxxc"); - } - } - - public CompilerOptions toCompilerOptions() { - CompilerOptions result = new CompilerOptions(); - result.setClassPath(getSrc().getPath()); - if (getJavaOpts() != null && !"".equals(getJavaOpts())) { - result.setJavacOpts(getJavaOpts()); - } - result.setKeepJavaFiles(true); - result.setOptimize(isOptimize()); - result.setJavacTargetDirectory(getClassOut()); - result.setTargetDirectory(getOut()); - return result; - } - - protected Log log = getLog(); - - public File getSrc() { - return src; - } - - public boolean isOptimize() { - return optimize; - } - - public File getOut() { - return out; - } - - public String getJavaOpts() { - return javaOpts; - } - - public File getClassOut() { - return classOut; - } - - public String[] getIncludes() { - return includes; - } - - public void setJavaOpts(String javaOpts) { - this.javaOpts = javaOpts; - } - - public void setOptimize(boolean optimize) { - this.optimize = optimize; - } - - public void setOut(File out) { - this.out = out; - } - - public void setClassOut(File classOut) { - this.classOut = classOut; - } - - public void setSrc(File src) { - this.src = src; - } - - public void setVerbose(boolean verbose) { - this.verbose = verbose; - } - - public void setIncludes(String[] includes) { - this.includes = includes; - } - - public String[] getFiles() { - return files; - } -} \ No newline at end of file Copied: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorGoal.java (from rev 740, trunk/lutinjaxx/maven/src/main/java/jaxx/JaxxGeneratorGoal.java) =================================================================== --- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorGoal.java (rev 0) +++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorGoal.java 2008-07-22 15:35:13 UTC (rev 749) @@ -0,0 +1,197 @@ +/* *##% + * Copyright (C) 2007 + * JaxxPlugin, Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +package org.codelutin.jaxx; + +import jaxx.compiler.CompilerOptions; +import jaxx.compiler.JAXXCompiler; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.logging.Log; +import org.codehaus.plexus.util.DirectoryScanner; + +import java.io.File; +import java.net.URL; + +/** + * Classe permettant de transformer des sources jaxx vers du source java. + * + * @author chemit + * @goal generate + * @phase process-resources + */ +public class JaxxGeneratorGoal extends AbstractMojo { + + /** + * @description R�pertoire sources des fichiers jaxx � g�n�rer. + * @parameter expression="${jaxx.src}" default-value="${basedir}/src/uimodel" + */ + protected File src; + /** + * @description R�pertoire de destination des fichiers � g�n�rer. + * @parameter expression="${jaxx.out}" default-value="${basedir}/target/gen/java" + */ + protected File out; + /** + * @description R�pertoire de destination des fichiers � compiler. + * @parameter expression="${jaxx.classOut}" default-value="${basedir}/target/test-classes" + */ + protected File classOut; + /** + * @description pour optimizer le code compil� ou g�n�r� ? + * @parameter expression="${jaxx.optimize}" default-value="false" + */ + protected boolean optimize; + + /** + * @description les options de la compilation + * @parameter expression="${jaxx.javaOpts}" + */ + protected String javaOpts = null; + + /** + * @description pour filter + * @parameter expression="${jaxx.includes}" + */ + protected String[] includes; + + /** + * @description verbose + * @parameter expression="${jaxx.verbose}" default-value="${maven.verbose}" + */ + protected boolean verbose; + + protected String[] files; + + private static final String[] INCLUDES = {"**\\/*.jaxx"}; + + public void execute() throws MojoExecutionException, MojoFailureException { + + DirectoryScanner ds; + ds = new DirectoryScanner(); + ds.setBasedir(getSrc()); + boolean noIncludes = includes == null || includes.length == 0; + ds.setIncludes(noIncludes ? INCLUDES : includes); + ds.scan(); + files = ds.getIncludedFiles(); + log.info("jaxx - found " + files.length + " file(s) to generate. "); + CompilerOptions options = toCompilerOptions(); + if (verbose) { + log.debug("classPath: " + options.getClassPath()); + log.debug("javaOut : " + options.getTargetDirectory()); + log.debug("classOut : " + options.getJavacTargetDirectory()); + log.debug("javacOpts: " + options.getJavacOpts()); + log.debug("optiomize: " + options.getOptimize()); + for (String file : files) { + log.debug(file); + } + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + log.debug(cl.toString()); + if (cl.getClass().getSimpleName().equals("RealmClassLoader")) { + try { + java.lang.reflect.Method m = cl.getClass().getDeclaredMethod("getURLs"); + m.setAccessible(true); + URL[] urls = (URL[]) m.invoke(cl); + + for (URL url : urls) { + log.debug("ulr in class loader " + url); + } + } catch (Exception e) { + log.warn("??? : " + e.getMessage(), e); + } + } + } + + if (!JAXXCompiler.compile(src, files, options)) { + throw new MojoFailureException("Aborting due to errors reported by jaxxc"); + } + } + + public CompilerOptions toCompilerOptions() { + CompilerOptions result = new CompilerOptions(); + result.setClassPath(getSrc().getPath()); + if (getJavaOpts() != null && !"".equals(getJavaOpts())) { + result.setJavacOpts(getJavaOpts()); + } + result.setKeepJavaFiles(true); + result.setOptimize(isOptimize()); + result.setJavacTargetDirectory(getClassOut()); + result.setTargetDirectory(getOut()); + return result; + } + + protected Log log = getLog(); + + public File getSrc() { + return src; + } + + public boolean isOptimize() { + return optimize; + } + + public File getOut() { + return out; + } + + public String getJavaOpts() { + return javaOpts; + } + + public File getClassOut() { + return classOut; + } + + public String[] getIncludes() { + return includes; + } + + public void setJavaOpts(String javaOpts) { + this.javaOpts = javaOpts; + } + + public void setOptimize(boolean optimize) { + this.optimize = optimize; + } + + public void setOut(File out) { + this.out = out; + } + + public void setClassOut(File classOut) { + this.classOut = classOut; + } + + public void setSrc(File src) { + this.src = src; + } + + public void setVerbose(boolean verbose) { + this.verbose = verbose; + } + + public void setIncludes(String[] includes) { + this.includes = includes; + } + + public String[] getFiles() { + return files; + } +} \ No newline at end of file
participants (1)
-
tchemit@users.labs.libre-entreprise.org