Buix-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
July 2008
- 1 participants
- 124 discussions
r766 - trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx
by tchemit@users.labs.libre-entreprise.org 23 Jul '08
by tchemit@users.labs.libre-entreprise.org 23 Jul '08
23 Jul '08
Author: tchemit
Date: 2008-07-23 08:06:48 +0000 (Wed, 23 Jul 2008)
New Revision: 766
Modified:
trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractJaxxMojo.java
trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java
Log:
utilisation repertoire compatible maven
Modified: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractJaxxMojo.java
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractJaxxMojo.java 2008-07-22 22:33:28 UTC (rev 765)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractJaxxMojo.java 2008-07-23 08:06:48 UTC (rev 766)
@@ -45,13 +45,13 @@
/**
* @description R�pertoire de destination des fichiers java � g�n�rer.
- * @parameter expression="${jaxx.outJava}" default-value="${basedir}/gen/java"
+ * @parameter expression="${jaxx.outJava}" default-value="${basedir}/target/generated-sources/java"
*/
protected File outJava;
/**
* @description chemin du r�pertoire de g�n�ration des resources.
- * @parameter expression="${jaxx.outResource}" default-value="${basedir}/gen/resources"
+ * @parameter expression="${jaxx.outResource}" default-value="${basedir}/target/generated-sources/resources"
*/
protected File outResource;
Modified: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java 2008-07-22 22:33:28 UTC (rev 765)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java 2008-07-23 08:06:48 UTC (rev 766)
@@ -37,7 +37,7 @@
/**
* @description R�pertoire sources des fichiers jaxx � g�n�rer.
- * @parameter expression="${jaxx.src}" default-value="${basedir}/src/uimodel"
+ * @parameter expression="${jaxx.src}" default-value="${maven.src.dir}/main/uimodel"
*/
protected File src;
1
0
r765 - trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
22 Jul '08
Author: tchemit
Date: 2008-07-22 22:33:28 +0000 (Tue, 22 Jul 2008)
New Revision: 765
Modified:
trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorMojo.java
trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorMojo.java
trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorMojo.java
Log:
refactor goals
Modified: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorMojo.java
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorMojo.java 2008-07-22 22:17:54 UTC (rev 764)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorMojo.java 2008-07-22 22:33:28 UTC (rev 765)
@@ -14,6 +14,11 @@
*/
package org.codelutin.jaxx;
+import org.codelutin.util.FileUtil;
+
+import java.io.File;
+import java.io.IOException;
+
/** @author chemit */
public abstract class AbstractActionGeneratorMojo extends AbstractJaxxMojo {
@@ -29,4 +34,18 @@
*/
protected boolean copyToCP;
+ protected void copyResourceToCP(File file) throws IOException {
+
+ String path = file.getAbsolutePath().substring(outResource.getAbsolutePath().length() + 1);
+ File compiledFile = new File(outClass, path);
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("copy to classapth generated file " + compiledFile);
+ }
+ File parent = compiledFile.getParentFile();
+ if (!parent.exists()) {
+ parent.mkdirs();
+ }
+ FileUtil.copy(file, compiledFile);
+ }
+
}
Modified: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorMojo.java
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorMojo.java 2008-07-22 22:17:54 UTC (rev 764)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorMojo.java 2008-07-22 22:33:28 UTC (rev 765)
@@ -23,7 +23,6 @@
import org.codelutin.jaxx.action.ActionConfig;
import org.codelutin.jaxx.action.SelectActionConfig;
import org.codelutin.jaxx.action.ToggleActionConfig;
-import org.codelutin.util.FileUtil;
import org.codelutin.util.SortedProperties;
import java.io.File;
@@ -170,15 +169,7 @@
if (copyToCP) {
// save it also in classes
- File compiledFile = new File(outClass, actionsFile);
- if (getLog().isDebugEnabled()) {
- getLog().debug("copy to classapth generated file " + compiledFile);
- }
- parent = compiledFile.getParentFile();
- if (!parent.exists()) {
- parent.mkdirs();
- }
- FileUtil.copy(generatedFile, compiledFile);
+ copyResourceToCP(generatedFile);
}
}
Modified: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorMojo.java
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorMojo.java 2008-07-22 22:17:54 UTC (rev 764)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorMojo.java 2008-07-22 22:33:28 UTC (rev 765)
@@ -114,16 +114,7 @@
if (copyToCP) {
// save it also in classes (since we are in process-resources phase and resources has already been copied)
- String path = generatedProviderDeclaration.getAbsolutePath().substring(outResource.getAbsolutePath().length() + 1);
- File compiledFile = new File(outClass, path);
- if (getLog().isDebugEnabled()) {
- getLog().debug("copy to classapth generated file " + compiledFile);
- }
- File parent = compiledFile.getParentFile();
- if (!parent.exists()) {
- parent.mkdirs();
- }
- FileUtil.copy(generatedProviderDeclaration, compiledFile);
+ copyResourceToCP(generatedProviderDeclaration);
}
}
1
0
r764 - in trunk/lutinjaxx/maven/src: main/java/org/codelutin/jaxx test/java/org/codelutin/jaxx
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
22 Jul '08
Author: tchemit
Date: 2008-07-22 22:17:54 +0000 (Tue, 22 Jul 2008)
New Revision: 764
Added:
trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorMojo.java
trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorMojo.java
trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java
Removed:
trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorGoal.java
trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorGoal.java
trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorGoal.java
Modified:
trunk/lutinjaxx/maven/src/test/java/org/codelutin/jaxx/CompilerTest.java
Log:
refactor goals
Deleted: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorGoal.java
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorGoal.java 2008-07-22 22:17:15 UTC (rev 763)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorGoal.java 2008-07-22 22:17:54 UTC (rev 764)
@@ -1,267 +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 org.codelutin.jaxx;
-
-import org.codehaus.plexus.util.DirectoryScanner;
-import org.codelutin.jaxx.action.ActionConfig;
-import org.codelutin.jaxx.action.SelectActionConfig;
-import org.codelutin.jaxx.action.ToggleActionConfig;
-import org.codelutin.util.FileUtil;
-import org.codelutin.util.SortedProperties;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Properties;
-
-/**
- * Classe permettant de generer le fichier de propri�t�s des actions d�tect�es.
- *
- * @author chemit
- * @goal generate-actions-properties
- * @phase process-classes
- */
-public class ActionGeneratorGoal extends AbstractActionGeneratorMojo {
-
- /**
- * @description R�pertoire sources des fichiers java � traiter.
- * @parameter expression="${jaxx.src}" default-value="${basedir}/src/main/java"
- */
- protected File src;
-
- /**
- * @description pour filter
- * @parameter expression="${jaxx.includes}"
- */
- protected String[] includes;
-
- /**
- * @description pour filter
- * @parameter expression="${jaxx.excludes}"
- */
- protected String[] excludes;
-
- protected String[] files;
-
- protected URLClassLoader loader;
-
- private static final String[] INCLUDES = {"**\\/*.java"};
-
-
- protected void doExecute() throws Exception {
-
- if (verbose) {
- printInit();
- }
-
- Properties result = loadProperties();
-
-
- saveProperties(result);
-
- }
-
- protected Properties loadProperties() throws ClassNotFoundException {
- Properties result = new SortedProperties();
- for (String file : files) {
- String fqn = file.substring(0, file.length() - 5).replaceAll("\\/", ".");
-
- if (getLog().isDebugEnabled()) {
- getLog().debug("fqn to treate " + fqn);
- }
-
- Class<?> clazz = Class.forName(fqn, false, loader);
-
- // try a ActionConfig
- ActionConfig actionConfig = clazz.getAnnotation(ActionConfig.class);
- if (actionConfig != null) {
-
- if (actionConfig.multiNames().length > 0) {
- // multinames
- registerEntry(clazz, result, actionConfig.multiNames());
- continue;
- }
-
- if (!actionConfig.actionCommand().isEmpty()) {
- registerEntry(clazz, result, actionConfig.actionCommand());
- continue;
- }
-
- getLog().warn("could not treate class " + clazz);
- continue;
- }
-
- // try a SelectActionConfig
- SelectActionConfig selectActionConfig = clazz.getAnnotation(SelectActionConfig.class);
- if (selectActionConfig != null) {
- if (selectActionConfig.multiNames().length > 0) {
- // multinames
- registerEntry(clazz, result, selectActionConfig.multiNames());
- continue;
- }
-
- if (!selectActionConfig.actionCommand().isEmpty()) {
- registerEntry(clazz, result, selectActionConfig.actionCommand());
- continue;
- }
- getLog().warn("could not treate class " + clazz);
- continue;
- }
-
- // try a toggleAction
- ToggleActionConfig toggleActionConfig = clazz.getAnnotation(ToggleActionConfig.class);
- if (toggleActionConfig != null) {
- if (toggleActionConfig.multiNames().length > 0) {
- // multinames
- registerEntry(clazz, result, toggleActionConfig.multiNames());
- continue;
- }
-
- if (!toggleActionConfig.actionCommand().isEmpty()) {
- registerEntry(clazz, result, toggleActionConfig.actionCommand());
- continue;
- }
-
- getLog().warn("could not treate class " + clazz);
- }
-
- }
- return result;
- }
-
- protected void saveProperties(Properties result) throws IOException {
- OutputStream writer = null;
- File generatedFile = new File(outResource, actionsFile);
- File parent = generatedFile.getParentFile();
- if (!parent.exists()) {
- parent.mkdirs();
- }
- try {
- writer = new org.codelutin.util.PropertiesDateRemoveFilterStream(new java.io.FileOutputStream(generatedFile));
-
- result.store(writer, null);
-
-
- } finally {
- if (writer != null) {
- writer.flush();
- writer.close();
- }
- }
-
- if (copyToCP) {
- // save it also in classes
- File compiledFile = new File(outClass, actionsFile);
- if (getLog().isDebugEnabled()) {
- getLog().debug("copy to classapth generated file " + compiledFile);
- }
- parent = compiledFile.getParentFile();
- if (!parent.exists()) {
- parent.mkdirs();
- }
- FileUtil.copy(generatedFile, compiledFile);
- }
- }
-
-
- @Override
- protected void init() {
-
- super.init();
-
- DirectoryScanner ds;
- ds = new DirectoryScanner();
- ds.setBasedir(src);
- boolean noIncludes = includes == null || includes.length == 0;
- ds.setIncludes(noIncludes ? INCLUDES : includes);
- boolean noExcludes = excludes == null || excludes.length == 0;
- if (!noExcludes) {
- ds.setExcludes(excludes);
- }
- ds.scan();
- files = ds.getIncludedFiles();
-
- getLog().info("jaxx-actions - found " + files.length + " file(s) to treate. ");
-
- loader = initClassLoader(project, getLog());
- }
-
- protected void registerEntry(Class<?> clazz, Properties result, String... names) {
- for (String name : names) {
- if (getLog().isDebugEnabled()) {
- getLog().debug("name: " + name + ", class:" + clazz);
- }
- result.put("action." + name, clazz.getName());
- }
- }
-
- protected void printInit() {
-
- for (String file : files) {
- getLog().debug(file);
- }
-
- printCP();
- }
-
- protected void printCP() {
-
- getLog().debug(loader.toString());
-
- for (URL url : loader.getURLs()) {
- getLog().debug("url in class loader " + url);
- }
- }
-
- public File getSrc() {
- return src;
- }
-
- public void setSrc(File src) {
- this.src = src;
- }
-
- public String[] getIncludes() {
- return includes;
- }
-
- public void setIncludes(String[] includes) {
- this.includes = includes;
- }
-
- public String[] getExcludes() {
- return excludes;
- }
-
- public void setExcludes(String[] excludes) {
- this.excludes = excludes;
- }
-
- public String[] getFiles() {
- return files;
- }
-
- public void setFiles(String[] files) {
- this.files = files;
- }
-
-}
\ No newline at end of file
Copied: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorMojo.java (from rev 763, trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorGoal.java)
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorMojo.java (rev 0)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorMojo.java 2008-07-22 22:17:54 UTC (rev 764)
@@ -0,0 +1,267 @@
+/* *##%
+ * 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 org.codehaus.plexus.util.DirectoryScanner;
+import org.codelutin.jaxx.action.ActionConfig;
+import org.codelutin.jaxx.action.SelectActionConfig;
+import org.codelutin.jaxx.action.ToggleActionConfig;
+import org.codelutin.util.FileUtil;
+import org.codelutin.util.SortedProperties;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Properties;
+
+/**
+ * Classe permettant de generer le fichier de propri�t�s des actions d�tect�es.
+ *
+ * @author chemit
+ * @goal generate-actions-properties
+ * @phase process-classes
+ */
+public class ActionGeneratorMojo extends AbstractActionGeneratorMojo {
+
+ /**
+ * @description R�pertoire sources des fichiers java � traiter.
+ * @parameter expression="${jaxx.src}" default-value="${basedir}/src/main/java"
+ */
+ protected File src;
+
+ /**
+ * @description pour filter
+ * @parameter expression="${jaxx.includes}"
+ */
+ protected String[] includes;
+
+ /**
+ * @description pour filter
+ * @parameter expression="${jaxx.excludes}"
+ */
+ protected String[] excludes;
+
+ protected String[] files;
+
+ protected URLClassLoader loader;
+
+ private static final String[] INCLUDES = {"**\\/*.java"};
+
+
+ protected void doExecute() throws Exception {
+
+ if (verbose) {
+ printInit();
+ }
+
+ Properties result = loadProperties();
+
+
+ saveProperties(result);
+
+ }
+
+ protected Properties loadProperties() throws ClassNotFoundException {
+ Properties result = new SortedProperties();
+ for (String file : files) {
+ String fqn = file.substring(0, file.length() - 5).replaceAll("\\/", ".");
+
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("fqn to treate " + fqn);
+ }
+
+ Class<?> clazz = Class.forName(fqn, false, loader);
+
+ // try a ActionConfig
+ ActionConfig actionConfig = clazz.getAnnotation(ActionConfig.class);
+ if (actionConfig != null) {
+
+ if (actionConfig.multiNames().length > 0) {
+ // multinames
+ registerEntry(clazz, result, actionConfig.multiNames());
+ continue;
+ }
+
+ if (!actionConfig.actionCommand().isEmpty()) {
+ registerEntry(clazz, result, actionConfig.actionCommand());
+ continue;
+ }
+
+ getLog().warn("could not treate class " + clazz);
+ continue;
+ }
+
+ // try a SelectActionConfig
+ SelectActionConfig selectActionConfig = clazz.getAnnotation(SelectActionConfig.class);
+ if (selectActionConfig != null) {
+ if (selectActionConfig.multiNames().length > 0) {
+ // multinames
+ registerEntry(clazz, result, selectActionConfig.multiNames());
+ continue;
+ }
+
+ if (!selectActionConfig.actionCommand().isEmpty()) {
+ registerEntry(clazz, result, selectActionConfig.actionCommand());
+ continue;
+ }
+ getLog().warn("could not treate class " + clazz);
+ continue;
+ }
+
+ // try a toggleAction
+ ToggleActionConfig toggleActionConfig = clazz.getAnnotation(ToggleActionConfig.class);
+ if (toggleActionConfig != null) {
+ if (toggleActionConfig.multiNames().length > 0) {
+ // multinames
+ registerEntry(clazz, result, toggleActionConfig.multiNames());
+ continue;
+ }
+
+ if (!toggleActionConfig.actionCommand().isEmpty()) {
+ registerEntry(clazz, result, toggleActionConfig.actionCommand());
+ continue;
+ }
+
+ getLog().warn("could not treate class " + clazz);
+ }
+
+ }
+ return result;
+ }
+
+ protected void saveProperties(Properties result) throws IOException {
+ OutputStream writer = null;
+ File generatedFile = new File(outResource, actionsFile);
+ File parent = generatedFile.getParentFile();
+ if (!parent.exists()) {
+ parent.mkdirs();
+ }
+ try {
+ writer = new org.codelutin.util.PropertiesDateRemoveFilterStream(new java.io.FileOutputStream(generatedFile));
+
+ result.store(writer, null);
+
+
+ } finally {
+ if (writer != null) {
+ writer.flush();
+ writer.close();
+ }
+ }
+
+ if (copyToCP) {
+ // save it also in classes
+ File compiledFile = new File(outClass, actionsFile);
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("copy to classapth generated file " + compiledFile);
+ }
+ parent = compiledFile.getParentFile();
+ if (!parent.exists()) {
+ parent.mkdirs();
+ }
+ FileUtil.copy(generatedFile, compiledFile);
+ }
+ }
+
+
+ @Override
+ protected void init() {
+
+ super.init();
+
+ DirectoryScanner ds;
+ ds = new DirectoryScanner();
+ ds.setBasedir(src);
+ boolean noIncludes = includes == null || includes.length == 0;
+ ds.setIncludes(noIncludes ? INCLUDES : includes);
+ boolean noExcludes = excludes == null || excludes.length == 0;
+ if (!noExcludes) {
+ ds.setExcludes(excludes);
+ }
+ ds.scan();
+ files = ds.getIncludedFiles();
+
+ getLog().info("jaxx-actions - found " + files.length + " file(s) to treate. ");
+
+ loader = initClassLoader(project, getLog());
+ }
+
+ protected void registerEntry(Class<?> clazz, Properties result, String... names) {
+ for (String name : names) {
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("name: " + name + ", class:" + clazz);
+ }
+ result.put("action." + name, clazz.getName());
+ }
+ }
+
+ protected void printInit() {
+
+ for (String file : files) {
+ getLog().debug(file);
+ }
+
+ printCP();
+ }
+
+ protected void printCP() {
+
+ getLog().debug(loader.toString());
+
+ for (URL url : loader.getURLs()) {
+ getLog().debug("url in class loader " + url);
+ }
+ }
+
+ public File getSrc() {
+ return src;
+ }
+
+ public void setSrc(File src) {
+ this.src = src;
+ }
+
+ public String[] getIncludes() {
+ return includes;
+ }
+
+ public void setIncludes(String[] includes) {
+ this.includes = includes;
+ }
+
+ public String[] getExcludes() {
+ return excludes;
+ }
+
+ public void setExcludes(String[] excludes) {
+ this.excludes = excludes;
+ }
+
+ public String[] getFiles() {
+ return files;
+ }
+
+ public void setFiles(String[] files) {
+ this.files = files;
+ }
+
+}
\ No newline at end of file
Deleted: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorGoal.java
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorGoal.java 2008-07-22 22:17:15 UTC (rev 763)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorGoal.java 2008-07-22 22:17:54 UTC (rev 764)
@@ -1,152 +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 org.codelutin.jaxx;
-
-import org.codelutin.jaxx.action.ActionProvider;
-import org.codelutin.util.FileUtil;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * Classe permettant de generer un {@link org.codelutin.jaxx.action.ActionProvider} et son fichier de d�claration.
- *
- * @author chemit
- * @goal generate-actions-provider
- * @phase process-resources
- */
-public class ActionProviderGeneratorGoal extends AbstractActionGeneratorMojo {
-
- /**
- * @description FQN de la classe � g�n�rer.
- * @parameter expression="${jaxx.fqn}"
- * @required
- */
- protected String fqn;
-
- /**
- * @description nom logique du provider � g�n�rer.
- * @parameter expression="${jaxx.providerName}"
- * @required
- */
- protected String providerName;
-
- /**
- * @description FQN de la classe d'action � utiliser.
- * @parameter expression="${jaxx.fqnAction}"
- * @required
- */
- protected String fqnAction;
-
- /**
- * template of ActionProvider
- * $1 : package of class
- * $2 : simple name of class
- * $3 : abstract action fqn
- * $4 : path to actions properties file
- * $5 : provider name
- */
- protected static final String PROVIDER_TEMPLATE =
- "package %1$s;\n" +
- "\n" +
- "public class %2$s extends org.codelutin.jaxx.action.ActionProviderFromProperties<%3$s> {\n" +
- "\n" +
- " public %2$s() {\n" +
- " super(\"%5$s\", %3$s.class, \"%4$s\");\n" +
- " }\n" +
- "\n" +
- "}\n";
-
- protected File generateJavaProvider;
-
- protected File generatedProviderDeclaration;
-
-
- protected void doExecute() throws Exception {
-
- generateProvider();
-
- generateProviderDeclaration();
-
- }
-
- protected void generateProvider() throws IOException {
-
- int index = fqn.lastIndexOf(".");
- String packageJava = fqn.substring(0, index);
- String simpleJavaName = fqn.substring(index + 1);
-
- //TODO check if file was modified
- String content = String.format(PROVIDER_TEMPLATE,
- packageJava,
- simpleJavaName,
- fqnAction,
- actionsFile,
- providerName
- );
-
- FileUtil.writeString(generateJavaProvider, content);
- }
-
- protected void generateProviderDeclaration() throws IOException {
-
- //TODO check if file was modified
-
- // just add the fqn inside the file :)
- FileUtil.writeString(generatedProviderDeclaration, fqn);
-
- if (copyToCP) {
- // save it also in classes (since we are in process-resources phase and resources has already been copied)
- String path = generatedProviderDeclaration.getAbsolutePath().substring(outResource.getAbsolutePath().length() + 1);
- File compiledFile = new File(outClass, path);
- if (getLog().isDebugEnabled()) {
- getLog().debug("copy to classapth generated file " + compiledFile);
- }
- File parent = compiledFile.getParentFile();
- if (!parent.exists()) {
- parent.mkdirs();
- }
- FileUtil.copy(generatedProviderDeclaration, compiledFile);
- }
- }
-
- @Override
- protected void init() {
-
- super.init();
-
- generateJavaProvider = new File(outJava, fqn.replaceAll("\\.", java.io.File.separator) + ".java");
-
- File parent = generateJavaProvider.getParentFile();
- if (!parent.exists()) {
- parent.mkdirs();
- }
-
- generatedProviderDeclaration = new File(outResource, "META-INF/services/" + ActionProvider.class.getName());
- parent = generatedProviderDeclaration.getParentFile();
- if (!parent.exists()) {
- parent.mkdirs();
- }
-
- fixCompileSourceRoots();
-
- }
-
-}
\ No newline at end of file
Copied: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorMojo.java (from rev 763, trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorGoal.java)
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorMojo.java (rev 0)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorMojo.java 2008-07-22 22:17:54 UTC (rev 764)
@@ -0,0 +1,152 @@
+/* *##%
+ * 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 org.codelutin.jaxx.action.ActionProvider;
+import org.codelutin.util.FileUtil;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Classe permettant de generer un {@link org.codelutin.jaxx.action.ActionProvider} et son fichier de d�claration.
+ *
+ * @author chemit
+ * @goal generate-actions-provider
+ * @phase process-resources
+ */
+public class ActionProviderGeneratorMojo extends AbstractActionGeneratorMojo {
+
+ /**
+ * @description FQN de la classe � g�n�rer.
+ * @parameter expression="${jaxx.fqn}"
+ * @required
+ */
+ protected String fqn;
+
+ /**
+ * @description nom logique du provider � g�n�rer.
+ * @parameter expression="${jaxx.providerName}"
+ * @required
+ */
+ protected String providerName;
+
+ /**
+ * @description FQN de la classe d'action � utiliser.
+ * @parameter expression="${jaxx.fqnAction}"
+ * @required
+ */
+ protected String fqnAction;
+
+ /**
+ * template of ActionProvider
+ * $1 : package of class
+ * $2 : simple name of class
+ * $3 : abstract action fqn
+ * $4 : path to actions properties file
+ * $5 : provider name
+ */
+ protected static final String PROVIDER_TEMPLATE =
+ "package %1$s;\n" +
+ "\n" +
+ "public class %2$s extends org.codelutin.jaxx.action.ActionProviderFromProperties<%3$s> {\n" +
+ "\n" +
+ " public %2$s() {\n" +
+ " super(\"%5$s\", %3$s.class, \"%4$s\");\n" +
+ " }\n" +
+ "\n" +
+ "}\n";
+
+ protected File generateJavaProvider;
+
+ protected File generatedProviderDeclaration;
+
+
+ protected void doExecute() throws Exception {
+
+ generateProvider();
+
+ generateProviderDeclaration();
+
+ }
+
+ protected void generateProvider() throws IOException {
+
+ int index = fqn.lastIndexOf(".");
+ String packageJava = fqn.substring(0, index);
+ String simpleJavaName = fqn.substring(index + 1);
+
+ //TODO check if file was modified
+ String content = String.format(PROVIDER_TEMPLATE,
+ packageJava,
+ simpleJavaName,
+ fqnAction,
+ actionsFile,
+ providerName
+ );
+
+ FileUtil.writeString(generateJavaProvider, content);
+ }
+
+ protected void generateProviderDeclaration() throws IOException {
+
+ //TODO check if file was modified
+
+ // just add the fqn inside the file :)
+ FileUtil.writeString(generatedProviderDeclaration, fqn);
+
+ if (copyToCP) {
+ // save it also in classes (since we are in process-resources phase and resources has already been copied)
+ String path = generatedProviderDeclaration.getAbsolutePath().substring(outResource.getAbsolutePath().length() + 1);
+ File compiledFile = new File(outClass, path);
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("copy to classapth generated file " + compiledFile);
+ }
+ File parent = compiledFile.getParentFile();
+ if (!parent.exists()) {
+ parent.mkdirs();
+ }
+ FileUtil.copy(generatedProviderDeclaration, compiledFile);
+ }
+ }
+
+ @Override
+ protected void init() {
+
+ super.init();
+
+ generateJavaProvider = new File(outJava, fqn.replaceAll("\\.", java.io.File.separator) + ".java");
+
+ File parent = generateJavaProvider.getParentFile();
+ if (!parent.exists()) {
+ parent.mkdirs();
+ }
+
+ generatedProviderDeclaration = new File(outResource, "META-INF/services/" + ActionProvider.class.getName());
+ parent = generatedProviderDeclaration.getParentFile();
+ if (!parent.exists()) {
+ parent.mkdirs();
+ }
+
+ fixCompileSourceRoots();
+
+ }
+
+}
\ No newline at end of file
Deleted: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorGoal.java
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorGoal.java 2008-07-22 22:17:15 UTC (rev 763)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorGoal.java 2008-07-22 22:17:54 UTC (rev 764)
@@ -1,159 +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 org.codelutin.jaxx;
-
-import jaxx.compiler.CompilerOptions;
-import jaxx.compiler.JAXXCompiler;
-import org.apache.maven.plugin.MojoFailureException;
-import org.codehaus.plexus.util.DirectoryScanner;
-
-import java.io.File;
-
-/**
- * Classe permettant de transformer des sources jaxx vers du source java.
- *
- * @author chemit
- * @goal generate
- * @phase process-resources
- */
-public class JaxxGeneratorGoal extends AbstractJaxxMojo {
-
- /**
- * @description R�pertoire sources des fichiers jaxx � g�n�rer.
- * @parameter expression="${jaxx.src}" default-value="${basedir}/src/uimodel"
- */
- protected File src;
-
- /**
- * @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;
-
- protected String[] files;
-
- private static final String[] INCLUDES = {"**\\/*.jaxx"};
-
- protected CompilerOptions options;
-
- protected void init() {
- super.init();
-
- fixCompileSourceRoots();
-
- DirectoryScanner ds;
- ds = new DirectoryScanner();
- ds.setBasedir(src);
- boolean noIncludes = includes == null || includes.length == 0;
- ds.setIncludes(noIncludes ? INCLUDES : includes);
- ds.scan();
- files = ds.getIncludedFiles();
- getLog().info("jaxx - found " + files.length + " file(s) to generate. ");
- options = toCompilerOptions();
-
- if (verbose) {
- printInit();
- }
-
- }
-
- protected void doExecute() throws Exception {
- 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(src.getPath());
- if (javaOpts != null && !"".equals(javaOpts)) {
- result.setJavacOpts(javaOpts);
- }
- result.setKeepJavaFiles(true);
- result.setOptimize(optimize);
- result.setJavacTargetDirectory(outClass);
- result.setTargetDirectory(outJava);
- return result;
- }
-
- protected void printInit() {
- getLog().debug("classPath: " + options.getClassPath());
- getLog().debug("javaOut : " + options.getTargetDirectory());
- getLog().debug("outClass : " + options.getJavacTargetDirectory());
- getLog().debug("javacOpts: " + options.getJavacOpts());
- getLog().debug("optiomize: " + options.getOptimize());
- for (String file : files) {
- getLog().debug(file);
- }
- }
-
- public File getSrc() {
- return src;
- }
-
- public void setSrc(File src) {
- this.src = src;
- }
-
- public boolean isOptimize() {
- return optimize;
- }
-
- public void setOptimize(boolean optimize) {
- this.optimize = optimize;
- }
-
- public String getJavaOpts() {
- return javaOpts;
- }
-
- public void setJavaOpts(String javaOpts) {
- this.javaOpts = javaOpts;
- }
-
- public String[] getIncludes() {
- return includes;
- }
-
- public void setIncludes(String[] includes) {
- this.includes = includes;
- }
-
- public String[] getFiles() {
- return files;
- }
-
- public void setFiles(String[] files) {
- this.files = files;
- }
-
-}
\ No newline at end of file
Copied: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java (from rev 762, trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorGoal.java)
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java (rev 0)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java 2008-07-22 22:17:54 UTC (rev 764)
@@ -0,0 +1,159 @@
+/* *##%
+ * 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.MojoFailureException;
+import org.codehaus.plexus.util.DirectoryScanner;
+
+import java.io.File;
+
+/**
+ * Classe permettant de transformer des sources jaxx vers du source java.
+ *
+ * @author chemit
+ * @goal generate
+ * @phase process-resources
+ */
+public class JaxxGeneratorMojo extends AbstractJaxxMojo {
+
+ /**
+ * @description R�pertoire sources des fichiers jaxx � g�n�rer.
+ * @parameter expression="${jaxx.src}" default-value="${basedir}/src/uimodel"
+ */
+ protected File src;
+
+ /**
+ * @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;
+
+ protected String[] files;
+
+ private static final String[] INCLUDES = {"**\\/*.jaxx"};
+
+ protected CompilerOptions options;
+
+ protected void init() {
+ super.init();
+
+ fixCompileSourceRoots();
+
+ DirectoryScanner ds;
+ ds = new DirectoryScanner();
+ ds.setBasedir(src);
+ boolean noIncludes = includes == null || includes.length == 0;
+ ds.setIncludes(noIncludes ? INCLUDES : includes);
+ ds.scan();
+ files = ds.getIncludedFiles();
+ getLog().info("jaxx - found " + files.length + " file(s) to generate. ");
+ options = toCompilerOptions();
+
+ if (verbose) {
+ printInit();
+ }
+
+ }
+
+ protected void doExecute() throws Exception {
+ 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(src.getPath());
+ if (javaOpts != null && !"".equals(javaOpts)) {
+ result.setJavacOpts(javaOpts);
+ }
+ result.setKeepJavaFiles(true);
+ result.setOptimize(optimize);
+ result.setJavacTargetDirectory(outClass);
+ result.setTargetDirectory(outJava);
+ return result;
+ }
+
+ protected void printInit() {
+ getLog().debug("classPath: " + options.getClassPath());
+ getLog().debug("javaOut : " + options.getTargetDirectory());
+ getLog().debug("outClass : " + options.getJavacTargetDirectory());
+ getLog().debug("javacOpts: " + options.getJavacOpts());
+ getLog().debug("optiomize: " + options.getOptimize());
+ for (String file : files) {
+ getLog().debug(file);
+ }
+ }
+
+ public File getSrc() {
+ return src;
+ }
+
+ public void setSrc(File src) {
+ this.src = src;
+ }
+
+ public boolean isOptimize() {
+ return optimize;
+ }
+
+ public void setOptimize(boolean optimize) {
+ this.optimize = optimize;
+ }
+
+ public String getJavaOpts() {
+ return javaOpts;
+ }
+
+ public void setJavaOpts(String javaOpts) {
+ this.javaOpts = javaOpts;
+ }
+
+ public String[] getIncludes() {
+ return includes;
+ }
+
+ public void setIncludes(String[] includes) {
+ this.includes = includes;
+ }
+
+ public String[] getFiles() {
+ return files;
+ }
+
+ public void setFiles(String[] files) {
+ this.files = files;
+ }
+
+}
\ No newline at end of file
Modified: trunk/lutinjaxx/maven/src/test/java/org/codelutin/jaxx/CompilerTest.java
===================================================================
--- trunk/lutinjaxx/maven/src/test/java/org/codelutin/jaxx/CompilerTest.java 2008-07-22 22:17:15 UTC (rev 763)
+++ trunk/lutinjaxx/maven/src/test/java/org/codelutin/jaxx/CompilerTest.java 2008-07-22 22:17:54 UTC (rev 764)
@@ -10,7 +10,7 @@
public class CompilerTest extends TestCase {
- protected JaxxGeneratorGoal goal;
+ protected JaxxGeneratorMojo goal;
protected static final String PREFIX_PACKAGE = "testcases";
@@ -54,7 +54,7 @@
final File classOutDir = getClassOutDir();
assertTrue("could not found classOutDir (or not existing) : " + classOutDir + " on test " + getClass(), classOutDir != null && classOutDir.exists());
String packageName = anno.packageName();
- goal = new JaxxGeneratorGoal();
+ goal = new JaxxGeneratorMojo();
goal.setSrc(srcDir);
goal.setOutJava(outDir);
goal.setOutClass(classOutDir);
1
0
r763 - trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
22 Jul '08
Author: tchemit
Date: 2008-07-22 22:17:15 +0000 (Tue, 22 Jul 2008)
New Revision: 763
Added:
trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorMojo.java
Removed:
trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorGoal.java
Modified:
trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorGoal.java
trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorGoal.java
Log:
refactor goals
Deleted: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorGoal.java
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorGoal.java 2008-07-22 22:16:19 UTC (rev 762)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorGoal.java 2008-07-22 22:17:15 UTC (rev 763)
@@ -1,32 +0,0 @@
-/**
- * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
- * 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;
-
-/** @author chemit */
-public abstract class AbstractActionGeneratorGoal extends AbstractJaxxMojo {
-
- /**
- * @description Nom du fichier d'actions � g�n�rer.
- * @parameter expression="${jaxx.actionsFile}" default-value="/jaxx/${project.artifactId}-actions.properties"
- */
- protected String actionsFile;
-
- /**
- * @description flag to copy generated resource files to outClass
- * @parameter expression="${jaxx.copyToCP}" default-value="false"
- */
- protected boolean copyToCP;
-
-}
Copied: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorMojo.java (from rev 762, trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorGoal.java)
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorMojo.java (rev 0)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorMojo.java 2008-07-22 22:17:15 UTC (rev 763)
@@ -0,0 +1,32 @@
+/**
+ * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * 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;
+
+/** @author chemit */
+public abstract class AbstractActionGeneratorMojo extends AbstractJaxxMojo {
+
+ /**
+ * @description Nom du fichier d'actions � g�n�rer.
+ * @parameter expression="${jaxx.actionsFile}" default-value="/jaxx/${project.artifactId}-actions.properties"
+ */
+ protected String actionsFile;
+
+ /**
+ * @description flag to copy generated resource files to outClass
+ * @parameter expression="${jaxx.copyToCP}" default-value="false"
+ */
+ protected boolean copyToCP;
+
+}
Modified: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorGoal.java
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorGoal.java 2008-07-22 22:16:19 UTC (rev 762)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorGoal.java 2008-07-22 22:17:15 UTC (rev 763)
@@ -40,7 +40,7 @@
* @goal generate-actions-properties
* @phase process-classes
*/
-public class ActionGeneratorGoal extends AbstractActionGeneratorGoal {
+public class ActionGeneratorGoal extends AbstractActionGeneratorMojo {
/**
* @description R�pertoire sources des fichiers java � traiter.
Modified: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorGoal.java
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorGoal.java 2008-07-22 22:16:19 UTC (rev 762)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorGoal.java 2008-07-22 22:17:15 UTC (rev 763)
@@ -32,7 +32,7 @@
* @goal generate-actions-provider
* @phase process-resources
*/
-public class ActionProviderGeneratorGoal extends AbstractActionGeneratorGoal {
+public class ActionProviderGeneratorGoal extends AbstractActionGeneratorMojo {
/**
* @description FQN de la classe � g�n�rer.
1
0
r762 - in trunk/lutinjaxx/maven/src: main/java/org/codelutin/jaxx test/java/org/codelutin/jaxx
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
22 Jul '08
Author: tchemit
Date: 2008-07-22 22:16:19 +0000 (Tue, 22 Jul 2008)
New Revision: 762
Modified:
trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorGoal.java
trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorGoal.java
trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorGoal.java
trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorGoal.java
trunk/lutinjaxx/maven/src/test/java/org/codelutin/jaxx/CompilerTest.java
Log:
refactor goals
Modified: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorGoal.java
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorGoal.java 2008-07-22 22:08:37 UTC (rev 761)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorGoal.java 2008-07-22 22:16:19 UTC (rev 762)
@@ -14,53 +14,17 @@
*/
package org.codelutin.jaxx;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.project.MavenProject;
-
-import java.io.File;
-
/** @author chemit */
-public abstract class AbstractActionGeneratorGoal extends AbstractMojo {
+public abstract class AbstractActionGeneratorGoal extends AbstractJaxxMojo {
/**
- * @description D�pendance du projet.
- * @parameter default-value="${project}"
- * @readonly
- */
- protected MavenProject project;
-
- /**
- * @description Nom du fichier destination � g�n�rer.
- * @parameter expression="${jaxx.baseResource}" default-value="${basedir}/src/main/resources"
- */
- protected File baseResource;
-
- /**
- * @description Nom du fichier destination � g�n�rer.
+ * @description Nom du fichier d'actions � g�n�rer.
* @parameter expression="${jaxx.actionsFile}" default-value="/jaxx/${project.artifactId}-actions.properties"
*/
protected String actionsFile;
/**
- * @description Nom du fichier destination � g�n�rer.
- * @parameter expression="${jaxx.cp}" default-value="${basedir}/target/classes"
- */
- protected File cp;
-
- /**
- * @description R�pertoire sources des fichiers java � traiter.
- * @parameter expression="${jaxx.src}" default-value="${basedir}/src/main/java"
- */
- protected File src;
-
- /**
- * @description verbose
- * @parameter expression="${jaxx.verbose}" default-value="false"
- */
- protected boolean verbose;
-
- /**
- * @description flag to copy generated file to cp
+ * @description flag to copy generated resource files to outClass
* @parameter expression="${jaxx.copyToCP}" default-value="false"
*/
protected boolean copyToCP;
Modified: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorGoal.java
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorGoal.java 2008-07-22 22:08:37 UTC (rev 761)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorGoal.java 2008-07-22 22:16:19 UTC (rev 762)
@@ -19,13 +19,7 @@
package org.codelutin.jaxx;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugin.logging.Log;
-import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.DirectoryScanner;
-import static org.codelutin.i18n.I18n._;
import org.codelutin.jaxx.action.ActionConfig;
import org.codelutin.jaxx.action.SelectActionConfig;
import org.codelutin.jaxx.action.ToggleActionConfig;
@@ -35,11 +29,9 @@
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
-import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Properties;
-import java.util.Set;
/**
* Classe permettant de generer le fichier de propri�t�s des actions d�tect�es.
@@ -51,6 +43,12 @@
public class ActionGeneratorGoal extends AbstractActionGeneratorGoal {
/**
+ * @description R�pertoire sources des fichiers java � traiter.
+ * @parameter expression="${jaxx.src}" default-value="${basedir}/src/main/java"
+ */
+ protected File src;
+
+ /**
* @description pour filter
* @parameter expression="${jaxx.includes}"
*/
@@ -64,30 +62,25 @@
protected String[] files;
+ protected URLClassLoader loader;
+
private static final String[] INCLUDES = {"**\\/*.java"};
- private ClassLoader loader;
- public void execute() throws MojoExecutionException, MojoFailureException {
+ protected void doExecute() throws Exception {
- init();
-
if (verbose) {
printInit();
}
Properties result = loadProperties();
- try {
- saveProperties(result);
- } catch (IOException e) {
- throw new MojoExecutionException(e.getMessage(), e);
- }
+ saveProperties(result);
}
- protected Properties loadProperties() {
+ protected Properties loadProperties() throws ClassNotFoundException {
Properties result = new SortedProperties();
for (String file : files) {
String fqn = file.substring(0, file.length() - 5).replaceAll("\\/", ".");
@@ -96,70 +89,68 @@
getLog().debug("fqn to treate " + fqn);
}
- try {
- Class<?> clazz = Class.forName(fqn, false, loader);
+ Class<?> clazz = Class.forName(fqn, false, loader);
- // try a ActionConfig
- ActionConfig actionConfig = clazz.getAnnotation(ActionConfig.class);
- if (actionConfig != null) {
- if (actionConfig.multiNames().length > 0) {
- // multinames
- registerEntry(clazz, result, actionConfig.multiNames());
- continue;
- }
+ // try a ActionConfig
+ ActionConfig actionConfig = clazz.getAnnotation(ActionConfig.class);
+ if (actionConfig != null) {
- if (!actionConfig.actionCommand().isEmpty()) {
- registerEntry(clazz, result, actionConfig.actionCommand());
- continue;
- }
+ if (actionConfig.multiNames().length > 0) {
+ // multinames
+ registerEntry(clazz, result, actionConfig.multiNames());
+ continue;
+ }
- getLog().warn("could not treate class " + clazz);
+ if (!actionConfig.actionCommand().isEmpty()) {
+ registerEntry(clazz, result, actionConfig.actionCommand());
continue;
}
- // try a SelectActionConfig
- SelectActionConfig selectActionConfig = clazz.getAnnotation(SelectActionConfig.class);
- if (selectActionConfig != null) {
- if (selectActionConfig.multiNames().length > 0) {
- // multinames
- registerEntry(clazz, result, selectActionConfig.multiNames());
- continue;
- }
+ getLog().warn("could not treate class " + clazz);
+ continue;
+ }
- if (!selectActionConfig.actionCommand().isEmpty()) {
- registerEntry(clazz, result, selectActionConfig.actionCommand());
- continue;
- }
- getLog().warn("could not treate class " + clazz);
+ // try a SelectActionConfig
+ SelectActionConfig selectActionConfig = clazz.getAnnotation(SelectActionConfig.class);
+ if (selectActionConfig != null) {
+ if (selectActionConfig.multiNames().length > 0) {
+ // multinames
+ registerEntry(clazz, result, selectActionConfig.multiNames());
continue;
}
- // try a toggleAction
- ToggleActionConfig toggleActionConfig = clazz.getAnnotation(ToggleActionConfig.class);
- if (toggleActionConfig != null) {
- if (toggleActionConfig.multiNames().length > 0) {
- // multinames
- registerEntry(clazz, result, toggleActionConfig.multiNames());
- continue;
- }
- if (!toggleActionConfig.actionCommand().isEmpty()) {
- registerEntry(clazz, result, toggleActionConfig.actionCommand());
- continue;
- }
+ if (!selectActionConfig.actionCommand().isEmpty()) {
+ registerEntry(clazz, result, selectActionConfig.actionCommand());
+ continue;
+ }
+ getLog().warn("could not treate class " + clazz);
+ continue;
+ }
- getLog().warn("could not treate class " + clazz);
+ // try a toggleAction
+ ToggleActionConfig toggleActionConfig = clazz.getAnnotation(ToggleActionConfig.class);
+ if (toggleActionConfig != null) {
+ if (toggleActionConfig.multiNames().length > 0) {
+ // multinames
+ registerEntry(clazz, result, toggleActionConfig.multiNames());
+ continue;
}
- } catch (ClassNotFoundException e) {
- getLog().error("could not find class " + e.getMessage());
+ if (!toggleActionConfig.actionCommand().isEmpty()) {
+ registerEntry(clazz, result, toggleActionConfig.actionCommand());
+ continue;
+ }
+
+ getLog().warn("could not treate class " + clazz);
}
+
}
return result;
}
protected void saveProperties(Properties result) throws IOException {
OutputStream writer = null;
- File generatedFile = new File(baseResource, actionsFile);
+ File generatedFile = new File(outResource, actionsFile);
File parent = generatedFile.getParentFile();
if (!parent.exists()) {
parent.mkdirs();
@@ -172,16 +163,14 @@
} finally {
if (writer != null) {
-
writer.flush();
writer.close();
-
}
}
if (copyToCP) {
// save it also in classes
- File compiledFile = new File(cp, actionsFile);
+ File compiledFile = new File(outClass, actionsFile);
if (getLog().isDebugEnabled()) {
getLog().debug("copy to classapth generated file " + compiledFile);
}
@@ -194,7 +183,11 @@
}
+ @Override
protected void init() {
+
+ super.init();
+
DirectoryScanner ds;
ds = new DirectoryScanner();
ds.setBasedir(src);
@@ -226,63 +219,49 @@
for (String file : files) {
getLog().debug(file);
}
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- getLog().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);
+ printCP();
+ }
- for (URL url : urls) {
- getLog().debug("ulr in class loader " + url);
- }
- } catch (Exception e) {
- getLog().warn("??? : " + e.getMessage(), e);
- }
+ protected void printCP() {
+
+ getLog().debug(loader.toString());
+
+ for (URL url : loader.getURLs()) {
+ getLog().debug("url in class loader " + url);
}
}
- @SuppressWarnings({"unchecked"})
- protected URLClassLoader initClassLoader(MavenProject project, Log log) {
- URLClassLoader loader = null;
- if (project != null) {
- URLClassLoader result;
- try {
- Set<Artifact> compileClasspathElements = project.getArtifacts();
- URL[] url = new URL[compileClasspathElements.size() + 1];
- url[0] = cp.toURI().toURL();
- int i = 1;
- for (Artifact artifact : compileClasspathElements) {
- File file = new File(artifact.getFile().getAbsolutePath());
- if (file.getName().endsWith(".jar")) {
- url[i] = new URL("jar", "", file.toURI().toURL().toString() + "!/");
- } else {
- url[i] = file.toURI().toURL();
- }
- i++;
- }
- //ClassLoader parent = Thread.currentThread().getContextClassLoader();
- if (compileClasspathElements.size() == 0) {
- result = new URLClassLoader(url, getClass().getClassLoader());
- } else {
- result = new URLClassLoader(url, getClass().getClassLoader());
- }
- } catch (MalformedURLException eee) {
- throw new RuntimeException(_("Can't create ClassLoader for script, bad directory: {0} for reason {1}", cp, eee.getMessage()), eee);
- } catch (IOException e) {
- throw new RuntimeException(_("Can't create ClassLoader for script, bad directory: {0} for reason {1}", cp, e.getMessage()), e);
- }
- loader = result;
- }
- if (log.isDebugEnabled() && loader != null) {
- for (URL entry : loader.getURLs()) {
- log.info("cp url " + entry);
- }
- }
- return loader;
+ public File getSrc() {
+ return src;
}
+ public void setSrc(File src) {
+ this.src = src;
+ }
+ public String[] getIncludes() {
+ return includes;
+ }
+
+ public void setIncludes(String[] includes) {
+ this.includes = includes;
+ }
+
+ public String[] getExcludes() {
+ return excludes;
+ }
+
+ public void setExcludes(String[] excludes) {
+ this.excludes = excludes;
+ }
+
+ public String[] getFiles() {
+ return files;
+ }
+
+ public void setFiles(String[] files) {
+ this.files = files;
+ }
+
}
\ No newline at end of file
Modified: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorGoal.java
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorGoal.java 2008-07-22 22:08:37 UTC (rev 761)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorGoal.java 2008-07-22 22:16:19 UTC (rev 762)
@@ -19,15 +19,14 @@
package org.codelutin.jaxx;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
+import org.codelutin.jaxx.action.ActionProvider;
import org.codelutin.util.FileUtil;
import java.io.File;
import java.io.IOException;
/**
- * Classe permettant de generer un {@link org.codelutin.jaxx.action.ActionProvider} et so fichier de d�claration.
+ * Classe permettant de generer un {@link org.codelutin.jaxx.action.ActionProvider} et son fichier de d�claration.
*
* @author chemit
* @goal generate-actions-provider
@@ -80,20 +79,12 @@
protected File generatedProviderDeclaration;
- public void execute() throws MojoExecutionException, MojoFailureException {
+ protected void doExecute() throws Exception {
- init();
+ generateProvider();
- try {
+ generateProviderDeclaration();
- generateProvider();
-
- generateProviderDeclaration();
-
- } catch (IOException e) {
- getLog().error(e);
- throw new MojoExecutionException(e.getMessage(), e);
- }
}
protected void generateProvider() throws IOException {
@@ -123,8 +114,8 @@
if (copyToCP) {
// save it also in classes (since we are in process-resources phase and resources has already been copied)
- String path = generatedProviderDeclaration.getAbsolutePath().substring(baseResource.getAbsolutePath().length() + 1);
- File compiledFile = new File(cp, path);
+ String path = generatedProviderDeclaration.getAbsolutePath().substring(outResource.getAbsolutePath().length() + 1);
+ File compiledFile = new File(outClass, path);
if (getLog().isDebugEnabled()) {
getLog().debug("copy to classapth generated file " + compiledFile);
}
@@ -136,22 +127,26 @@
}
}
+ @Override
protected void init() {
- generateJavaProvider = new File(src, fqn.replaceAll("\\.", java.io.File.separator) + ".java");
+ super.init();
+ generateJavaProvider = new File(outJava, fqn.replaceAll("\\.", java.io.File.separator) + ".java");
+
File parent = generateJavaProvider.getParentFile();
if (!parent.exists()) {
parent.mkdirs();
}
- generatedProviderDeclaration = new File(baseResource, "META-INF/services/org.codelutin.jaxx.action.ActionProvider");
+ generatedProviderDeclaration = new File(outResource, "META-INF/services/" + ActionProvider.class.getName());
parent = generatedProviderDeclaration.getParentFile();
if (!parent.exists()) {
parent.mkdirs();
}
+ fixCompileSourceRoots();
+
}
-
}
\ No newline at end of file
Modified: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorGoal.java
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorGoal.java 2008-07-22 22:08:37 UTC (rev 761)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorGoal.java 2008-07-22 22:16:19 UTC (rev 762)
@@ -21,15 +21,10 @@
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.apache.maven.project.MavenProject;
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.
@@ -38,32 +33,15 @@
* @goal generate
* @phase process-resources
*/
-public class JaxxGeneratorGoal extends AbstractMojo {
+public class JaxxGeneratorGoal extends AbstractJaxxMojo {
+
/**
- * The maven project.
- *
- * @parameter expression="${project}"
- * @read-only
- * @required
- */
- private MavenProject project;
-
- /**
* @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"
*/
@@ -81,58 +59,34 @@
*/
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 {
- if (!out.exists()) {
- out.mkdirs();
- }
+ protected CompilerOptions options;
+ protected void init() {
+ super.init();
+
fixCompileSourceRoots();
DirectoryScanner ds;
ds = new DirectoryScanner();
- ds.setBasedir(getSrc());
+ ds.setBasedir(src);
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);
+ getLog().info("jaxx - found " + files.length + " file(s) to generate. ");
+ options = toCompilerOptions();
- for (URL url : urls) {
- log.debug("ulr in class loader " + url);
- }
- } catch (Exception e) {
- log.warn("??? : " + e.getMessage(), e);
- }
- }
+ if (verbose) {
+ printInit();
}
+ }
+
+ protected void doExecute() throws Exception {
if (!JAXXCompiler.compile(src, files, options)) {
throw new MojoFailureException("Aborting due to errors reported by jaxxc");
}
@@ -140,67 +94,56 @@
public CompilerOptions toCompilerOptions() {
CompilerOptions result = new CompilerOptions();
- result.setClassPath(getSrc().getPath());
- if (getJavaOpts() != null && !"".equals(getJavaOpts())) {
- result.setJavacOpts(getJavaOpts());
+ result.setClassPath(src.getPath());
+ if (javaOpts != null && !"".equals(javaOpts)) {
+ result.setJavacOpts(javaOpts);
}
result.setKeepJavaFiles(true);
- result.setOptimize(isOptimize());
- result.setJavacTargetDirectory(getClassOut());
- result.setTargetDirectory(getOut());
+ result.setOptimize(optimize);
+ result.setJavacTargetDirectory(outClass);
+ result.setTargetDirectory(outJava);
return result;
}
- protected Log log = getLog();
+ protected void printInit() {
+ getLog().debug("classPath: " + options.getClassPath());
+ getLog().debug("javaOut : " + options.getTargetDirectory());
+ getLog().debug("outClass : " + options.getJavacTargetDirectory());
+ getLog().debug("javacOpts: " + options.getJavacOpts());
+ getLog().debug("optiomize: " + options.getOptimize());
+ for (String file : files) {
+ getLog().debug(file);
+ }
+ }
public File getSrc() {
return src;
}
+ public void setSrc(File src) {
+ this.src = src;
+ }
+
public boolean isOptimize() {
return optimize;
}
- public File getOut() {
- return out;
+ public void setOptimize(boolean optimize) {
+ this.optimize = optimize;
}
public String getJavaOpts() {
return javaOpts;
}
- public File getClassOut() {
- return classOut;
+ public void setJavaOpts(String javaOpts) {
+ this.javaOpts = javaOpts;
}
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;
}
@@ -209,9 +152,8 @@
return files;
}
- protected void fixCompileSourceRoots() {
- if (!project.getCompileSourceRoots().contains(out.getPath())) {
- project.addCompileSourceRoot(out.getPath());
- }
- }
+ public void setFiles(String[] files) {
+ this.files = files;
+ }
+
}
\ No newline at end of file
Modified: trunk/lutinjaxx/maven/src/test/java/org/codelutin/jaxx/CompilerTest.java
===================================================================
--- trunk/lutinjaxx/maven/src/test/java/org/codelutin/jaxx/CompilerTest.java 2008-07-22 22:08:37 UTC (rev 761)
+++ trunk/lutinjaxx/maven/src/test/java/org/codelutin/jaxx/CompilerTest.java 2008-07-22 22:16:19 UTC (rev 762)
@@ -56,14 +56,14 @@
String packageName = anno.packageName();
goal = new JaxxGeneratorGoal();
goal.setSrc(srcDir);
- goal.setOut(outDir);
- goal.setClassOut(classOutDir);
+ goal.setOutJava(outDir);
+ goal.setOutClass(classOutDir);
goal.setIncludes(new String[]{"**\\/" + PREFIX_PACKAGE + "\\/" + packageName + "\\/*.jaxx"});
goal.setOptimize(anno.optimize());
goal.setVerbose(anno.verbose());
//TODO Use the maven plexus TestCase inorder to include dependencies
goal.setJavaOpts(anno.javaOpts());
- System.out.println(getName());
+ goal.getLog().info(getName());
}
1
0
r761 - trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
22 Jul '08
Author: tchemit
Date: 2008-07-22 22:08:37 +0000 (Tue, 22 Jul 2008)
New Revision: 761
Added:
trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractJaxxMojo.java
Log:
abstract Jaxx Mojo
Copied: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractJaxxMojo.java (from rev 759, trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorGoal.java)
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractJaxxMojo.java (rev 0)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractJaxxMojo.java 2008-07-22 22:08:37 UTC (rev 761)
@@ -0,0 +1,183 @@
+/**
+ * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * 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 org.apache.maven.artifact.Artifact;
+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.apache.maven.project.MavenProject;
+import static org.codelutin.i18n.I18n._;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Set;
+
+/**
+ * Le mojo de base pour les goals Jaxx.
+ *
+ * @author chemit
+ */
+public abstract class AbstractJaxxMojo extends AbstractMojo {
+
+ /**
+ * @description D�pendance du projet.
+ * @parameter default-value="${project}"
+ * @readonly
+ */
+ protected MavenProject project;
+
+ /**
+ * @description R�pertoire de destination des fichiers java � g�n�rer.
+ * @parameter expression="${jaxx.outJava}" default-value="${basedir}/gen/java"
+ */
+ protected File outJava;
+
+ /**
+ * @description chemin du r�pertoire de g�n�ration des resources.
+ * @parameter expression="${jaxx.outResource}" default-value="${basedir}/gen/resources"
+ */
+ protected File outResource;
+
+ /**
+ * @description chemin du r�pertoire de compilation des resources.
+ * @parameter expression="${jaxx.outClass}" default-value="${basedir}/target/classes"
+ */
+ protected File outClass;
+
+ /**
+ * @description verbose
+ * @parameter expression="${jaxx.verbose}" default-value="${maven.verbose}"
+ */
+ protected boolean verbose;
+
+
+ protected abstract void doExecute() throws Exception;
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+
+ init();
+
+ try {
+
+ doExecute();
+
+ } catch (Exception e) {
+ getLog().error(e);
+ Throwable e2 = e;
+ while (e2.getCause() != null) {
+ e2 = e.getCause();
+ }
+ getLog().error(e2);
+
+ throw new MojoExecutionException(e.getMessage(), e);
+ }
+
+ }
+
+ protected void init() {
+
+ if (!outResource.exists()) {
+ outResource.mkdirs();
+ }
+
+ if (!outJava.exists()) {
+ outJava.mkdirs();
+ }
+
+ }
+
+ protected void fixCompileSourceRoots() {
+ if (!project.getCompileSourceRoots().contains(outJava.getPath())) {
+ project.addCompileSourceRoot(outJava.getPath());
+ }
+ }
+
+ @SuppressWarnings({"unchecked"})
+ protected URLClassLoader initClassLoader(MavenProject project, Log log) {
+ URLClassLoader loader = null;
+ if (project != null) {
+ URLClassLoader result;
+ try {
+ Set<Artifact> compileClasspathElements = project.getArtifacts();
+ URL[] url = new URL[compileClasspathElements.size() + 1];
+ url[0] = outClass.toURI().toURL();
+ int i = 1;
+ for (Artifact artifact : compileClasspathElements) {
+ File file = new File(artifact.getFile().getAbsolutePath());
+ if (file.getName().endsWith(".jar")) {
+ url[i] = new URL("jar", "", file.toURI().toURL().toString() + "!/");
+ } else {
+ url[i] = file.toURI().toURL();
+ }
+ i++;
+ }
+ //ClassLoader parent = Thread.currentThread().getContextClassLoader();
+ if (compileClasspathElements.size() == 0) {
+ result = new URLClassLoader(url, getClass().getClassLoader());
+ } else {
+ result = new URLClassLoader(url, getClass().getClassLoader());
+ }
+ } catch (MalformedURLException eee) {
+ throw new RuntimeException(_("Can't create ClassLoader for script, bad directory: {0} for reason {1}", outClass, eee.getMessage()), eee);
+ } catch (IOException e) {
+ throw new RuntimeException(_("Can't create ClassLoader for script, bad directory: {0} for reason {1}", outClass, e.getMessage()), e);
+ }
+ loader = result;
+ }
+ if (log.isDebugEnabled() && loader != null) {
+ for (URL entry : loader.getURLs()) {
+ log.info("outClass url " + entry);
+ }
+ }
+ return loader;
+ }
+
+ public File getOutJava() {
+ return outJava;
+ }
+
+ public void setOutJava(File outJava) {
+ this.outJava = outJava;
+ }
+
+ public File getOutResource() {
+ return outResource;
+ }
+
+ public void setOutResource(File outResource) {
+ this.outResource = outResource;
+ }
+
+ public File getOutClass() {
+ return outClass;
+ }
+
+ public void setOutClass(File outClass) {
+ this.outClass = outClass;
+ }
+
+ public boolean isVerbose() {
+ return verbose;
+ }
+
+ public void setVerbose(boolean verbose) {
+ this.verbose = verbose;
+ }
+}
\ No newline at end of file
1
0
r760 - trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
22 Jul '08
Author: tchemit
Date: 2008-07-22 20:06:35 +0000 (Tue, 22 Jul 2008)
New Revision: 760
Modified:
trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorGoal.java
Log:
utilisation d'un r?\195?\169pertoire de compilation dans le projet
Modified: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorGoal.java
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorGoal.java 2008-07-22 18:03:24 UTC (rev 759)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorGoal.java 2008-07-22 20:06:35 UTC (rev 760)
@@ -25,6 +25,7 @@
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.DirectoryScanner;
import java.io.File;
@@ -38,8 +39,16 @@
* @phase process-resources
*/
public class JaxxGeneratorGoal extends AbstractMojo {
-
/**
+ * The maven project.
+ *
+ * @parameter expression="${project}"
+ * @read-only
+ * @required
+ */
+ private MavenProject project;
+
+ /**
* @description R�pertoire sources des fichiers jaxx � g�n�rer.
* @parameter expression="${jaxx.src}" default-value="${basedir}/src/uimodel"
*/
@@ -83,7 +92,12 @@
private static final String[] INCLUDES = {"**\\/*.jaxx"};
public void execute() throws MojoExecutionException, MojoFailureException {
+ if (!out.exists()) {
+ out.mkdirs();
+ }
+ fixCompileSourceRoots();
+
DirectoryScanner ds;
ds = new DirectoryScanner();
ds.setBasedir(getSrc());
@@ -194,4 +208,10 @@
public String[] getFiles() {
return files;
}
+
+ protected void fixCompileSourceRoots() {
+ if (!project.getCompileSourceRoots().contains(out.getPath())) {
+ project.addCompileSourceRoot(out.getPath());
+ }
+ }
}
\ No newline at end of file
1
0
r759 - trunk/lutinjaxx/maven/src/main/resources
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
22 Jul '08
Author: tchemit
Date: 2008-07-22 18:03:24 +0000 (Tue, 22 Jul 2008)
New Revision: 759
Modified:
trunk/lutinjaxx/maven/src/main/resources/log4j.properties
Log:
revert !
Modified: trunk/lutinjaxx/maven/src/main/resources/log4j.properties
===================================================================
--- trunk/lutinjaxx/maven/src/main/resources/log4j.properties 2008-07-22 18:02:38 UTC (rev 758)
+++ trunk/lutinjaxx/maven/src/main/resources/log4j.properties 2008-07-22 18:03:24 UTC (rev 759)
@@ -5,5 +5,5 @@
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
-log4j.logger.org.codelutin.jaxx=DEBUG
-log4j.logger.jaxx=DEBUG
+#log4j.logger.org.codelutin.jaxx=DEBUG
+#log4j.logger.jaxx=DEBUG
1
0
r758 - trunk/lutinjaxx/jaxx-swing/src/main/java/jaxx/tags/swing
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
22 Jul '08
Author: tchemit
Date: 2008-07-22 18:02:38 +0000 (Tue, 22 Jul 2008)
New Revision: 758
Modified:
trunk/lutinjaxx/jaxx-swing/src/main/java/jaxx/tags/swing/TableHandler.java
Log:
revert !
Modified: trunk/lutinjaxx/jaxx-swing/src/main/java/jaxx/tags/swing/TableHandler.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing/src/main/java/jaxx/tags/swing/TableHandler.java 2008-07-22 17:16:20 UTC (rev 757)
+++ trunk/lutinjaxx/jaxx-swing/src/main/java/jaxx/tags/swing/TableHandler.java 2008-07-22 18:02:38 UTC (rev 758)
@@ -100,8 +100,8 @@
rowConstraints = (GridBagConstraints) tableConstraints.clone();
for (int x = 0; x < rowSpans.size(); x++) {
- Integer rowSpan = rowSpans.get(x);
- if (rowSpan != null && rowSpan > 0) {
+ int rowSpan = rowSpans.get(x);
+ if (rowSpan > 0) {
rowSpans.set(x, rowSpan - 1);
}
}
@@ -110,7 +110,7 @@
public void newCell() {
emptyCell = true;
rowConstraints.gridx++;
- while (rowConstraints.gridx < rowSpans.size() && rowSpans.get(rowConstraints.gridx) != null && rowSpans.get(rowConstraints.gridx) > 0) {
+ while (rowConstraints.gridx < rowSpans.size() && rowSpans.get(rowConstraints.gridx) > 0) {
rowConstraints.gridx++;
}
cellConstraints = (GridBagConstraints) rowConstraints.clone();
1
0
r757 - trunk/lutinjaxx/jaxx-swing/src/main/java/jaxx/tags/swing
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
by tchemit@users.labs.libre-entreprise.org 22 Jul '08
22 Jul '08
Author: tchemit
Date: 2008-07-22 17:16:20 +0000 (Tue, 22 Jul 2008)
New Revision: 757
Modified:
trunk/lutinjaxx/jaxx-swing/src/main/java/jaxx/tags/swing/TableHandler.java
Log:
test d'un NPE ?
Modified: trunk/lutinjaxx/jaxx-swing/src/main/java/jaxx/tags/swing/TableHandler.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing/src/main/java/jaxx/tags/swing/TableHandler.java 2008-07-22 17:09:28 UTC (rev 756)
+++ trunk/lutinjaxx/jaxx-swing/src/main/java/jaxx/tags/swing/TableHandler.java 2008-07-22 17:16:20 UTC (rev 757)
@@ -110,7 +110,7 @@
public void newCell() {
emptyCell = true;
rowConstraints.gridx++;
- while (rowConstraints.gridx < rowSpans.size() && rowSpans.get(rowConstraints.gridx) > 0) {
+ while (rowConstraints.gridx < rowSpans.size() && rowSpans.get(rowConstraints.gridx) != null && rowSpans.get(rowConstraints.gridx) > 0) {
rowConstraints.gridx++;
}
cellConstraints = (GridBagConstraints) rowConstraints.clone();
1
0