Author: Alex.Kolonitsky
Date: 2009-11-01 11:28:50 -0500 (Sun, 01 Nov 2009)
New Revision: 15792
Modified:
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/AbstractTestComponent.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/UITestCommand.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenLogger.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractCDKMojo.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractGenerateMojo.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CompileMojo.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CompileTemplatesMojo.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Library.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Renderkit.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/SkinInfo.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Taglib.java
Log:
Code style policy
https://jira.jboss.org/jira/browse/RFPL-195
Modified:
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/AbstractTestComponent.java
===================================================================
---
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/AbstractTestComponent.java 2009-11-01
16:27:54 UTC (rev 15791)
+++
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/AbstractTestComponent.java 2009-11-01
16:28:50 UTC (rev 15792)
@@ -21,6 +21,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.test.component;
import org.richfaces.cdk.annotations.Attribute;
@@ -29,6 +31,7 @@
import org.richfaces.cdk.annotations.Generate;
import java.util.List;
+
import javax.faces.component.UIComponentBase;
import javax.faces.component.ValueHolder;
@@ -40,20 +43,19 @@
@Component("org.richfaces.cdk.test.TestComponent")
@Generate("org.richfaces.cdk.test.UITestComponent")
@Family("org.richfaces.cdk.test.Test")
-public abstract class AbstractTestComponent extends UIComponentBase {
-
- @Attribute
- private int foo;
-
- /**
- * Test Attribute
- */
- @Attribute
- public abstract List<String> getTestValue();
+public abstract class AbstractTestComponent extends UIComponentBase {
+ @Attribute
+ private int foo;
- /**
- * Bar Attribute
- */
- @Attribute
- public abstract void setBarValue(List<Object> bar);
+ /**
+ * Test Attribute
+ */
+ @Attribute
+ public abstract List<String> getTestValue();
+
+ /**
+ * Bar Attribute
+ */
+ @Attribute
+ public abstract void setBarValue(List<Object> bar);
}
Modified:
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/UITestCommand.java
===================================================================
---
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/UITestCommand.java 2009-11-01
16:27:54 UTC (rev 15791)
+++
root/cdk/trunk/plugins/maven-cdk-plugin/src/it/annotated-component/src/main/java/org/richfaces/cdk/test/component/UITestCommand.java 2009-11-01
16:28:50 UTC (rev 15792)
@@ -21,9 +21,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.cdk.test.component;
import javax.el.MethodExpression;
+
import javax.faces.component.ActionSource2;
import javax.faces.component.FacesComponent;
import javax.faces.component.UIComponentBase;
@@ -37,96 +40,110 @@
*/
@FacesComponent("cdk.TestCommand")
public class UITestCommand extends UIComponentBase implements ActionSource2 {
-
- private static final String COMPONENT_FAMILY="cdk.TestFamily";
+ private static final String COMPONENT_FAMILY = "cdk.TestFamily";
- /* (non-Javadoc)
- * @see javax.faces.component.UIComponent#getFamily()
- */
- @Override
- public String getFamily() {
- return COMPONENT_FAMILY;
- }
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.UIComponent#getFamily()
+ */
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
- /* (non-Javadoc)
- * @see
javax.faces.component.ActionSource#addActionListener(javax.faces.event.ActionListener)
- */
- public void addActionListener(ActionListener listener) {
- // TODO Auto-generated method stub
+ /*
+ * (non-Javadoc)
+ * @see
javax.faces.component.ActionSource#addActionListener(javax.faces.event.ActionListener)
+ */
+ public void addActionListener(ActionListener listener) {
- }
+ // TODO Auto-generated method stub
+ }
- /* (non-Javadoc)
- * @see javax.faces.component.ActionSource#getAction()
- */
- public MethodBinding getAction() {
- // TODO Auto-generated method stub
- return null;
- }
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.ActionSource#getAction()
+ */
+ public MethodBinding getAction() {
- /* (non-Javadoc)
- * @see javax.faces.component.ActionSource#getActionListener()
- */
- public MethodBinding getActionListener() {
- // TODO Auto-generated method stub
- return null;
- }
+ // TODO Auto-generated method stub
+ return null;
+ }
- /* (non-Javadoc)
- * @see javax.faces.component.ActionSource#getActionListeners()
- */
- public ActionListener[] getActionListeners() {
- // TODO Auto-generated method stub
- return null;
- }
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.ActionSource#getActionListener()
+ */
+ public MethodBinding getActionListener() {
- /* (non-Javadoc)
- * @see javax.faces.component.ActionSource#isImmediate()
- */
- public boolean isImmediate() {
- // TODO Auto-generated method stub
- return false;
- }
+ // TODO Auto-generated method stub
+ return null;
+ }
- /* (non-Javadoc)
- * @see
javax.faces.component.ActionSource#removeActionListener(javax.faces.event.ActionListener)
- */
- public void removeActionListener(ActionListener listener) {
- // TODO Auto-generated method stub
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.ActionSource#getActionListeners()
+ */
+ public ActionListener[] getActionListeners() {
- }
+ // TODO Auto-generated method stub
+ return null;
+ }
- /* (non-Javadoc)
- * @see javax.faces.component.ActionSource#setAction(javax.faces.el.MethodBinding)
- */
- public void setAction(MethodBinding action) {
- // TODO Auto-generated method stub
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.ActionSource#isImmediate()
+ */
+ public boolean isImmediate() {
- }
+ // TODO Auto-generated method stub
+ return false;
+ }
- /* (non-Javadoc)
- * @see
javax.faces.component.ActionSource#setActionListener(javax.faces.el.MethodBinding)
- */
- public void setActionListener(MethodBinding actionListener) {
- // TODO Auto-generated method stub
+ /*
+ * (non-Javadoc)
+ * @see
javax.faces.component.ActionSource#removeActionListener(javax.faces.event.ActionListener)
+ */
+ public void removeActionListener(ActionListener listener) {
- }
+ // TODO Auto-generated method stub
+ }
- public void setActionExpression(MethodExpression action) {
- // TODO Auto-generated method stub
-
- }
- /* (non-Javadoc)
- * @see javax.faces.component.ActionSource#setImmediate(boolean)
- */
- public void setImmediate(boolean immediate) {
- // TODO Auto-generated method stub
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.ActionSource#setAction(javax.faces.el.MethodBinding)
+ */
+ public void setAction(MethodBinding action) {
- }
+ // TODO Auto-generated method stub
+ }
- public MethodExpression getActionExpression() {
- // TODO Auto-generated method stub
- return null;
- }
+ /*
+ * (non-Javadoc)
+ * @see
javax.faces.component.ActionSource#setActionListener(javax.faces.el.MethodBinding)
+ */
+ public void setActionListener(MethodBinding actionListener) {
+ // TODO Auto-generated method stub
+ }
+
+ public void setActionExpression(MethodExpression action) {
+
+ // TODO Auto-generated method stub
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.ActionSource#setImmediate(boolean)
+ */
+ public void setImmediate(boolean immediate) {
+
+ // TODO Auto-generated method stub
+ }
+
+ public MethodExpression getActionExpression() {
+
+ // TODO Auto-generated method stub
+ return null;
+ }
}
Modified:
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenLogger.java
===================================================================
---
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenLogger.java 2009-11-01
16:27:54 UTC (rev 15791)
+++
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenLogger.java 2009-11-01
16:28:50 UTC (rev 15792)
@@ -19,9 +19,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.maven;
import org.apache.maven.plugin.logging.Log;
+
import org.richfaces.cdk.Logger;
/**
@@ -29,147 +32,145 @@
*
*/
public class MavenLogger implements Logger {
-
- private Log _log;
+ private Log log;
- /**
- * @param _log
- */
- public MavenLogger(Log _log) {
- super();
- this._log = _log;
- }
+ /**
+ * @param log
+ */
+ public MavenLogger(Log log) {
+ super();
+ this.log = log;
+ }
- /**
- * @param content
- * @param error
- * @see org.apache.maven.plugin.logging.Log#debug(java.lang.CharSequence,
java.lang.Throwable)
- */
- public void debug(CharSequence content, Throwable error) {
- _log.debug(content, error);
- }
+ /**
+ * @param content
+ * @param error
+ * @see org.apache.maven.plugin.logging.Log#debug(java.lang.CharSequence,
java.lang.Throwable)
+ */
+ public void debug(CharSequence content, Throwable error) {
+ log.debug(content, error);
+ }
- /**
- * @param content
- * @see org.apache.maven.plugin.logging.Log#debug(java.lang.CharSequence)
- */
- public void debug(CharSequence content) {
- _log.debug(content);
- }
+ /**
+ * @param content
+ * @see org.apache.maven.plugin.logging.Log#debug(java.lang.CharSequence)
+ */
+ public void debug(CharSequence content) {
+ log.debug(content);
+ }
- /**
- * @param error
- * @see org.apache.maven.plugin.logging.Log#debug(java.lang.Throwable)
- */
- public void debug(Throwable error) {
- _log.debug(error);
- }
+ /**
+ * @param error
+ * @see org.apache.maven.plugin.logging.Log#debug(java.lang.Throwable)
+ */
+ public void debug(Throwable error) {
+ log.debug(error);
+ }
- /**
- * @param content
- * @param error
- * @see org.apache.maven.plugin.logging.Log#error(java.lang.CharSequence,
java.lang.Throwable)
- */
- public void error(CharSequence content, Throwable error) {
- _log.error(content, error);
- }
+ /**
+ * @param content
+ * @param error
+ * @see org.apache.maven.plugin.logging.Log#error(java.lang.CharSequence,
java.lang.Throwable)
+ */
+ public void error(CharSequence content, Throwable error) {
+ log.error(content, error);
+ }
- /**
- * @param content
- * @see org.apache.maven.plugin.logging.Log#error(java.lang.CharSequence)
- */
- public void error(CharSequence content) {
- _log.error(content);
- }
+ /**
+ * @param content
+ * @see org.apache.maven.plugin.logging.Log#error(java.lang.CharSequence)
+ */
+ public void error(CharSequence content) {
+ log.error(content);
+ }
- /**
- * @param error
- * @see org.apache.maven.plugin.logging.Log#error(java.lang.Throwable)
- */
- public void error(Throwable error) {
- _log.error(error);
- }
+ /**
+ * @param error
+ * @see org.apache.maven.plugin.logging.Log#error(java.lang.Throwable)
+ */
+ public void error(Throwable error) {
+ log.error(error);
+ }
- /**
- * @param content
- * @param error
- * @see org.apache.maven.plugin.logging.Log#info(java.lang.CharSequence,
java.lang.Throwable)
- */
- public void info(CharSequence content, Throwable error) {
- _log.info(content, error);
- }
+ /**
+ * @param content
+ * @param error
+ * @see org.apache.maven.plugin.logging.Log#info(java.lang.CharSequence,
java.lang.Throwable)
+ */
+ public void info(CharSequence content, Throwable error) {
+ log.info(content, error);
+ }
- /**
- * @param content
- * @see org.apache.maven.plugin.logging.Log#info(java.lang.CharSequence)
- */
- public void info(CharSequence content) {
- _log.info(content);
- }
+ /**
+ * @param content
+ * @see org.apache.maven.plugin.logging.Log#info(java.lang.CharSequence)
+ */
+ public void info(CharSequence content) {
+ log.info(content);
+ }
- /**
- * @param error
- * @see org.apache.maven.plugin.logging.Log#info(java.lang.Throwable)
- */
- public void info(Throwable error) {
- _log.info(error);
- }
+ /**
+ * @param error
+ * @see org.apache.maven.plugin.logging.Log#info(java.lang.Throwable)
+ */
+ public void info(Throwable error) {
+ log.info(error);
+ }
- /**
- * @return
- * @see org.apache.maven.plugin.logging.Log#isDebugEnabled()
- */
- public boolean isDebugEnabled() {
- return _log.isDebugEnabled();
- }
+ /**
+ * @return
+ * @see org.apache.maven.plugin.logging.Log#isDebugEnabled()
+ */
+ public boolean isDebugEnabled() {
+ return log.isDebugEnabled();
+ }
- /**
- * @return
- * @see org.apache.maven.plugin.logging.Log#isErrorEnabled()
- */
- public boolean isErrorEnabled() {
- return _log.isErrorEnabled();
- }
+ /**
+ * @return
+ * @see org.apache.maven.plugin.logging.Log#isErrorEnabled()
+ */
+ public boolean isErrorEnabled() {
+ return log.isErrorEnabled();
+ }
- /**
- * @return
- * @see org.apache.maven.plugin.logging.Log#isInfoEnabled()
- */
- public boolean isInfoEnabled() {
- return _log.isInfoEnabled();
- }
+ /**
+ * @return
+ * @see org.apache.maven.plugin.logging.Log#isInfoEnabled()
+ */
+ public boolean isInfoEnabled() {
+ return log.isInfoEnabled();
+ }
- /**
- * @return
- * @see org.apache.maven.plugin.logging.Log#isWarnEnabled()
- */
- public boolean isWarnEnabled() {
- return _log.isWarnEnabled();
- }
+ /**
+ * @return
+ * @see org.apache.maven.plugin.logging.Log#isWarnEnabled()
+ */
+ public boolean isWarnEnabled() {
+ return log.isWarnEnabled();
+ }
- /**
- * @param content
- * @param error
- * @see org.apache.maven.plugin.logging.Log#warn(java.lang.CharSequence,
java.lang.Throwable)
- */
- public void warn(CharSequence content, Throwable error) {
- _log.warn(content, error);
- }
+ /**
+ * @param content
+ * @param error
+ * @see org.apache.maven.plugin.logging.Log#warn(java.lang.CharSequence,
java.lang.Throwable)
+ */
+ public void warn(CharSequence content, Throwable error) {
+ log.warn(content, error);
+ }
- /**
- * @param content
- * @see org.apache.maven.plugin.logging.Log#warn(java.lang.CharSequence)
- */
- public void warn(CharSequence content) {
- _log.warn(content);
- }
+ /**
+ * @param content
+ * @see org.apache.maven.plugin.logging.Log#warn(java.lang.CharSequence)
+ */
+ public void warn(CharSequence content) {
+ log.warn(content);
+ }
- /**
- * @param error
- * @see org.apache.maven.plugin.logging.Log#warn(java.lang.Throwable)
- */
- public void warn(Throwable error) {
- _log.warn(error);
- }
-
+ /**
+ * @param error
+ * @see org.apache.maven.plugin.logging.Log#warn(java.lang.Throwable)
+ */
+ public void warn(Throwable error) {
+ log.warn(error);
+ }
}
Modified:
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractCDKMojo.java
===================================================================
---
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractCDKMojo.java 2009-11-01
16:27:54 UTC (rev 15791)
+++
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractCDKMojo.java 2009-11-01
16:28:50 UTC (rev 15792)
@@ -19,347 +19,390 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.mojo;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+
+import org.codehaus.plexus.util.DirectoryScanner;
+
import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
+
import java.lang.reflect.Method;
+
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
+
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.DependencyResolutionRequiredException;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.project.MavenProject;
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.VelocityEngine;
-import org.apache.velocity.exception.MethodInvocationException;
-import org.apache.velocity.exception.ParseErrorException;
-import org.apache.velocity.exception.ResourceNotFoundException;
-import org.codehaus.plexus.util.DirectoryScanner;
-import org.codehaus.plexus.velocity.VelocityComponent;
-
/**
* @author shura
*
*/
public abstract class AbstractCDKMojo extends AbstractMojo {
- /**
- * Top maven project.
- *
- * @parameter expression="${project}"
- * @readonly
- */
- protected MavenProject project;
- /**
- *
- * @parameter
- */
- protected String key;
- /**
- * Place for component configuration XML files. All '*.xml' files wil be
- * parsed as components config. All '*.ent' files will be processed as
- * include configurations.
- *
- * @parameter expression="src/main/config/component"
- */
- protected File componentConfigDirectory;
- /**
- * Place for validator configuration XML files. All '*.xml' files wil be
- * parsed as component config. All '*.ent' files will be processed as
- * include configurations.
- *
- * @parameter expression="src/main/config/validator"
- */
- protected File validatorConfigDirectory;
+ /**
+ * Project classpath.
+ *
+ * @parameter expression="${project.compileClasspathElements}"
+ * @required
+ * @readonly
+ */
+ protected List classpathElements;
- /**
- * Place for converter configuration XML files. All '*.xml' files wil be
- * parsed as components config. All '*.ent' files will be processed as
- * include configurations.
- *
- * @parameter expression="src/main/config/converter"
- */
- protected File converterConfigDirectory;
+ /**
+ * The source directories containing the sources to be compiled.
+ *
+ * @parameter expression="${project.compileSourceRoots}"
+ * @required
+ * @readonly
+ */
+ protected List<String> compileSourceRoots;
- /**
- * Place for faces configuration XML files
- *
- * @parameter expression="src/main/config/faces"
- */
- protected File facesConfigInclude;
- /**
- * Place for component configuration XML files
- *
- * @parameter expression="src/main/config/taglib"
- */
- protected File taglibInclude;
- /**
- * Place for component configuration XML files
- *
- * @parameter expression="src/main/config/resources"
- */
- protected File resourcesInclude;
- /**
- *
- * @parameter expression="src/main/templates"
- */
- protected File templatesDirectory;
- /**
- * Directory where the output Java Files will be located.
- *
- * @parameter
expression="${project.build.directory}/generated-component/java"
- */
- protected File outputJavaDirectory;
+ /**
+ * Place for component configuration XML files. All '*.xml' files wil be
+ * parsed as components config. All '*.ent' files will be processed as
+ * include configurations.
+ *
+ * @parameter expression="src/main/config/component"
+ */
+ protected File componentConfigDirectory;
- /**
- * @parameter
expression="${project.build.directory}/generated-component/test"
- */
- protected File outputTestsDirectory;
+ /**
+ * Place for converter configuration XML files. All '*.xml' files wil be
+ * parsed as components config. All '*.ent' files will be processed as
+ * include configurations.
+ *
+ * @parameter expression="src/main/config/converter"
+ */
+ protected File converterConfigDirectory;
- /**
- * Directory where the output Java Files will be located.
- *
- * @parameter
expression="${project.build.directory}/generated-component/resources"
- */
- protected File outputResourcesDirectory;
- /**
- * @parameter
- */
- protected Library library;
- /**
- * The source directories containing the sources to be compiled.
- *
- * @parameter expression="${project.compileSourceRoots}"
- * @required
- * @readonly
- */
- protected List<String> compileSourceRoots;
- /**
- * Project classpath.
- *
- * @parameter expression="${project.compileClasspathElements}"
- * @required
- * @readonly
- */
- protected List classpathElements;
- /**
- * The directory for compiled classes.
- *
- * @parameter expression="${project.build.outputDirectory}"
- * @required
- * @readonly
- */
- protected File outputDirectory;
- /**
- * Check library configuration, and fill all empty values to default.
- *
- * @return
- */
- protected Taglib checkLibraryConfig() {
- if (null != library) {
- getLog().debug("Library prefix is " + library.getPrefix());
- } else {
- library = new Library();
- }
- if (null == library.getPrefix()) {
- library.setPrefix(project.getGroupId());
+ /**
+ * Place for faces configuration XML files
+ *
+ * @parameter expression="src/main/config/faces"
+ */
+ protected File facesConfigInclude;
- }
- getLog().debug("Default prefix for a generated packages:
"+library.getPrefix());
- if (null == library.getDescription()) {
- library.setDescription(project.getDescription());
- }
- getLog().debug("Library description: "+library.getDescription());
- if( null == library.getJsfVersion()){
- String version = Library.JSF11;
- // Check version-specific methods in UIComponent class
- try {
- Class<?> componentClass = createProjectClassLoader(project,
false).loadClass("javax.faces.component.UIComponent");
- Method[] methods = componentClass.getDeclaredMethods();
- for (int i = 0; i < methods.length; i++) {
- if("encodeAll".equals(methods[i].getName())){
- version = Library.JSF12;
- break;
- }
- }
- } catch (ClassNotFoundException e) {
- // Ignore - by defaule, generate codes for JSF 1.1
- }
- library.setJsfVersion(version);
- }
-
- //velocity = new DefaultVelocityComponent();
-
- getLog().debug("Generate files for a JSF "+library.getJsfVersion());
- Renderkit[] renderkits = library.getRenderkits();
- if (null != renderkits) {
- for (int i = 0; i < renderkits.length; i++) {
- Renderkit renderkit = renderkits[i];
- getLog().debug("Renderkit name is " + renderkit.getName());
- if(null == renderkit.getPackage()){
- renderkit.setPackage(library.getPrefix()+".renderkit."+renderkit.getName().toLowerCase());
- }
- }
- } else {
- renderkits = new Renderkit[1];
- Renderkit renderkit = new Renderkit();
- renderkit.setMarkup("html");
- renderkit.setName("HTML_BASIC");
- renderkit.setPackage(library.getPrefix()+".renderkit."+renderkit.getName().toLowerCase());
- renderkits[0] = renderkit;
- library.setRenderkits(renderkits);
- }
- Taglib taglib = library.getTaglib();
- if (null != taglib) {
- getLog().debug("Taglib uri is " + taglib.getUri());
- getLog().debug("Taglib shortname is " + taglib.getShortName());
- } else {
- taglib = new Taglib();
- library.setTaglib(taglib);
- }
- if (null == taglib.getDisplayName()) {
- taglib.setDisplayName(project.getDescription());
+ /**
+ *
+ * @parameter
+ */
+ protected String key;
- }
- if( null == taglib.getJspVersion()){
- // Jsf 1.2 can use JSP 2.1 only, other - 2.0
- taglib.setJspVersion(library.getJsfVersion().equals(Library.JSF12)?"2.1":"1.2");
- }
- if (null == taglib.getUri()) {
- String url = project.getUrl();
- if (null == url) {
- url = "http://";
- String[] parts = project.getGroupId().split(".");
- for (int i = parts.length - 1; i >= 0; i--) {
- url = url + parts[i];
- if (i > 0) {
- url = url + ".";
- }
- }
- url = url + "/" + project.getArtifactId();
- }
- taglib.setUri(url);
+ /**
+ * @parameter
+ */
+ protected Library library;
- }
- if (null == taglib.getShortName()) {
- taglib.setShortName(project.getArtifactId());
+ /**
+ * The directory for compiled classes.
+ *
+ * @parameter expression="${project.build.outputDirectory}"
+ * @required
+ * @readonly
+ */
+ protected File outputDirectory;
- }
- if(null == taglib.getTaglib()){
- taglib.setTaglib(taglib.getShortName());
- }
-
- if (null == taglib.getTlibVersion()) {
- taglib.setTlibVersion(createTaglibVersionFromProjectVersion());
- }
- getLog().debug("Taglib uri is " + taglib.getUri());
- getLog().debug("Taglib shortname is " + taglib.getShortName());
- if (null != library.getTaglibs() && library.getTaglibs().length > 0) {
- for (int i = 0; i < library.getTaglibs().length; i++) {
- Taglib t = library.getTaglibs()[i];
- checkTaglib(t);
- }
- }
- return taglib;
- }
+ /**
+ * Directory where the output Java Files will be located.
+ *
+ * @parameter
expression="${project.build.directory}/generated-component/java"
+ */
+ protected File outputJavaDirectory;
- private String createTaglibVersionFromProjectVersion() {
- Artifact artifact = project.getArtifact();
- String version = artifact.getVersion();
- Matcher matcher = Pattern.compile("^(\\d+(?:\\.\\d+)*)").matcher(version);
- if (matcher.find()) {
- return matcher.group(1);
- }
+ /**
+ * Directory where the output Java Files will be located.
+ *
+ * @parameter
expression="${project.build.directory}/generated-component/resources"
+ */
+ protected File outputResourcesDirectory;
- return "1.2";
- }
+ /**
+ * @parameter
expression="${project.build.directory}/generated-component/test"
+ */
+ protected File outputTestsDirectory;
- protected ClassLoader createProjectClassLoader(MavenProject project, boolean useCCL) {
- ClassLoader classLoader = Thread.currentThread()
- .getContextClassLoader();
- try {
- List<?> compileClasspathElements = project
- .getCompileClasspathElements();
- String outputDirectory = project.getBuild().getOutputDirectory();
- URL[] urls = new URL[compileClasspathElements.size() + 1];
- int i = 0;
- urls[i++] = new File(outputDirectory).toURI().toURL();
- for (Iterator<?> iter = compileClasspathElements.iterator(); iter
- .hasNext();) {
- String element = (String) iter.next();
- urls[i++] = new File(element).toURI().toURL();
- }
+ /**
+ * Top maven project.
+ *
+ * @parameter expression="${project}"
+ * @readonly
+ */
+ protected MavenProject project;
- if (useCCL) {
- classLoader = new URLClassLoader(urls, classLoader);
- } else {
- classLoader = new URLClassLoader(urls);
- }
- } catch (MalformedURLException e) {
- getLog().error("Bad URL in classpath", e);
- } catch (DependencyResolutionRequiredException e) {
- getLog().error("Dependencies not resolved ", e);
- }
+ /**
+ * Place for component configuration XML files
+ *
+ * @parameter expression="src/main/config/resources"
+ */
+ protected File resourcesInclude;
- return classLoader;
- }
+ /**
+ * Place for component configuration XML files
+ *
+ * @parameter expression="src/main/config/taglib"
+ */
+ protected File taglibInclude;
- protected ClassLoader createProjectClassLoader(MavenProject project) {
- return createProjectClassLoader(project, true);
- }
+ /**
+ *
+ * @parameter expression="src/main/templates"
+ */
+ protected File templatesDirectory;
- protected void checkTaglib(Taglib taglib) {
- if (null == taglib.getDisplayName()) {
- taglib.setDisplayName(library.getTaglib().getDisplayName());
- }
- if (null == taglib.getShortName()) {
- taglib.setShortName(library.getTaglib().getShortName());
- }
- if (null == taglib.getJspVersion()) {
- taglib.setJspVersion(library.getTaglib().getJspVersion());
- }
- if (null == taglib.getUri()) {
- taglib.setUri(library.getTaglib().getUri() + "/"
- + taglib.getShortName());
- }
- if(null == taglib.getTaglib()){
- taglib.setTaglib(taglib.getShortName());
- }
- if (null == taglib.getTlibVersion()) {
- taglib.setTlibVersion(createTaglibVersionFromProjectVersion());
- }
- getLog().debug("Taglib uri is " + taglib.getUri());
- getLog().debug("Taglib shortname is " + taglib.getShortName());
- getLog().debug("Taglib version is " + taglib.getTlibVersion());
- }
+ /**
+ * Place for validator configuration XML files. All '*.xml' files wil be
+ * parsed as component config. All '*.ent' files will be processed as
+ * include configurations.
+ *
+ * @parameter expression="src/main/config/validator"
+ */
+ protected File validatorConfigDirectory;
- protected String[] doScan(String[] includes, String[] excludes, File rootFolder)
- throws MojoExecutionException {
- try {
- DirectoryScanner directoryScanner = new DirectoryScanner();
- directoryScanner.setFollowSymlinks(true);
- directoryScanner.setBasedir(rootFolder);
- directoryScanner.setExcludes(excludes);
- directoryScanner.setIncludes(includes);
- directoryScanner.addDefaultExcludes();
+ /**
+ * Check library configuration, and fill all empty values to default.
+ *
+ * @return
+ */
+ protected Taglib checkLibraryConfig() {
+ if (null != library) {
+ getLog().debug("Library prefix is " + library.getPrefix());
+ } else {
+ library = new Library();
+ }
- directoryScanner.scan();
+ if (null == library.getPrefix()) {
+ library.setPrefix(project.getGroupId());
+ }
- return directoryScanner.getIncludedFiles();
- } catch (IllegalStateException e) {
- throw new MojoExecutionException(
- "Error scanning source root: \'" + rootFolder + "\'", e
);
- }
- }
+ getLog().debug("Default prefix for a generated packages: " +
library.getPrefix());
+ if (null == library.getDescription()) {
+ library.setDescription(project.getDescription());
+ }
+
+ getLog().debug("Library description: " + library.getDescription());
+
+ if (null == library.getJsfVersion()) {
+ String version = Library.JSF11;
+
+ // Check version-specific methods in UIComponent class
+ try {
+ Class<?> componentClass = createProjectClassLoader(project,
+
false).loadClass("javax.faces.component.UIComponent");
+ Method[] methods = componentClass.getDeclaredMethods();
+
+ for (int i = 0; i < methods.length; i++) {
+ if ("encodeAll".equals(methods[i].getName())) {
+ version = Library.JSF12;
+
+ break;
+ }
+ }
+ } catch (ClassNotFoundException e) {
+
+ // Ignore - by defaule, generate codes for JSF 1.1
+ }
+
+ library.setJsfVersion(version);
+ }
+
+ // velocity = new DefaultVelocityComponent();
+ getLog().debug("Generate files for a JSF " + library.getJsfVersion());
+
+ Renderkit[] renderkits = library.getRenderkits();
+
+ if (null != renderkits) {
+ for (int i = 0; i < renderkits.length; i++) {
+ Renderkit renderkit = renderkits[i];
+
+ getLog().debug("Renderkit name is " + renderkit.getName());
+
+ if (null == renderkit.getPackage()) {
+ renderkit.setPackage(library.getPrefix() + ".renderkit." +
renderkit.getName().toLowerCase());
+ }
+ }
+ } else {
+ renderkits = new Renderkit[1];
+
+ Renderkit renderkit = new Renderkit();
+
+ renderkit.setMarkup("html");
+ renderkit.setName("HTML_BASIC");
+ renderkit.setPackage(library.getPrefix() + ".renderkit." +
renderkit.getName().toLowerCase());
+ renderkits[0] = renderkit;
+ library.setRenderkits(renderkits);
+ }
+
+ Taglib taglib = library.getTaglib();
+
+ if (null != taglib) {
+ getLog().debug("Taglib uri is " + taglib.getUri());
+ getLog().debug("Taglib shortname is " + taglib.getShortName());
+ } else {
+ taglib = new Taglib();
+ library.setTaglib(taglib);
+ }
+
+ if (null == taglib.getDisplayName()) {
+ taglib.setDisplayName(project.getDescription());
+ }
+
+ if (null == taglib.getJspVersion()) {
+
+ // Jsf 1.2 can use JSP 2.1 only, other - 2.0
+ taglib.setJspVersion(library.getJsfVersion().equals(Library.JSF12) ?
"2.1" : "1.2");
+ }
+
+ if (null == taglib.getUri()) {
+ String url = project.getUrl();
+
+ if (null == url) {
+ url = "http://";
+
+ String[] parts = project.getGroupId().split(".");
+
+ for (int i = parts.length - 1; i >= 0; i--) {
+ url = url + parts[i];
+
+ if (i > 0) {
+ url = url + ".";
+ }
+ }
+
+ url = url + "/" + project.getArtifactId();
+ }
+
+ taglib.setUri(url);
+ }
+
+ if (null == taglib.getShortName()) {
+ taglib.setShortName(project.getArtifactId());
+ }
+
+ if (null == taglib.getTaglib()) {
+ taglib.setTaglib(taglib.getShortName());
+ }
+
+ if (null == taglib.getTlibVersion()) {
+ taglib.setTlibVersion(createTaglibVersionFromProjectVersion());
+ }
+
+ getLog().debug("Taglib uri is " + taglib.getUri());
+ getLog().debug("Taglib shortname is " + taglib.getShortName());
+
+ if (null != library.getTaglibs() && library.getTaglibs().length > 0)
{
+ for (int i = 0; i < library.getTaglibs().length; i++) {
+ Taglib t = library.getTaglibs()[i];
+
+ checkTaglib(t);
+ }
+ }
+
+ return taglib;
+ }
+
+ private String createTaglibVersionFromProjectVersion() {
+ Artifact artifact = project.getArtifact();
+ String version = artifact.getVersion();
+ Matcher matcher =
Pattern.compile("^(\\d+(?:\\.\\d+)*)").matcher(version);
+
+ if (matcher.find()) {
+ return matcher.group(1);
+ }
+
+ return "1.2";
+ }
+
+ protected ClassLoader createProjectClassLoader(MavenProject project, boolean useCCL)
{
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+
+ try {
+ List<?> compileClasspathElements =
project.getCompileClasspathElements();
+ String outputDirectory = project.getBuild().getOutputDirectory();
+ URL[] urls = new URL[compileClasspathElements.size() + 1];
+ int i = 0;
+
+ urls[i++] = new File(outputDirectory).toURI().toURL();
+
+ for (Iterator<?> iter = compileClasspathElements.iterator();
iter.hasNext(); ) {
+ String element = (String) iter.next();
+
+ urls[i++] = new File(element).toURI().toURL();
+ }
+
+ if (useCCL) {
+ classLoader = new URLClassLoader(urls, classLoader);
+ } else {
+ classLoader = new URLClassLoader(urls);
+ }
+ } catch (MalformedURLException e) {
+ getLog().error("Bad URL in classpath", e);
+ } catch (DependencyResolutionRequiredException e) {
+ getLog().error("Dependencies not resolved ", e);
+ }
+
+ return classLoader;
+ }
+
+ protected ClassLoader createProjectClassLoader(MavenProject project) {
+ return createProjectClassLoader(project, true);
+ }
+
+ protected void checkTaglib(Taglib taglib) {
+ if (null == taglib.getDisplayName()) {
+ taglib.setDisplayName(library.getTaglib().getDisplayName());
+ }
+
+ if (null == taglib.getShortName()) {
+ taglib.setShortName(library.getTaglib().getShortName());
+ }
+
+ if (null == taglib.getJspVersion()) {
+ taglib.setJspVersion(library.getTaglib().getJspVersion());
+ }
+
+ if (null == taglib.getUri()) {
+ taglib.setUri(library.getTaglib().getUri() + "/" +
taglib.getShortName());
+ }
+
+ if (null == taglib.getTaglib()) {
+ taglib.setTaglib(taglib.getShortName());
+ }
+
+ if (null == taglib.getTlibVersion()) {
+ taglib.setTlibVersion(createTaglibVersionFromProjectVersion());
+ }
+
+ getLog().debug("Taglib uri is " + taglib.getUri());
+ getLog().debug("Taglib shortname is " + taglib.getShortName());
+ getLog().debug("Taglib version is " + taglib.getTlibVersion());
+ }
+
+ protected String[] doScan(String[] includes, String[] excludes, File rootFolder)
throws MojoExecutionException {
+ try {
+ DirectoryScanner directoryScanner = new DirectoryScanner();
+
+ directoryScanner.setFollowSymlinks(true);
+ directoryScanner.setBasedir(rootFolder);
+ directoryScanner.setExcludes(excludes);
+ directoryScanner.setIncludes(includes);
+ directoryScanner.addDefaultExcludes();
+ directoryScanner.scan();
+
+ return directoryScanner.getIncludedFiles();
+ } catch (IllegalStateException e) {
+ throw new MojoExecutionException("Error scanning source root:
\'" + rootFolder + "\'", e);
+ }
+ }
}
Modified:
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractGenerateMojo.java
===================================================================
---
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractGenerateMojo.java 2009-11-01
16:27:54 UTC (rev 15791)
+++
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractGenerateMojo.java 2009-11-01
16:28:50 UTC (rev 15792)
@@ -19,202 +19,200 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.mojo;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+
+import org.codehaus.plexus.util.DirectoryScanner;
+
import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.lang.reflect.Method;
+
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
+
import java.util.Iterator;
import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.DependencyResolutionRequiredException;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.project.MavenProject;
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.VelocityEngine;
-import org.apache.velocity.exception.MethodInvocationException;
-import org.apache.velocity.exception.ParseErrorException;
-import org.apache.velocity.exception.ResourceNotFoundException;
-import org.codehaus.plexus.util.DirectoryScanner;
-import org.codehaus.plexus.velocity.VelocityComponent;
-
/**
* @author shura
*
*/
public abstract class AbstractGenerateMojo extends AbstractMojo {
- /**
- * Top maven project.
- *
- * @parameter expression="${project}"
- * @readonly
- */
- protected MavenProject project;
- /**
- *
- * @parameter
- */
- protected String key;
- /**
- * Place for component configuration XML files. All '*.xml' files wil be
- * parsed as components config. All '*.ent' files will be processed as
- * include configurations.
- *
- * @parameter expression="src/main/config/component"
- */
- protected File componentConfigDirectory;
- /**
- * Place for validator configuration XML files. All '*.xml' files wil be
- * parsed as component config. All '*.ent' files will be processed as
- * include configurations.
- *
- * @parameter expression="src/main/config/validator"
- */
- protected File validatorConfigDirectory;
+ /**
+ * Project classpath.
+ *
+ * @parameter expression="${project.compileClasspathElements}"
+ * @required
+ * @readonly
+ */
+ protected List<String> classpathElements;
- /**
- * Place for converter configuration XML files. All '*.xml' files wil be
- * parsed as components config. All '*.ent' files will be processed as
- * include configurations.
- *
- * @parameter expression="src/main/config/converter"
- */
- protected File converterConfigDirectory;
+ /**
+ * The source directories containing the sources to be compiled.
+ *
+ * @parameter expression="${project.compileSourceRoots}"
+ * @required
+ * @readonly
+ */
+ protected List<String> compileSourceRoots;
- /**
- * Place for faces configuration XML files
- *
- * @parameter expression="src/main/config/faces"
- */
- protected File facesConfigInclude;
- /**
- * Place for component configuration XML files
- *
- * @parameter expression="src/main/config/taglib"
- */
- protected File taglibInclude;
- /**
- * Place for component configuration XML files
- *
- * @parameter expression="src/main/config/resources"
- */
- protected File resourcesInclude;
- /**
- *
- * @parameter expression="src/main/templates"
- */
- protected File templatesDirectory;
- /**
- * Directory where the output Java Files will be located.
- *
- * @parameter
expression="${project.build.directory}/generated-component/java"
- */
- protected File outputJavaDirectory;
+ /**
+ * Place for component configuration XML files. All '*.xml' files wil be
+ * parsed as components config. All '*.ent' files will be processed as
+ * include configurations.
+ *
+ * @parameter expression="src/main/config/component"
+ */
+ protected File componentConfigDirectory;
- /**
- * @parameter
expression="${project.build.directory}/generated-component/test"
- */
- protected File outputTestsDirectory;
+ /**
+ * Place for converter configuration XML files. All '*.xml' files wil be
+ * parsed as components config. All '*.ent' files will be processed as
+ * include configurations.
+ *
+ * @parameter expression="src/main/config/converter"
+ */
+ protected File converterConfigDirectory;
- /**
- * Directory where the output Java Files will be located.
- *
- * @parameter
expression="${project.build.directory}/generated-component/resources"
- */
- protected File outputResourcesDirectory;
+ /**
+ * Place for faces configuration XML files
+ *
+ * @parameter expression="src/main/config/faces"
+ */
+ protected File facesConfigInclude;
- /**
- * @parameter
expression="${project.build.directory}/generated-component/test-resources"
- */
- protected File outputTestsResourcesDirectory;
-
-
- /**
- * @parameter
- */
- protected Library library;
- /**
- * The source directories containing the sources to be compiled.
- *
- * @parameter expression="${project.compileSourceRoots}"
- * @required
- * @readonly
- */
- protected List<String> compileSourceRoots;
- /**
- * Project classpath.
- *
- * @parameter expression="${project.compileClasspathElements}"
- * @required
- * @readonly
- */
- protected List<String> classpathElements;
- /**
- * The directory for compiled classes.
- *
- * @parameter expression="${project.build.outputDirectory}"
- * @required
- * @readonly
- */
- protected File outputDirectory;
-
-
- protected ClassLoader createProjectClassLoader(MavenProject project, boolean useCCL) {
- ClassLoader classLoader = Thread.currentThread()
- .getContextClassLoader();
- try {
- URL[] urls = new URL[classpathElements.size() + 1];
- int i = 0;
- urls[i++] = outputDirectory.toURI().toURL();
- for (Iterator<?> iter = classpathElements.iterator(); iter
- .hasNext();) {
- String element = (String) iter.next();
- urls[i++] = new File(element).toURI().toURL();
- }
+ /**
+ *
+ * @parameter
+ */
+ protected String key;
- if (useCCL) {
- classLoader = new URLClassLoader(urls, classLoader);
- } else {
- classLoader = new URLClassLoader(urls);
- }
- } catch (MalformedURLException e) {
- getLog().error("Bad URL in classpath", e);
- }
+ /**
+ * @parameter
+ */
+ protected Library library;
- return classLoader;
- }
+ /**
+ * The directory for compiled classes.
+ *
+ * @parameter expression="${project.build.outputDirectory}"
+ * @required
+ * @readonly
+ */
+ protected File outputDirectory;
- protected ClassLoader createProjectClassLoader(MavenProject project) {
- return createProjectClassLoader(project, true);
- }
+ /**
+ * Directory where the output Java Files will be located.
+ *
+ * @parameter
expression="${project.build.directory}/generated-component/java"
+ */
+ protected File outputJavaDirectory;
- protected String[] doScan(String[] includes, String[] excludes, File rootFolder)
- throws MojoExecutionException {
- try {
- DirectoryScanner directoryScanner = new DirectoryScanner();
- directoryScanner.setFollowSymlinks(true);
- directoryScanner.setBasedir(rootFolder);
- directoryScanner.setExcludes(excludes);
- directoryScanner.setIncludes(includes);
- directoryScanner.addDefaultExcludes();
+ /**
+ * Directory where the output Java Files will be located.
+ *
+ * @parameter
expression="${project.build.directory}/generated-component/resources"
+ */
+ protected File outputResourcesDirectory;
- directoryScanner.scan();
+ /**
+ * @parameter
expression="${project.build.directory}/generated-component/test"
+ */
+ protected File outputTestsDirectory;
- return directoryScanner.getIncludedFiles();
- } catch (IllegalStateException e) {
- throw new MojoExecutionException(
- "Error scanning source root: \'" + rootFolder + "\'", e
);
- }
- }
+ /**
+ * @parameter
expression="${project.build.directory}/generated-component/test-resources"
+ */
+ protected File outputTestsResourcesDirectory;
+ /**
+ * Top maven project.
+ *
+ * @parameter expression="${project}"
+ * @readonly
+ */
+ protected MavenProject project;
+
+ /**
+ * Place for component configuration XML files
+ *
+ * @parameter expression="src/main/config/resources"
+ */
+ protected File resourcesInclude;
+
+ /**
+ * Place for component configuration XML files
+ *
+ * @parameter expression="src/main/config/taglib"
+ */
+ protected File taglibInclude;
+
+ /**
+ *
+ * @parameter expression="src/main/templates"
+ */
+ protected File templatesDirectory;
+
+ /**
+ * Place for validator configuration XML files. All '*.xml' files wil be
+ * parsed as component config. All '*.ent' files will be processed as
+ * include configurations.
+ *
+ * @parameter expression="src/main/config/validator"
+ */
+ protected File validatorConfigDirectory;
+
+ protected ClassLoader createProjectClassLoader(MavenProject project, boolean useCCL)
{
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+
+ try {
+ URL[] urls = new URL[classpathElements.size() + 1];
+ int i = 0;
+
+ urls[i++] = outputDirectory.toURI().toURL();
+
+ for (Iterator<?> iter = classpathElements.iterator(); iter.hasNext(); )
{
+ String element = (String) iter.next();
+
+ urls[i++] = new File(element).toURI().toURL();
+ }
+
+ if (useCCL) {
+ classLoader = new URLClassLoader(urls, classLoader);
+ } else {
+ classLoader = new URLClassLoader(urls);
+ }
+ } catch (MalformedURLException e) {
+ getLog().error("Bad URL in classpath", e);
+ }
+
+ return classLoader;
+ }
+
+ protected ClassLoader createProjectClassLoader(MavenProject project) {
+ return createProjectClassLoader(project, true);
+ }
+
+ protected String[] doScan(String[] includes, String[] excludes, File rootFolder)
throws MojoExecutionException {
+ try {
+ DirectoryScanner directoryScanner = new DirectoryScanner();
+
+ directoryScanner.setFollowSymlinks(true);
+ directoryScanner.setBasedir(rootFolder);
+ directoryScanner.setExcludes(excludes);
+ directoryScanner.setIncludes(includes);
+ directoryScanner.addDefaultExcludes();
+ directoryScanner.scan();
+
+ return directoryScanner.getIncludedFiles();
+ } catch (IllegalStateException e) {
+ throw new MojoExecutionException("Error scanning source root:
\'" + rootFolder + "\'", e);
+ }
+ }
}
Modified:
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CompileMojo.java
===================================================================
---
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CompileMojo.java 2009-11-01
16:27:54 UTC (rev 15791)
+++
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CompileMojo.java 2009-11-01
16:28:50 UTC (rev 15792)
@@ -19,13 +19,18 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.mojo;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
+
import java.io.File;
+
import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
+
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
@@ -38,6 +43,7 @@
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.project.ProjectBuildingException;
+
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.archiver.manager.ArchiverManager;
@@ -49,246 +55,268 @@
/**
* Compile all xml templates, matched given pattern to Java classes. Sources
* will be created in {@link AbstractCDKMojo#outputJavaDirectory}
- *
+ *
* @goal compile
* @requiresDependencyResolution compile
* @phase generate-sources
* @author shura
- *
+ *
*/
public class CompileMojo extends AbstractCDKMojo implements Contextualizable {
- /**
- * Project executed by first compile lifecycle.
- *
- * @parameter expression="${executedProject}"
- * @readonly
- */
- private MavenProject executedProject;
+ /**
+ * To look up Archiver/UnArchiver implementations
+ *
+ * @component
+ */
+ private ArchiverManager archiverManager;
+ private PlexusContainer container;
- /**
- * The reactor projects.
- *
- * @parameter expression="${project.parent}"
- * @readonly
- */
- private MavenProject parentProject;
- /**
- * @parameter default-value=${project.groupId}
- */
- private String defaultPackage;
+ /**
+ * @parameter default-value=${project.groupId}
+ */
+ private String defaultPackage;
- /**
- * A list of inclusion filters for the compiler. By default, include all
- * files in templates directory.
- *
- * @parameter
- */
- private String[] includes;
+ /**
+ * A list of exclusion filters for the compiler. None by default.
+ *
+ * @parameter
+ */
+ private String[] excludes;
- /**
- * A list of exclusion filters for the compiler. None by default.
- *
- * @parameter
- */
- private String[] excludes;
+ /**
+ * Project executed by first compile lifecycle.
+ *
+ * @parameter expression="${executedProject}"
+ * @readonly
+ */
+ private MavenProject executedProject;
- /**
- * The local repository.
- *
- * @parameter expression="${localRepository}"
- */
- private ArtifactRepository localRepository;
+ /**
+ * A list of inclusion filters for the compiler. By default, include all
+ * files in templates directory.
+ *
+ * @parameter
+ */
+ private String[] includes;
- /**
- * To look up Archiver/UnArchiver implementations
- *
- * @component
- */
- private ArchiverManager archiverManager;
+ /**
+ * The local repository.
+ *
+ * @parameter expression="${localRepository}"
+ */
+ private ArtifactRepository localRepository;
- /**
- * Project builder
- *
- * @component
- */
- private MavenProjectBuilder mavenProjectBuilder;
- private PlexusContainer container;
+ /**
+ * Project builder
+ *
+ * @component
+ */
+ private MavenProjectBuilder mavenProjectBuilder;
- /*
- * (non-Javadoc)
- *
- * @see org.apache.maven.plugin.Mojo#execute()
- */
- public void execute() throws MojoExecutionException, MojoFailureException {
+ /**
+ * The reactor projects.
+ *
+ * @parameter expression="${project.parent}"
+ * @readonly
+ */
+ private MavenProject parentProject;
- // VelocityTemplates.init();
- try {
- List components = container
- .lookupList("org.richfaces.templatecompiler.elements.ElementsFactory");
- for (Iterator iter = components.iterator(); iter.hasNext();) {
- Object element = iter.next();
- System.out.println(element.getClass().getName());
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.maven.plugin.Mojo#execute()
+ */
+ public void execute() throws MojoExecutionException, MojoFailureException {
- }
- System.out.println("Components Map");
- Map componentsMap = container
- .lookupMap("org.richfaces.templatecompiler.elements.ElementsFactory");
- for (Iterator iter = componentsMap.entrySet().iterator(); iter
- .hasNext();) {
- Map.Entry element = (Map.Entry) iter.next();
- System.out.println(element.getKey() + ":"
- + element.getValue().getClass().getName());
- }
- } catch (ComponentLookupException e) {
- throw new MojoExecutionException(
- "Error lookup ElementFactory components");
- }
- Parent parentModel = project.getModel().getParent();
- if (null != parentModel) {
- String relativePath = parentModel.getRelativePath();
- File parentPom = new File(project.getFile().getParentFile(), relativePath);
- if (parentPom.isDirectory()) {
- parentPom = new File(parentPom, "pom.xml");
- }
- if (parentPom.exists()) {
- try {
- parentProject = mavenProjectBuilder.build(parentPom,
- localRepository, null);
- } catch (ProjectBuildingException e) {
- throw new MojoExecutionException("Error get parent project for a components
library",e);
- }
- } else {
- throw new MojoFailureException("Parent project pom file
"+parentPom.getAbsolutePath()+" is not found for a components
library");
- }
- }else {
- throw new MojoFailureException("Components library project must have parent pom
with components modules");
- }
- getLog().info("Parent Project object :\n" + toLog(parentProject) +
"\n");
- getLog().info("Project object :\n" + toLog(project) + "\n");
- getLog().info("Project object Model :\n" + toLog(project.getModel()) +
"\n");
- getLog().info("Project object Parent Model :\n" +
toLog(project.getModel().getParent()) + "\n");
-
- getLog().info(
- "Executed Project object :\n" + toLog(executedProject) + "\n");
- }
+ // VelocityTemplates.init();
+ try {
+ List components =
container.lookupList("org.richfaces.templatecompiler.elements.ElementsFactory");
- /*
- * (non-Javadoc)
- *
- * @see
org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable#contextualize(org.codehaus.plexus.context.Context)
- */
- public void contextualize(Context context) throws ContextException {
- this.container = (PlexusContainer) context
- .get(PlexusConstants.PLEXUS_KEY);
+ for (Iterator iter = components.iterator(); iter.hasNext(); ) {
+ Object element = iter.next();
- }
+ System.out.println(element.getClass().getName());
+ }
- private void logBean(Object bean) {
- StringBuffer content = new StringBuffer();
- }
+ System.out.println("Components Map");
- /**
- * Convert any Java Object to JavaScript representation ( as possible ).
- *
- * @param obj
- * @return
- * @throws MojoExecutionException
- */
- public String toLog(Object obj) throws MojoExecutionException {
- if (null == obj) {
- return "null";
- } else if (obj.getClass().isArray()) {
- StringBuffer ret = new StringBuffer("[");
- boolean first = true;
- for (int i = 0; i < Array.getLength(obj); i++) {
- Object element = Array.get(obj, i);
- if (!first) {
- ret.append(',');
- }
- ret.append(toLog(element));
- first = false;
- }
- return ret.append("]\n").toString();
- } else if (obj instanceof Collection) {
- // Collections put as JavaScript array.
- Collection collection = (Collection) obj;
- StringBuffer ret = new StringBuffer("[");
- boolean first = true;
- for (Iterator iter = collection.iterator(); iter.hasNext();) {
- Object element = iter.next();
- if (!first) {
- ret.append(',');
- }
- ret.append(toLog(element));
- first = false;
- }
- return ret.append("]\n").toString();
- } else if (obj instanceof Map) {
- // Maps put as JavaScript hash.
- Map map = (Map) obj;
+ Map componentsMap =
container.lookupMap("org.richfaces.templatecompiler.elements.ElementsFactory");
- StringBuffer ret = new StringBuffer("{");
- boolean first = true;
- for (Iterator iter = map.keySet().iterator(); iter.hasNext();) {
- Object key = (Object) iter.next();
- if (!first) {
- ret.append(',');
- }
- ret.append(key);
- ret.append(":");
- ret.append(toLog(map.get(key)));
- first = false;
- }
- return ret.append("}\n").toString();
- } else if (obj instanceof Number || obj instanceof Boolean) {
- // numbers and boolean put as-is, without conversion
- return obj.toString();
- } else if (obj instanceof String) {
- // all other put as encoded strings.
- StringBuffer ret = new StringBuffer();
- addEncodedString(ret, obj);
- return ret.append("\n").toString();
- }
- // All other objects threaded as Java Beans.
- try {
- StringBuffer ret = new StringBuffer("{");
- PropertyDescriptor[] propertyDescriptors = Introspector
- .getBeanInfo(obj.getClass()).getPropertyDescriptors();
- boolean first = true;
- for (int i = 0; i < propertyDescriptors.length; i++) {
- PropertyDescriptor propertyDescriptor = propertyDescriptors[i];
- String key = propertyDescriptor.getName();
- if (!"class".equals(key)
- && propertyDescriptor.getReadMethod() != null) {
- if (!first) {
- ret.append(",\n\t");
- }
- addEncodedString(ret, key);
- ret.append(":");
- try {
- Object value = propertyDescriptor.getReadMethod()
- .invoke(obj, new Object[] {});
- propertyDescriptor.getReadMethod();
- ret.append(String.valueOf(value));
- } catch (InvocationTargetException e) {
- ret.append("null");
- }// ret.append(toLog(PropertyUtils.getProperty(obj, key)));
- first = false;
- }
- }
- return ret.append("}\n").toString();
- } catch (Exception e) {
- throw new MojoExecutionException(
- "Error in conversion Java Object to String", e);
- }
- }
+ for (Iterator iter = componentsMap.entrySet().iterator(); iter.hasNext(); )
{
+ Map.Entry element = (Map.Entry) iter.next();
- public void addEncodedString(StringBuffer buff, Object obj) {
- buff.append("'");
- buff.append(obj);
- buff.append("'");
+ System.out.println(element.getKey() + ":" +
element.getValue().getClass().getName());
+ }
+ } catch (ComponentLookupException e) {
+ throw new MojoExecutionException("Error lookup ElementFactory
components");
+ }
- }
+ Parent parentModel = project.getModel().getParent();
+ if (null != parentModel) {
+ String relativePath = parentModel.getRelativePath();
+ File parentPom = new File(project.getFile().getParentFile(), relativePath);
+
+ if (parentPom.isDirectory()) {
+ parentPom = new File(parentPom, "pom.xml");
+ }
+
+ if (parentPom.exists()) {
+ try {
+ parentProject = mavenProjectBuilder.build(parentPom, localRepository,
null);
+ } catch (ProjectBuildingException e) {
+ throw new MojoExecutionException("Error get parent project for a
components library", e);
+ }
+ } else {
+ throw new MojoFailureException("Parent project pom file " +
parentPom.getAbsolutePath()
+ + " is not found for a components
library");
+ }
+ } else {
+ throw new MojoFailureException("Components library project must have
parent pom with components modules");
+ }
+
+ getLog().info("Parent Project object :\n" + toLog(parentProject) +
"\n");
+ getLog().info("Project object :\n" + toLog(project) + "\n");
+ getLog().info("Project object Model :\n" + toLog(project.getModel()) +
"\n");
+ getLog().info("Project object Parent Model :\n" +
toLog(project.getModel().getParent()) + "\n");
+ getLog().info("Executed Project object :\n" + toLog(executedProject) +
"\n");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable#contextualize(org.codehaus.plexus.context.Context)
+ */
+ public void contextualize(Context context) throws ContextException {
+ this.container = (PlexusContainer) context.get(PlexusConstants.PLEXUS_KEY);
+ }
+
+ private void logBean(Object bean) {
+ StringBuffer content = new StringBuffer();
+ }
+
+ /**
+ * Convert any Java Object to JavaScript representation ( as possible ).
+ *
+ * @param obj
+ * @return
+ * @throws MojoExecutionException
+ */
+ public String toLog(Object obj) throws MojoExecutionException {
+ if (null == obj) {
+ return "null";
+ } else if (obj.getClass().isArray()) {
+ StringBuffer ret = new StringBuffer("[");
+ boolean first = true;
+
+ for (int i = 0; i < Array.getLength(obj); i++) {
+ Object element = Array.get(obj, i);
+
+ if (!first) {
+ ret.append(',');
+ }
+
+ ret.append(toLog(element));
+ first = false;
+ }
+
+ return ret.append("]\n").toString();
+ } else if (obj instanceof Collection) {
+
+ // Collections put as JavaScript array.
+ Collection collection = (Collection) obj;
+ StringBuffer ret = new StringBuffer("[");
+ boolean first = true;
+
+ for (Iterator iter = collection.iterator(); iter.hasNext(); ) {
+ Object element = iter.next();
+
+ if (!first) {
+ ret.append(',');
+ }
+
+ ret.append(toLog(element));
+ first = false;
+ }
+
+ return ret.append("]\n").toString();
+ } else if (obj instanceof Map) {
+
+ // Maps put as JavaScript hash.
+ Map map = (Map) obj;
+ StringBuffer ret = new StringBuffer("{");
+ boolean first = true;
+
+ for (Iterator iter = map.keySet().iterator(); iter.hasNext(); ) {
+ Object key = (Object) iter.next();
+
+ if (!first) {
+ ret.append(',');
+ }
+
+ ret.append(key);
+ ret.append(":");
+ ret.append(toLog(map.get(key)));
+ first = false;
+ }
+
+ return ret.append("}\n").toString();
+ } else if (obj instanceof Number || obj instanceof Boolean) {
+
+ // numbers and boolean put as-is, without conversion
+ return obj.toString();
+ } else if (obj instanceof String) {
+
+ // all other put as encoded strings.
+ StringBuffer ret = new StringBuffer();
+
+ addEncodedString(ret, obj);
+
+ return ret.append("\n").toString();
+ }
+
+ // All other objects threaded as Java Beans.
+ try {
+ StringBuffer ret = new StringBuffer("{");
+ PropertyDescriptor[] propertyDescriptors =
+ Introspector.getBeanInfo(obj.getClass()).getPropertyDescriptors();
+ boolean first = true;
+
+ for (int i = 0; i < propertyDescriptors.length; i++) {
+ PropertyDescriptor propertyDescriptor = propertyDescriptors[i];
+ String key = propertyDescriptor.getName();
+
+ if (!"class".equals(key) &&
propertyDescriptor.getReadMethod() != null) {
+ if (!first) {
+ ret.append(",\n\t");
+ }
+
+ addEncodedString(ret, key);
+ ret.append(":");
+
+ try {
+ Object value = propertyDescriptor.getReadMethod().invoke(obj, new
Object[] {});
+
+ propertyDescriptor.getReadMethod();
+ ret.append(String.valueOf(value));
+ } catch (InvocationTargetException e) {
+ ret.append("null");
+ } // ret.append(toLog(PropertyUtils.getProperty(obj, key)));
+
+ first = false;
+ }
+ }
+
+ return ret.append("}\n").toString();
+ } catch (Exception e) {
+ throw new MojoExecutionException("Error in conversion Java Object to
String", e);
+ }
+ }
+
+ public void addEncodedString(StringBuffer buff, Object obj) {
+ buff.append("'");
+ buff.append(obj);
+ buff.append("'");
+ }
}
Modified:
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CompileTemplatesMojo.java
===================================================================
---
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CompileTemplatesMojo.java 2009-11-01
16:27:54 UTC (rev 15791)
+++
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CompileTemplatesMojo.java 2009-11-01
16:28:50 UTC (rev 15792)
@@ -19,16 +19,20 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.mojo;
import java.io.File;
import java.io.FileInputStream;
import java.io.PrintWriter;
+
import java.util.HashSet;
import java.util.Set;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
+
import org.richfaces.builder.model.JavaClass;
import org.richfaces.builder.render.JavaClassRenderer;
import org.richfaces.builder.templates.TemplateReader;
@@ -39,86 +43,80 @@
*/
public class CompileTemplatesMojo extends AbstractCDKMojo {
-
- /**
- * sourceFileIncludes
- * @parameter
- */
- protected String[] templateFileIncludes = {"**/*.template.xml"};
-
- /**
- * sourceFileExcludes
- * @parameter
- */
- protected String[] templatesFileExcludes = null;
-
- /**
- * @param templatesDirectory the templatesDirectory to set
- */
- protected void setTemplatesDirectory(File templatesDirectory) {
- this.templatesDirectory = templatesDirectory;
- }
-
- /**
- * @param templateFileIncludes the templateFileIncludes to set
- */
- public void setTemplateFileIncludes(String[] templateFileIncludes) {
- this.templateFileIncludes = templateFileIncludes;
- }
-
- /**
- * @param templatesFileExcludes the templatesFileExcludes to set
- */
- public void setTemplatesFileExcludes(String[] templatesFileExcludes) {
- this.templatesFileExcludes = templatesFileExcludes;
- }
-
- protected Iterable<File> findTemplateFiles() throws MojoExecutionException {
- Set<File> sourceFiles = new HashSet<File>();
- if (templatesDirectory.exists() && templatesDirectory.isDirectory()) {
- for (String fileName : doScan(templateFileIncludes, templatesFileExcludes,
templatesDirectory)) {
- sourceFiles.add(new File(templatesDirectory, fileName));
- }
- }
-
- return sourceFiles;
- }
-
- protected void compileTemplates() throws MojoExecutionException, MojoFailureException {
- try {
- Iterable<File> templates = findTemplateFiles();
- for (File file : templates) {
- JavaClass javaClass = TemplateReader.parse(new FileInputStream(file));
-
- String fullName = javaClass.getFullName();
-
- File outFile = new File(outputJavaDirectory,
- fullName.replace('.', '/') + ".java");
-
- if (outFile.exists()) {
- outFile.delete();
- }
+ /**
+ * sourceFileIncludes
+ * @parameter
+ */
+ protected String[] templateFileIncludes = {"**/*.template.xml"};
- outFile.getParentFile().mkdirs();
-
- new JavaClassRenderer().render(javaClass, new PrintWriter(outFile));
- }
- } catch (Exception e) {
- throw new MojoExecutionException(e.getMessage(), e);
- }
- }
-
- @Override
- public void execute() throws MojoExecutionException, MojoFailureException {
- outputJavaDirectory.mkdirs();
- outputResourcesDirectory.mkdirs();
- outputTestsDirectory.mkdirs();
-
- project.addCompileSourceRoot(outputJavaDirectory.getAbsolutePath());
- project.addCompileSourceRoot(outputResourcesDirectory.getAbsolutePath());
- project.addTestCompileSourceRoot(outputTestsDirectory.getAbsolutePath());
-
- compileTemplates();
- }
+ /**
+ * sourceFileExcludes
+ * @parameter
+ */
+ protected String[] templatesFileExcludes = null;
+ /**
+ * @param templatesDirectory the templatesDirectory to set
+ */
+ protected void setTemplatesDirectory(File templatesDirectory) {
+ this.templatesDirectory = templatesDirectory;
+ }
+
+ /**
+ * @param templateFileIncludes the templateFileIncludes to set
+ */
+ public void setTemplateFileIncludes(String[] templateFileIncludes) {
+ this.templateFileIncludes = templateFileIncludes;
+ }
+
+ /**
+ * @param templatesFileExcludes the templatesFileExcludes to set
+ */
+ public void setTemplatesFileExcludes(String[] templatesFileExcludes) {
+ this.templatesFileExcludes = templatesFileExcludes;
+ }
+
+ protected Iterable<File> findTemplateFiles() throws MojoExecutionException {
+ Set<File> sourceFiles = new HashSet<File>();
+
+ if (templatesDirectory.exists() && templatesDirectory.isDirectory()) {
+ for (String fileName : doScan(templateFileIncludes, templatesFileExcludes,
templatesDirectory)) {
+ sourceFiles.add(new File(templatesDirectory, fileName));
+ }
+ }
+
+ return sourceFiles;
+ }
+
+ protected void compileTemplates() throws MojoExecutionException, MojoFailureException
{
+ try {
+ Iterable<File> templates = findTemplateFiles();
+
+ for (File file : templates) {
+ JavaClass javaClass = TemplateReader.parse(new FileInputStream(file));
+ String fullName = javaClass.getFullName();
+ File outFile = new File(outputJavaDirectory,
fullName.replace('.', '/') + ".java");
+
+ if (outFile.exists()) {
+ outFile.delete();
+ }
+
+ outFile.getParentFile().mkdirs();
+ new JavaClassRenderer().render(javaClass, new PrintWriter(outFile));
+ }
+ } catch (Exception e) {
+ throw new MojoExecutionException(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ outputJavaDirectory.mkdirs();
+ outputResourcesDirectory.mkdirs();
+ outputTestsDirectory.mkdirs();
+ project.addCompileSourceRoot(outputJavaDirectory.getAbsolutePath());
+ project.addCompileSourceRoot(outputResourcesDirectory.getAbsolutePath());
+ project.addTestCompileSourceRoot(outputTestsDirectory.getAbsolutePath());
+ compileTemplates();
+ }
}
Modified:
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java
===================================================================
---
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java 2009-11-01
16:27:54 UTC (rev 15791)
+++
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java 2009-11-01
16:28:50 UTC (rev 15792)
@@ -21,408 +21,416 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.mojo;
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
-
-import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.model.FileSet;
import org.apache.maven.model.Resource;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
+
import org.codehaus.plexus.util.DirectoryScanner;
+
import org.richfaces.builder.maven.MavenLogger;
-import org.richfaces.cdk.CdkContextBase;
-import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.CdkWorker;
-import org.richfaces.cdk.LibraryBuilder;
-import org.richfaces.cdk.LoggerFactory;
-import org.richfaces.cdk.ModelValidator;
-import org.richfaces.cdk.NamingConventions;
-import org.richfaces.cdk.RichFacesConventions;
-import org.richfaces.cdk.StandardOutputFolders;
-import org.richfaces.cdk.StandardOutputs;
-import org.richfaces.cdk.StandardSources;
-import org.richfaces.cdk.ValidatorImpl;
+import org.richfaces.cdk.*;
import org.richfaces.cdk.model.ComponentLibrary;
+import java.io.File;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+import java.util.*;
+import java.util.Map.Entry;
+
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
* @goal generate
* @phase generate-sources
*/
public class GenerateMojo extends AbstractMojo {
+ private static final String[] JAVA_INCLUDES = new String[] {"**/*.java"};
+ private static final String MAIN_CONFIG = "src/main/config";
+ private static final String MAIN_TEMPLATES = "src/main/templates";
+ private static final String[] STRINGS_ARRAY = new String[0];
+ private static final String XML_INCLUDES = "**/*.xml";
- private static final String MAIN_CONFIG = "src/main/config";
+ /**
+ * Project classpath.
+ *
+ * @parameter expression="${project.compileClasspathElements}"
+ * @required
+ * @readonly
+ */
+ protected List<String> classpathElements;
- private static final String XML_INCLUDES = "**/*.xml";
+ /**
+ * The source directories containing the sources to be compiled.
+ *
+ * @parameter expression="${project.compileSourceRoots}"
+ * @required
+ * @readonly
+ */
+ protected List<String> compileSourceRoots;
- private static final String[] JAVA_INCLUDES = new String[] { "**/*.java" };
+ /**
+ * The list of JSF configuration files that will be processed by CDK.
+ * By default, CDK looks for all files in the
<code>src/main/config</code> folder
+ * with "xml" extension.
+ * @parameter
+ */
+ protected FileSet[] facesConfigs;
- private static final String[] STRINGS_ARRAY = new String[0];
+ /**
+ * @parameter
+ */
+ protected Map<String, String> options;
- private static final String MAIN_TEMPLATES = "src/main/templates";
+ /**
+ * The directory for compiled classes.
+ *
+ * @parameter expression="${project.build.outputDirectory}"
+ * @required
+ * @readonly
+ */
+ protected File outputDirectory;
- /**
- * Top maven project.
- *
- * @parameter expression="${project}"
- * @readonly
- */
- protected MavenProject project;
+ /**
+ * Directory where the output Java Files will be located.
+ *
+ * @parameter
expression="${project.build.directory}/cdk-generated/main/java"
+ */
+ protected File outputJavaDirectory;
- /**
- * List of filename patterns that will be included to process by annotations processor.
- * By default, all *.java files will be processed.
- * @parameter
- */
- protected String[] sourceIncludes;
+ /**
+ * Directory where the output Java Files will be located.
+ *
+ * @parameter
+ *
expression="${project.build.directory}/cdk-generated/main/resources"
+ */
+ protected File outputResourcesDirectory;
- /**
- * List of filename patterns that will be excluded from process by annotations
processor.
- * By default, all *.java files will be processed.
- * @parameter
- */
- protected String[] sourceExcludes;
+ /**
+ * @parameter
expression="${project.build.directory}/cdk-generated/test/java"
+ */
+ protected File outputTestDirectory;
- /**
- * The list of JSF configuration files that will be processed by CDK.
- * By default, CDK looks for all files in the <code>src/main/config</code>
folder
- * with "xml" extension.
- * @parameter
- */
- protected FileSet[] facesConfigs;
+ /**
+ * Directory where the output Java Files will be located.
+ *
+ * @parameter
+ *
expression="${project.build.directory}/cdk-generated/test/resources"
+ */
+ protected File outputTestResourcesDirectory;
- /**
- * The list of Renderer template files that will be processed by CDK.
- * By default, CDK looks for all files in the
<code>src/main/templates</code> folder
- * with "xml" extension.
- * @parameter
- */
- protected FileSet[] templates;
+ /**
+ * Top maven project.
+ *
+ * @parameter expression="${project}"
+ * @readonly
+ */
+ protected MavenProject project;
- /**
- * Directory where the output Java Files will be located.
- *
- * @parameter expression="${project.build.directory}/cdk-generated/main/java"
- */
- protected File outputJavaDirectory;
+ /**
+ * List of filename patterns that will be excluded from process by annotations
processor.
+ * By default, all *.java files will be processed.
+ * @parameter
+ */
+ protected String[] sourceExcludes;
- /**
- * @parameter expression="${project.build.directory}/cdk-generated/test/java"
- */
- protected File outputTestDirectory;
+ /**
+ * List of filename patterns that will be included to process by annotations
processor.
+ * By default, all *.java files will be processed.
+ * @parameter
+ */
+ protected String[] sourceIncludes;
- /**
- * Directory where the output Java Files will be located.
- *
- * @parameter
- *
expression="${project.build.directory}/cdk-generated/main/resources"
- */
- protected File outputResourcesDirectory;
+ /**
+ * The list of Renderer template files that will be processed by CDK.
+ * By default, CDK looks for all files in the
<code>src/main/templates</code> folder
+ * with "xml" extension.
+ * @parameter
+ */
+ protected FileSet[] templates;
- /**
- * Directory where the output Java Files will be located.
- *
- * @parameter
- *
expression="${project.build.directory}/cdk-generated/test/resources"
- */
- protected File outputTestResourcesDirectory;
- /**
- * The source directories containing the sources to be compiled.
- *
- * @parameter expression="${project.compileSourceRoots}"
- * @required
- * @readonly
- */
- protected List<String> compileSourceRoots;
- /**
- * Project classpath.
- *
- * @parameter expression="${project.compileClasspathElements}"
- * @required
- * @readonly
- */
- protected List<String> classpathElements;
- /**
- * The directory for compiled classes.
- *
- * @parameter expression="${project.build.outputDirectory}"
- * @required
- * @readonly
- */
- protected File outputDirectory;
+ /**
+ * @parameter
+ */
+ protected Map<String, String> workers;
- /**
- * @parameter
- */
- protected Map<String, String> workers;
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.maven.plugin.Mojo#execute()
+ */
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
- /**
- * @parameter
- */
- protected Map<String, String> options;
+ // Setup logger.
+ LoggerFactory.setLogger(new MavenLogger(getLog()));
- /*
- * (non-Javadoc)
- *
- * @see org.apache.maven.plugin.Mojo#execute()
- */
- @Override
- public void execute() throws MojoExecutionException, MojoFailureException {
- // Setup logger.
- LoggerFactory.setLogger(new MavenLogger(getLog()));
- CdkContextBase context = new CdkContextBase(this
- .createProjectClassLoader(project));
- // Set source folders.
- ArrayList<File> folders = new ArrayList<File>(compileSourceRoots.size());
- for (String sourceFolder : compileSourceRoots) {
- File folder = new File(sourceFolder);
- if (folder.exists() && folder.isDirectory()) {
- folders.add(folder);
- }
- }
- context.setSourceFolders(StandardSources.JAVA_SOURCES, folders);
- // Non-java sources.
- context.addSources(StandardSources.JAVA_SOURCES, findJavaFiles());
- context.addSources(StandardSources.RENDERER_TEMPLATES,
- findTemplateFiles());
- context.addSources(StandardSources.FACES_CONFIGS,
- findFacesConfigFiles());
- // Setup output folders.
- setOutput(context, outputJavaDirectory, StandardOutputFolders.JAVA_CLASSES);
- setOutput(context, outputResourcesDirectory, StandardOutputFolders.RESOURCES);
- setOutput(context, outputTestDirectory, StandardOutputFolders.TEST_JAVA_CLASSES);
- setOutput(context, outputTestResourcesDirectory,
StandardOutputFolders.TEST_RESOURCES);
- // configure CDK workers.
- boolean namingConventionsConfigured = false;
- boolean validatorConfigured = false;
- if (null != workers) {
- for (Entry<String, String> workerEntry : workers.entrySet()) {
- try {
- Class<? extends CdkWorker> workerClass = Class.forName(
- workerEntry.getKey()).asSubclass(CdkWorker.class);
- Class<? extends CdkWorker> workerImplementationClass = Class
- .forName(workerEntry.getValue()).asSubclass(
- CdkWorker.class);
- CdkWorker workerInstance = workerImplementationClass
- .newInstance();
- workerInstance.init(context);
- context.addWorker(workerClass, workerInstance);
- if (NamingConventions.class.equals(workerClass)) {
- namingConventionsConfigured = true;
- }
- if (ModelValidator.class.equals(workerClass)) {
- validatorConfigured = true;
- }
- } catch (ClassNotFoundException e) {
- throw new MojoFailureException("Worker class not found", e);
- } catch (InstantiationException e) {
- throw new MojoFailureException(
- "Worker instance can't be created", e);
- } catch (IllegalAccessException e) {
- throw new MojoFailureException(
- "Worker instance can't be created", e);
- } catch (CdkException e) {
- throw new MojoFailureException(
- "Worker initialization error", e);
- }
- }
+ CdkContextBase context = new
CdkContextBase(this.createProjectClassLoader(project));
- }
- // Set default naming conventions if it was not configured.
- if (namingConventionsConfigured) {
- RichFacesConventions facesConventions = new RichFacesConventions();
- try {
- facesConventions.init(context);
- } catch (CdkException e) {
- throw new MojoFailureException(
- "Naming conventions initialization error", e);
- }
- context.addWorker(NamingConventions.class, facesConventions);
- }
- // Set default model validator if it was not configured.
- if (validatorConfigured) {
- ValidatorImpl validatorImpl = new ValidatorImpl();
- try {
- validatorImpl.init(context);
- } catch (CdkException e) {
- throw new MojoFailureException(
- "RichFaces Validator initialization error", e);
- }
- context.addWorker(ModelValidator.class, validatorImpl);
- }
- if (null != options) {
- // TODO make it type safe.
- context.setOptions(options);
- }
- try {
- // Build JSF library.
- LibraryBuilder builder = LibraryBuilder.createInstance(context);
- ComponentLibrary model = builder.buildModel();
- builder.generate(model);
- // Tell project about generated files.
- project.addCompileSourceRoot(outputJavaDirectory.getAbsolutePath());
- Resource resource = new Resource();
- resource.setDirectory(outputResourcesDirectory.getAbsolutePath());
- project.addResource(resource);
- project.addTestCompileSourceRoot(outputTestDirectory
- .getAbsolutePath());
- Resource testResource = new Resource();
- testResource.setDirectory(outputTestResourcesDirectory
- .getAbsolutePath());
- project.addTestResource(testResource);
- } catch (CdkException e) {
- throw new MojoExecutionException("CDK build error", e);
- }
- }
+ // Set source folders.
+ ArrayList<File> folders = new
ArrayList<File>(compileSourceRoots.size());
- /**
- * <p class="changed_added_4_0">This utility method sets output
directory for particular type.
- * I such directory does not exist, it is created.</p>
- * @param context
- * @param directory
- * @param type
- */
- private static void setOutput(CdkContextBase context, File directory,
- StandardOutputFolders type) {
- if (!directory.exists()) {
- directory.mkdirs();
- }
- context.setOutputFolder(type,
- directory);
- }
+ for (String sourceFolder : compileSourceRoots) {
+ File folder = new File(sourceFolder);
- /**
- * <p class="changed_added_4_0">This method checks library configuration
and sets default values if necessary.</p>
- */
- protected void checkLibraryConfig() {
- // TODO Auto-generated method stub
+ if (folder.exists() && folder.isDirectory()) {
+ folders.add(folder);
+ }
+ }
- }
+ context.setSourceFolders(StandardSources.JAVA_SOURCES, folders);
- private Iterable<File> findTemplateFiles() throws MojoExecutionException {
- if (null == templates) {
- File defaultDirectory = new File(MAIN_TEMPLATES);
- if (defaultDirectory.exists() && defaultDirectory.isDirectory()) {
- FileSet fileSet = new FileSet();
- fileSet.setDirectory(MAIN_TEMPLATES);
- fileSet.addInclude(XML_INCLUDES);
- templates = new FileSet[] { fileSet };
- }
- }
- return doScan(templates);
+ // Non-java sources.
+ context.addSources(StandardSources.JAVA_SOURCES, findJavaFiles());
+ context.addSources(StandardSources.RENDERER_TEMPLATES, findTemplateFiles());
+ context.addSources(StandardSources.FACES_CONFIGS, findFacesConfigFiles());
- }
+ // Setup output folders.
+ setOutput(context, outputJavaDirectory, StandardOutputFolders.JAVA_CLASSES);
+ setOutput(context, outputResourcesDirectory, StandardOutputFolders.RESOURCES);
+ setOutput(context, outputTestDirectory,
StandardOutputFolders.TEST_JAVA_CLASSES);
+ setOutput(context, outputTestResourcesDirectory,
StandardOutputFolders.TEST_RESOURCES);
- private Iterable<File> findJavaFiles() throws MojoExecutionException {
- Set<File> javaSources = new HashSet<File>();
- String[] includes = null == sourceIncludes ? JAVA_INCLUDES
- : sourceIncludes;
- for (String compileRoot : compileSourceRoots) {
- File rootFolder = new File(compileRoot);
- String[] sources = doScan(includes, sourceExcludes, rootFolder);
- for (String src : sources) {
- javaSources.add(new File(rootFolder, src));
- }
- }
- return javaSources;
- }
+ // configure CDK workers.
+ boolean namingConventionsConfigured = false;
+ boolean validatorConfigured = false;
- private Iterable<File> findFacesConfigFiles() throws MojoExecutionException {
- if (null == facesConfigs) {
- File defaultDirectory = new File(MAIN_CONFIG);
- if (defaultDirectory.exists() && defaultDirectory.isDirectory()) {
- FileSet fileSet = new FileSet();
- fileSet.setDirectory(MAIN_CONFIG);
- fileSet.addInclude(XML_INCLUDES);
- facesConfigs = new FileSet[] { fileSet };
- }
- }
- return doScan(facesConfigs);
- }
+ if (null != workers) {
+ for (Entry<String, String> workerEntry : workers.entrySet()) {
+ try {
+ Class<? extends CdkWorker> workerClass =
+ Class.forName(workerEntry.getKey()).asSubclass(CdkWorker.class);
+ Class<? extends CdkWorker> workerImplementationClass =
+
Class.forName(workerEntry.getValue()).asSubclass(CdkWorker.class);
+ CdkWorker workerInstance = workerImplementationClass.newInstance();
- protected ClassLoader createProjectClassLoader(MavenProject project) {
- ClassLoader classLoader = null;
- try {
- String outputDirectory = project.getBuild().getOutputDirectory();
- URL[] urls = new URL[classpathElements.size() + 1];
- int i = 0;
- urls[i++] = new File(outputDirectory).toURI().toURL();
- for (Iterator<String> iter = classpathElements.iterator(); iter
- .hasNext();) {
- String element = iter.next();
- urls[i++] = new File(element).toURI().toURL();
- }
- classLoader = new URLClassLoader(urls);
- } catch (MalformedURLException e) {
- getLog().error("Bad URL in classpath", e);
- }
+ workerInstance.init(context);
+ context.addWorker(workerClass, workerInstance);
- return classLoader;
- }
+ if (NamingConventions.class.equals(workerClass)) {
+ namingConventionsConfigured = true;
+ }
- protected String[] doScan(String[] includes, String[] excludes,
- File rootFolder) throws MojoExecutionException {
- try {
- DirectoryScanner directoryScanner = new DirectoryScanner();
- directoryScanner.setFollowSymlinks(true);
- directoryScanner.setBasedir(rootFolder);
- directoryScanner.setExcludes(excludes);
- directoryScanner.setIncludes(includes);
- directoryScanner.addDefaultExcludes();
+ if (ModelValidator.class.equals(workerClass)) {
+ validatorConfigured = true;
+ }
+ } catch (ClassNotFoundException e) {
+ throw new MojoFailureException("Worker class not found",
e);
+ } catch (InstantiationException e) {
+ throw new MojoFailureException("Worker instance can't be
created", e);
+ } catch (IllegalAccessException e) {
+ throw new MojoFailureException("Worker instance can't be
created", e);
+ } catch (CdkException e) {
+ throw new MojoFailureException("Worker initialization
error", e);
+ }
+ }
+ }
- directoryScanner.scan();
+ // Set default naming conventions if it was not configured.
+ if (namingConventionsConfigured) {
+ RichFacesConventions facesConventions = new RichFacesConventions();
- return directoryScanner.getIncludedFiles();
- } catch (IllegalStateException e) {
- throw new MojoExecutionException("Error scanning source root: \'"
- + rootFolder + "\'", e);
- }
- }
+ try {
+ facesConventions.init(context);
+ } catch (CdkException e) {
+ throw new MojoFailureException("Naming conventions initialization
error", e);
+ }
- /**
- * Skan Array of filesets for selected resources.
- *
- * @param fileset
- * @return
- * @throws MojoExecutionException
- */
- @SuppressWarnings("unchecked")
- protected Collection<File> doScan(FileSet[] filesets)
- throws MojoExecutionException {
- List<File> files = new ArrayList<File>();
- if (null != filesets) {
- for (FileSet fileSet : filesets) {
- String[] includes = (String[]) fileSet.getIncludes().toArray(
- STRINGS_ARRAY);
- String[] excludes = (String[]) fileSet.getExcludes().toArray(
- STRINGS_ARRAY);
- String[] scan = doScan(includes, excludes, new File(fileSet
- .getDirectory()));
- for (String filename : scan) {
- files.add(new File(filename));
- }
- }
+ context.addWorker(NamingConventions.class, facesConventions);
+ }
- }
- return files;
- }
+ // Set default model validator if it was not configured.
+ if (validatorConfigured) {
+ ValidatorImpl validatorImpl = new ValidatorImpl();
+
+ try {
+ validatorImpl.init(context);
+ } catch (CdkException e) {
+ throw new MojoFailureException("RichFaces Validator initialization
error", e);
+ }
+
+ context.addWorker(ModelValidator.class, validatorImpl);
+ }
+
+ if (null != options) {
+
+ // TODO make it type safe.
+ context.setOptions(options);
+ }
+
+ try {
+
+ // Build JSF library.
+ LibraryBuilder builder = LibraryBuilder.createInstance(context);
+ ComponentLibrary model = builder.buildModel();
+
+ builder.generate(model);
+
+ // Tell project about generated files.
+ project.addCompileSourceRoot(outputJavaDirectory.getAbsolutePath());
+
+ Resource resource = new Resource();
+
+ resource.setDirectory(outputResourcesDirectory.getAbsolutePath());
+ project.addResource(resource);
+ project.addTestCompileSourceRoot(outputTestDirectory.getAbsolutePath());
+
+ Resource testResource = new Resource();
+
+ testResource.setDirectory(outputTestResourcesDirectory.getAbsolutePath());
+ project.addTestResource(testResource);
+ } catch (CdkException e) {
+ throw new MojoExecutionException("CDK build error", e);
+ }
+ }
+
+ /**
+ * <p class="changed_added_4_0">This utility method sets output
directory for particular type.
+ * I such directory does not exist, it is created.</p>
+ * @param context
+ * @param directory
+ * @param type
+ */
+ private static void setOutput(CdkContextBase context, File directory,
StandardOutputFolders type) {
+ if (!directory.exists()) {
+ directory.mkdirs();
+ }
+
+ context.setOutputFolder(type, directory);
+ }
+
+ /**
+ * <p class="changed_added_4_0">This method checks library
configuration and sets default values if necessary.</p>
+ */
+ protected void checkLibraryConfig() {
+
+ // TODO Auto-generated method stub
+ }
+
+ private Iterable<File> findTemplateFiles() throws MojoExecutionException {
+ if (null == templates) {
+ File defaultDirectory = new File(MAIN_TEMPLATES);
+
+ if (defaultDirectory.exists() && defaultDirectory.isDirectory()) {
+ FileSet fileSet = new FileSet();
+
+ fileSet.setDirectory(MAIN_TEMPLATES);
+ fileSet.addInclude(XML_INCLUDES);
+ templates = new FileSet[] {fileSet};
+ }
+ }
+
+ return doScan(templates);
+ }
+
+ private Iterable<File> findJavaFiles() throws MojoExecutionException {
+ Set<File> javaSources = new HashSet<File>();
+ String[] includes = null == sourceIncludes ? JAVA_INCLUDES : sourceIncludes;
+
+ for (String compileRoot : compileSourceRoots) {
+ File rootFolder = new File(compileRoot);
+ String[] sources = doScan(includes, sourceExcludes, rootFolder);
+
+ for (String src : sources) {
+ javaSources.add(new File(rootFolder, src));
+ }
+ }
+
+ return javaSources;
+ }
+
+ private Iterable<File> findFacesConfigFiles() throws MojoExecutionException {
+ if (null == facesConfigs) {
+ File defaultDirectory = new File(MAIN_CONFIG);
+
+ if (defaultDirectory.exists() && defaultDirectory.isDirectory()) {
+ FileSet fileSet = new FileSet();
+
+ fileSet.setDirectory(MAIN_CONFIG);
+ fileSet.addInclude(XML_INCLUDES);
+ facesConfigs = new FileSet[] {fileSet};
+ }
+ }
+
+ return doScan(facesConfigs);
+ }
+
+ protected ClassLoader createProjectClassLoader(MavenProject project) {
+ ClassLoader classLoader = null;
+
+ try {
+ String outputDirectory = project.getBuild().getOutputDirectory();
+ URL[] urls = new URL[classpathElements.size() + 1];
+ int i = 0;
+
+ urls[i++] = new File(outputDirectory).toURI().toURL();
+
+ for (Iterator<String> iter = classpathElements.iterator();
iter.hasNext(); ) {
+ String element = iter.next();
+
+ urls[i++] = new File(element).toURI().toURL();
+ }
+
+ classLoader = new URLClassLoader(urls);
+ } catch (MalformedURLException e) {
+ getLog().error("Bad URL in classpath", e);
+ }
+
+ return classLoader;
+ }
+
+ protected String[] doScan(String[] includes, String[] excludes, File rootFolder)
throws MojoExecutionException {
+ try {
+ DirectoryScanner directoryScanner = new DirectoryScanner();
+
+ directoryScanner.setFollowSymlinks(true);
+ directoryScanner.setBasedir(rootFolder);
+ directoryScanner.setExcludes(excludes);
+ directoryScanner.setIncludes(includes);
+ directoryScanner.addDefaultExcludes();
+ directoryScanner.scan();
+
+ return directoryScanner.getIncludedFiles();
+ } catch (IllegalStateException e) {
+ throw new MojoExecutionException("Error scanning source root:
\'" + rootFolder + "\'", e);
+ }
+ }
+
+ /**
+ * Skan Array of filesets for selected resources.
+ *
+ * @param fileset
+ * @return
+ * @throws MojoExecutionException
+ */
+ @SuppressWarnings("unchecked")
+ protected Collection<File> doScan(FileSet[] filesets) throws
MojoExecutionException {
+ List<File> files = new ArrayList<File>();
+
+ if (null != filesets) {
+ for (FileSet fileSet : filesets) {
+ String[] includes = (String[])
fileSet.getIncludes().toArray(STRINGS_ARRAY);
+ String[] excludes = (String[])
fileSet.getExcludes().toArray(STRINGS_ARRAY);
+ String[] scan = doScan(includes, excludes, new
File(fileSet.getDirectory()));
+
+ for (String filename : scan) {
+ files.add(new File(filename));
+ }
+ }
+ }
+
+ return files;
+ }
}
Modified:
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Library.java
===================================================================
---
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Library.java 2009-11-01
16:27:54 UTC (rev 15791)
+++
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Library.java 2009-11-01
16:28:50 UTC (rev 15792)
@@ -19,133 +19,125 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.mojo;
/**
* @author shura
- *
+ *
*/
public class Library {
+ public static final String JSF10 = "1.0";
+ public static final String JSF11 = "1.1";
+ public static final String JSF12 = "1.2";
+ private String description;
+ private String jsfVersion;
+ private String prefix;
+ private Renderkit[] renderkits;
+ private Taglib taglib;
- public static final String JSF10 = "1.0";
+ /**
+ * @parameter
+ */
+ private Taglib[] taglibs;
- public static final String JSF11 = "1.1";
+ /**
+ * @return the prefix
+ */
+ public String getPrefix() {
+ return this.prefix;
+ }
- public static final String JSF12 = "1.2";
+ /**
+ * @param prefix
+ * the prefix to set
+ */
+ public void setPrefix(String prefix) {
+ this.prefix = prefix;
+ }
- private String _prefix;
+ /**
+ * @return the renderkits
+ */
+ public Renderkit[] getRenderkits() {
+ return this.renderkits;
+ }
- private String _description;
+ /**
+ * @param renderkits
+ * the renderkits to set
+ */
+ public void setRenderkits(Renderkit[] renderkits) {
+ this.renderkits = renderkits;
+ }
- private String _jsfVersion;
+ /**
+ * @return the taglib
+ */
+ public Taglib getTaglib() {
+ return this.taglib;
+ }
- private Taglib _taglib;
+ /**
+ * @param taglib
+ * the taglib to set
+ */
+ public void setTaglib(Taglib taglib) {
+ this.taglib = taglib;
+ }
- private Renderkit[] _renderkits;
+ /**
+ * @return the description
+ */
+ public String getDescription() {
+ return this.description;
+ }
- /**
- * @parameter
- */
- private Taglib[] taglibs;
+ /**
+ * @param description
+ * the description to set
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
- /**
- * @return the prefix
- */
- public String getPrefix() {
- return this._prefix;
- }
+ /**
+ * @return the jsfVersion
+ */
+ public String getJsfVersion() {
+ return this.jsfVersion;
+ }
- /**
- * @param prefix
- * the prefix to set
- */
- public void setPrefix(String prefix) {
- this._prefix = prefix;
- }
+ /**
+ * @param jsfVersion
+ * the jsfVersion to set
+ */
+ public void setJsfVersion(String jsfVersion) {
+ if (JSF10.equals(jsfVersion) || JSF11.equals(jsfVersion) ||
JSF12.equals(jsfVersion)) {
+ this.jsfVersion = jsfVersion;
+ } else {
+ throw new IllegalArgumentException("Supported JSF versions is 1.0,1.1
and 1.2 only. ");
+ }
+ }
- /**
- * @return the renderkits
- */
- public Renderkit[] getRenderkits() {
- return this._renderkits;
- }
+ /**
+ * @return the taglibs
+ */
+ public Taglib[] getTaglibs() {
+ return taglibs;
+ }
- /**
- * @param renderkits
- * the renderkits to set
- */
- public void setRenderkits(Renderkit[] renderkits) {
- this._renderkits = renderkits;
- }
+ /**
+ * @param taglibs the taglibs to set
+ */
+ public void setTaglibs(Taglib[] taglibs) {
+ this.taglibs = taglibs;
+ }
- /**
- * @return the taglib
- */
- public Taglib getTaglib() {
- return this._taglib;
- }
-
- /**
- * @param taglib
- * the taglib to set
- */
- public void setTaglib(Taglib taglib) {
- this._taglib = taglib;
- }
-
- /**
- * @return the description
- */
- public String getDescription() {
- return this._description;
- }
-
- /**
- * @param description
- * the description to set
- */
- public void setDescription(String description) {
- this._description = description;
- }
-
- /**
- * @return the jsfVersion
- */
- public String getJsfVersion() {
- return this._jsfVersion;
- }
-
- /**
- * @param jsfVersion
- * the jsfVersion to set
- */
- public void setJsfVersion(String jsfVersion) {
- if (JSF10.equals(jsfVersion) || JSF11.equals(jsfVersion)
- || JSF12.equals(jsfVersion)) {
- this._jsfVersion = jsfVersion;
-
- } else {
- throw new IllegalArgumentException(
- "Supported JSF versions is 1.0,1.1 and 1.2 only. ");
- }
- }
-
- /**
- * @return the taglibs
- */
- public Taglib[] getTaglibs() {
- return taglibs;
- }
-
- /**
- * @param taglibs the taglibs to set
- */
- public void setTaglibs(Taglib[] taglibs) {
- this.taglibs = taglibs;
- }
-
- @Override
- public String toString() {
- return "JSF library "+getPrefix()+", desc:
"+getDescription()+(null!=getTaglibs()?", libs:
"+getTaglibs():"");
- }
+ @Override
+ public String toString() {
+ return "JSF library " + getPrefix() + ", desc: " +
getDescription()
+ + (null != getTaglibs() ? ", libs: " + getTaglibs() :
"");
+ }
}
Modified:
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Renderkit.java
===================================================================
---
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Renderkit.java 2009-11-01
16:27:54 UTC (rev 15791)
+++
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Renderkit.java 2009-11-01
16:28:50 UTC (rev 15792)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.mojo;
/**
@@ -26,98 +28,96 @@
*
*/
public class Renderkit {
-
- private String _name = "HTML_BASIC";
-
- private String _markup = "html";
-
- private String _classname;
-
- private String _package;
-
- private StringBuffer _content;
+ private String markup = "html";
+ private String name = "HTML_BASIC";
+ private String classPackage;
+ private String classname;
+ private StringBuffer content;
- /**
- * @return the classname
- */
- public String getClassname() {
- return this._classname;
- }
+ /**
+ * @return the classname
+ */
+ public String getClassname() {
+ return this.classname;
+ }
- /**
- * @param classname the classname to set
- */
- public void setClassname(String classname) {
- this._classname = classname;
- }
+ /**
+ * @param classname the classname to set
+ */
+ public void setClassname(String classname) {
+ this.classname = classname;
+ }
- /**
- * @return the markup
- */
- public String getMarkup() {
- return this._markup;
- }
+ /**
+ * @return the markup
+ */
+ public String getMarkup() {
+ return this.markup;
+ }
- /**
- * @param markup the markup to set
- */
- public void setMarkup(String markup) {
- this._markup = markup;
- }
+ /**
+ * @param markup the markup to set
+ */
+ public void setMarkup(String markup) {
+ this.markup = markup;
+ }
- /**
- * @return the name
- */
- public String getName() {
- return this._name;
- }
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return this.name;
+ }
- /**
- * @param name the name to set
- */
- public void setName(String name) {
- this._name = name;
- }
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
- /**
- * @return the package
- */
- public String getPackage() {
- return this._package;
- }
+ /**
+ * @return the package
+ */
+ public String getPackage() {
+ return this.classPackage;
+ }
- /**
- * @param package1 the package to set
- */
- public void setPackage(String package1) {
- this._package = package1;
- }
+ /**
+ * @param package1 the package to set
+ */
+ public void setPackage(String package1) {
+ this.classPackage = package1;
+ }
- /**
- * @return the content
- */
- StringBuffer getContent() {
- return this._content;
- }
+ /**
+ * @return the content
+ */
+ StringBuffer getContent() {
+ return this.content;
+ }
- /**
- * @param content the content to set
- */
- void setContent(StringBuffer content) {
- this._content = content;
- }
-
- public String getFacesConfig(){
- if(null != _content){
- return _content.toString();
- }
- return "";
- }
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return "render-kit id ["+_name+"], class ["+_classname+"],
content :"+_content;
- }
+ /**
+ * @param content the content to set
+ */
+ void setContent(StringBuffer content) {
+ this.content = content;
+ }
+ public String getFacesConfig() {
+ if (null != content) {
+ return content.toString();
+ }
+
+ return "";
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "render-kit id [" + name + "], class [" + classname +
"], content :" + content;
+ }
}
Modified:
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/SkinInfo.java
===================================================================
---
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/SkinInfo.java 2009-11-01
16:27:54 UTC (rev 15791)
+++
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/SkinInfo.java 2009-11-01
16:28:50 UTC (rev 15792)
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+
package org.richfaces.builder.mojo;
import java.util.ArrayList;
@@ -30,76 +32,91 @@
* @author Maksim Kaszynski
*
*/
-public class SkinInfo implements Cloneable{
- private String shortName;
- private String packageName;
-
- private String baseSkin;
- private List<Resource> baseClassResources = new ArrayList<Resource>();
- private List<Resource> extClassResources = new ArrayList<Resource>();
- private Resource masterXcss;
- private Resource extendedXcss;
- private Resource propertyFile;
- private boolean useExt;
-
- public boolean isUseExt() {
- return useExt;
- }
- public void setUseExt(boolean useExt) {
- this.useExt = useExt;
- }
- public String getShortName() {
- return shortName;
- }
- public void setShortName(String shortName) {
- this.shortName = shortName;
- }
- public String getPackageName() {
- return packageName;
- }
- public void setPackageName(String packageName) {
- this.packageName = packageName;
- }
- public List<Resource> getBaseClassResources() {
- return baseClassResources;
- }
- public void setBaseClassResources(List<Resource> baseClassResources) {
- this.baseClassResources = baseClassResources;
- }
- public List<Resource> getExtClassResources() {
- return extClassResources;
- }
- public void setExtClassResources(List<Resource> extClassResources) {
- this.extClassResources = extClassResources;
- }
- public Resource getMasterXcss() {
- return masterXcss;
- }
- public void setMasterXcss(Resource masterXcss) {
- this.masterXcss = masterXcss;
- }
- public Resource getExtendedXcss() {
- return extendedXcss;
- }
- public void setExtendedXcss(Resource extendedXcss) {
- this.extendedXcss = extendedXcss;
- }
- public Resource getPropertyFile() {
- return propertyFile;
- }
- public void setPropertyFile(Resource propertyFile) {
- this.propertyFile = propertyFile;
- }
- @Override
- public Object clone() throws CloneNotSupportedException {
- return super.clone();
- }
- public String getBaseSkin() {
- return baseSkin;
- }
- public void setBaseSkin(String baseSkin) {
- this.baseSkin = baseSkin;
- }
+public class SkinInfo implements Cloneable {
+ private List<Resource> baseClassResources = new ArrayList<Resource>();
+ private List<Resource> extClassResources = new ArrayList<Resource>();
+ private String baseSkin;
+ private Resource extendedXcss;
+ private Resource masterXcss;
+ private String packageName;
+ private Resource propertyFile;
+ private String shortName;
+ private boolean useExt;
+ public boolean isUseExt() {
+ return useExt;
+ }
+ public void setUseExt(boolean useExt) {
+ this.useExt = useExt;
+ }
+
+ public String getShortName() {
+ return shortName;
+ }
+
+ public void setShortName(String shortName) {
+ this.shortName = shortName;
+ }
+
+ public String getPackageName() {
+ return packageName;
+ }
+
+ public void setPackageName(String packageName) {
+ this.packageName = packageName;
+ }
+
+ public List<Resource> getBaseClassResources() {
+ return baseClassResources;
+ }
+
+ public void setBaseClassResources(List<Resource> baseClassResources) {
+ this.baseClassResources = baseClassResources;
+ }
+
+ public List<Resource> getExtClassResources() {
+ return extClassResources;
+ }
+
+ public void setExtClassResources(List<Resource> extClassResources) {
+ this.extClassResources = extClassResources;
+ }
+
+ public Resource getMasterXcss() {
+ return masterXcss;
+ }
+
+ public void setMasterXcss(Resource masterXcss) {
+ this.masterXcss = masterXcss;
+ }
+
+ public Resource getExtendedXcss() {
+ return extendedXcss;
+ }
+
+ public void setExtendedXcss(Resource extendedXcss) {
+ this.extendedXcss = extendedXcss;
+ }
+
+ public Resource getPropertyFile() {
+ return propertyFile;
+ }
+
+ public void setPropertyFile(Resource propertyFile) {
+ this.propertyFile = propertyFile;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public String getBaseSkin() {
+ return baseSkin;
+ }
+
+ public void setBaseSkin(String baseSkin) {
+ this.baseSkin = baseSkin;
+ }
}
Modified:
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Taglib.java
===================================================================
---
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Taglib.java 2009-11-01
16:27:54 UTC (rev 15791)
+++
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Taglib.java 2009-11-01
16:28:50 UTC (rev 15792)
@@ -19,208 +19,198 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.richfaces.builder.mojo;
+package org.richfaces.builder.mojo;
+
/**
* @author shura
*
*/
public class Taglib {
-
- private String _taglib;
-
- private String _uri;
-
- private String _shortName;
-
- private String _listenerClass;
-
- private String _displayName;
+ private String excludeModules = null;
+ private String excludeTags = null;
+ private String includeModules = null;
+ private String includeTags = null;
+ private String tlibVersion = null;
+ private String validatorClass = null;
+ private String displayName;
+ private String jspVersion;
+ private String listenerClass;
+ private String shortName;
+ private String taglib;
+ private String uri;
- private String _tlibVersion = null;
-
- private String _jspVersion ;
-
- private String _validatorClass = null;
-
- private String _includeModules = null;
-
- private String _excludeModules = null;
-
- private String _includeTags = null;
-
- private String _excludeTags = null;
- /**
- * @return the displayName
- */
- public String getDisplayName() {
- return this._displayName;
- }
+ /**
+ * @return the displayName
+ */
+ public String getDisplayName() {
+ return this.displayName;
+ }
- /**
- * @param displayName the displayName to set
- */
- public void setDisplayName(String displayName) {
- this._displayName = displayName;
- }
+ /**
+ * @param displayName the displayName to set
+ */
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
- /**
- * @return the listenerClass
- */
- public String getListenerClass() {
- return this._listenerClass;
- }
+ /**
+ * @return the listenerClass
+ */
+ public String getListenerClass() {
+ return this.listenerClass;
+ }
- /**
- * @param listenerClass the listenerClass to set
- */
- public void setListenerClass(String listenerClass) {
- this._listenerClass = listenerClass;
- }
+ /**
+ * @param listenerClass the listenerClass to set
+ */
+ public void setListenerClass(String listenerClass) {
+ this.listenerClass = listenerClass;
+ }
- /**
- * @return the shortName
- */
- public String getShortName() {
- return this._shortName;
- }
+ /**
+ * @return the shortName
+ */
+ public String getShortName() {
+ return this.shortName;
+ }
- /**
- * @param shortName the shortName to set
- */
- public void setShortName(String shortName) {
- this._shortName = shortName;
- }
+ /**
+ * @param shortName the shortName to set
+ */
+ public void setShortName(String shortName) {
+ this.shortName = shortName;
+ }
- /**
- * @return the taglib
- */
- public String getTaglib() {
- return this._taglib;
- }
+ /**
+ * @return the taglib
+ */
+ public String getTaglib() {
+ return this.taglib;
+ }
- /**
- * @param taglib the taglib to set
- */
- public void setTaglib(String taglib) {
- this._taglib = taglib;
- }
+ /**
+ * @param taglib the taglib to set
+ */
+ public void setTaglib(String taglib) {
+ this.taglib = taglib;
+ }
- /**
- * @return the uri
- */
- public String getUri() {
- return this._uri;
- }
+ /**
+ * @return the uri
+ */
+ public String getUri() {
+ return this.uri;
+ }
- /**
- * @param uri the uri to set
- */
- public void setUri(String uri) {
- this._uri = uri;
- }
+ /**
+ * @param uri the uri to set
+ */
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
- /**
- * @return the jspVersion
- */
- public String getJspVersion() {
- return this._jspVersion;
- }
+ /**
+ * @return the jspVersion
+ */
+ public String getJspVersion() {
+ return this.jspVersion;
+ }
- /**
- * @param jspVersion the jspVersion to set
- */
- public void setJspVersion(String jspVersion) {
- this._jspVersion = jspVersion;
- }
+ /**
+ * @param jspVersion the jspVersion to set
+ */
+ public void setJspVersion(String jspVersion) {
+ this.jspVersion = jspVersion;
+ }
- /**
- * @return the tlibVersion
- */
- public String getTlibVersion() {
- return this._tlibVersion;
- }
+ /**
+ * @return the tlibVersion
+ */
+ public String getTlibVersion() {
+ return this.tlibVersion;
+ }
- /**
- * @param tlibVersion the tlibVersion to set
- */
- public void setTlibVersion(String tlibVersion) {
- this._tlibVersion = tlibVersion;
- }
+ /**
+ * @param tlibVersion the tlibVersion to set
+ */
+ public void setTlibVersion(String tlibVersion) {
+ this.tlibVersion = tlibVersion;
+ }
- /**
- * @return the validatorClass
- */
- public String getValidatorClass() {
- return this._validatorClass;
- }
+ /**
+ * @return the validatorClass
+ */
+ public String getValidatorClass() {
+ return this.validatorClass;
+ }
- /**
- * @param validatorClass the validatorClass to set
- */
- public void setValidatorClass(String validatorClass) {
- this._validatorClass = validatorClass;
- }
+ /**
+ * @param validatorClass the validatorClass to set
+ */
+ public void setValidatorClass(String validatorClass) {
+ this.validatorClass = validatorClass;
+ }
- /**
- * @return the includeModules
- */
- public String getIncludeModules() {
- return _includeModules;
- }
+ /**
+ * @return the includeModules
+ */
+ public String getIncludeModules() {
+ return includeModules;
+ }
- /**
- * @param includeModules the includeModules to set
- */
- public void setIncludeModules(String includeModules) {
- _includeModules = includeModules;
- }
+ /**
+ * @param includeModules the includeModules to set
+ */
+ public void setIncludeModules(String includeModules) {
+ this.includeModules = includeModules;
+ }
- /**
- * @return the excludeModules
- */
- public String getExcludeModules() {
- return _excludeModules;
- }
+ /**
+ * @return the excludeModules
+ */
+ public String getExcludeModules() {
+ return excludeModules;
+ }
- /**
- * @param excludeModules the excludeModules to set
- */
- public void setExcludeModules(String excludeModules) {
- _excludeModules = excludeModules;
- }
+ /**
+ * @param excludeModules the excludeModules to set
+ */
+ public void setExcludeModules(String excludeModules) {
+ this.excludeModules = excludeModules;
+ }
- /**
- * @return the includeTags
- */
- public String getIncludeTags() {
- return _includeTags;
- }
+ /**
+ * @return the includeTags
+ */
+ public String getIncludeTags() {
+ return includeTags;
+ }
- /**
- * @param includeTags the includeTags to set
- */
- public void setIncludeTags(String includeTags) {
- _includeTags = includeTags;
- }
+ /**
+ * @param includeTags the includeTags to set
+ */
+ public void setIncludeTags(String includeTags) {
+ this.includeTags = includeTags;
+ }
- /**
- * @return the excludeTags
- */
- public String getExcludeTags() {
- return _excludeTags;
- }
+ /**
+ * @return the excludeTags
+ */
+ public String getExcludeTags() {
+ return excludeTags;
+ }
- /**
- * @param excludeTags the excludeTags to set
- */
- public void setExcludeTags(String excludeTags) {
- _excludeTags = excludeTags;
- }
+ /**
+ * @param excludeTags the excludeTags to set
+ */
+ public void setExcludeTags(String excludeTags) {
+ this.excludeTags = excludeTags;
+ }
- @Override
- public String toString() {
- return "Lib: "+getShortName()+", URL: "+getUri();
- }
+ @Override
+ public String toString() {
+ return "Lib: " + getShortName() + ", URL: " + getUri();
+ }
}