Author: alexsmirnov
Date: 2007-03-29 21:56:34 -0400 (Thu, 29 Mar 2007)
New Revision: 44
Modified:
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyLibraryMojo.java
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/CompileMojo.java
trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/NekkoParser.java
trunk/pom.xml
trunk/test/pom.xml
Log:
Fix call cdk:assembly goals from forked builds ( aka assembly:assembly )
Setup build for a clover reports.
Modified:
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyLibraryMojo.java
===================================================================
---
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyLibraryMojo.java 2007-03-29
01:55:10 UTC (rev 43)
+++
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyLibraryMojo.java 2007-03-30
01:56:34 UTC (rev 44)
@@ -45,6 +45,7 @@
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
+import org.apache.maven.model.Parent;
import org.apache.maven.model.Resource;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
@@ -82,6 +83,7 @@
public class AssemblyLibraryMojo extends AbstractCDKMojo {
private static final String TEMPLATES_PREFIX = "/templates/";
+
private static final String TEMPLATES12_PREFIX = "/templates12/";
private static final String FACES_CONFIG_TEMPLATE = "faces-config.vm";
@@ -140,7 +142,6 @@
* The reactor projects.
*
* @parameter expression="${project.parent}"
- * @required
* @readonly
*/
private MavenProject parentProject;
@@ -176,14 +177,17 @@
* @parameter
*/
private String templates;
+
/**
* @parameter
*/
- private String includeTld="META-INF/*.tld";
+ private String includeTld = "META-INF/*.tld";
+
/**
* @parameter
*/
- private String includeTaglib="META-INF/*.taglib.xml";
+ private String includeTaglib = "META-INF/*.taglib.xml";
+
/**
*
*/
@@ -197,11 +201,35 @@
* @see org.apache.maven.plugin.Mojo#execute()
*/
public void execute() throws MojoExecutionException, MojoFailureException {
- // populateReactorProjects();
+ // Parent project not set for a custom lifecycles. Try to load artifact.
+ if (null == parentProject || null == parentProject.getFile()) {
+ Parent parentModel = project.getModel().getParent();
+ if (null != parentModel) {
+ String relativePath = parentModel.getRelativePath();
+ File parentPom = new File(project.getFile().getAbsoluteFile().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 MojoFailureException("Error get parent project for a components
library");
+ }
+ } else {
+ throw new MojoFailureException("Parent project pom file not found for a
components library");
+ }
+ }else {
+ throw new MojoFailureException("Components library project must have parent pom
with components modules");
+ }
+
+ }
if (null != parentProject) {
this.checkLibraryConfig();
- if(null == templates){
- templates =
Library.JSF12.equals(library.getJsfVersion())?TEMPLATES12_PREFIX:TEMPLATES_PREFIX;
+ if (null == templates) {
+ templates = Library.JSF12.equals(library.getJsfVersion()) ? TEMPLATES12_PREFIX
+ : TEMPLATES_PREFIX;
}
Model generatedProject;
try {
@@ -261,7 +289,8 @@
}
}
// Remove modules projects from dependencise
- Set<String> unwanted = new HashSet<String>(projectsDependencies.size());
+ Set<String> unwanted = new HashSet<String>(projectsDependencies
+ .size());
for (Iterator iter = models.iterator(); iter.hasNext();) {
Model model = (Model) iter.next();
for (Iterator iterator = projectsDependencies.values()
@@ -273,8 +302,7 @@
getLog().debug(
"Remove dependency of library module "
+ dependency.getManagementKey());
- unwanted.add(dependency
- .getManagementKey());
+ unwanted.add(dependency.getManagementKey());
}
}
// Got module and unpack it to target directory.
@@ -294,15 +322,25 @@
projectsDependencies.values());
writePom(generatedProject);
mergeFacesConfig(models);
- File resourcesConfig = new
File(outputDirectory,"META-INF/resources-config.xml");
- mergeXML(models, "META-INF/resources-config.xml", RESOURCES_CONFIG_TEMPLATE,
null, new VelocityContext(),resourcesConfig);
- File tld = new
File(outputDirectory,"META-INF/"+library.getTaglib().getShortName()
- + ".tld");
- mergeXML(models, includeTld, TLD_TEMPLATE, "/taglib/tag | /taglib/listener",
new VelocityContext(),tld);
- File taglib = new
File(outputDirectory,"META-INF/"+library.getTaglib().getShortName()
- + ".taglib.xml");
- mergeXML(models, includeTaglib, TAGLIB_TEMPLATE, "/facelet-taglib/tag |
/facelet-taglib/function", new VelocityContext(),taglib);
+ File resourcesConfig = new File(outputDirectory,
+ "META-INF/resources-config.xml");
+ mergeXML(models, "META-INF/resources-config.xml",
+ RESOURCES_CONFIG_TEMPLATE, null, new VelocityContext(),
+ resourcesConfig);
+ File tld = new File(outputDirectory, "META-INF/"
+ + library.getTaglib().getShortName() + ".tld");
+ mergeXML(models, includeTld, TLD_TEMPLATE,
+ "/taglib/tag | /taglib/listener", new VelocityContext(),
+ tld);
+ File taglib = new File(outputDirectory, "META-INF/"
+ + library.getTaglib().getShortName() + ".taglib.xml");
+ mergeXML(models, includeTaglib, TAGLIB_TEMPLATE,
+ "/facelet-taglib/tag | /facelet-taglib/function",
+ new VelocityContext(), taglib);
+ }else {
+ throw new MojoFailureException("Components library project must have parent pom
with components modules");
}
+
}
/**
@@ -354,8 +392,8 @@
context.put("library", library);
context.put("renderkits", Arrays.asList(library.getRenderkits()));
try {
- writeParsedTemplate(templates+FACES_CONFIG_TEMPLATE, context, new File(
- outputDirectory, "META-INF/faces-config.xml"));
+ writeParsedTemplate(templates + FACES_CONFIG_TEMPLATE, context,
+ new File(outputDirectory, "META-INF/faces-config.xml"));
} catch (Exception e) {
throw new MojoExecutionException(
"Error to process faces-config template", e);
@@ -373,30 +411,30 @@
* name of velocity template for result file.
* @param commonXpath -
* XPath expression fof common part of result file.
- * @param context - Velocity context for template processing.
+ * @param context -
+ * Velocity context for template processing.
* @throws MojoExecutionException
*/
private void mergeXML(List models, String filename, String templateName,
- String commonXpath, VelocityContext context,File target)
+ String commonXpath, VelocityContext context, File target)
throws MojoExecutionException {
StringBuffer content = new StringBuffer();
List<XMLBody> xmls = new ArrayList<XMLBody>(models.size());
String[] split = filename.split(",");
for (Iterator iter = models.iterator(); iter.hasNext();) {
Model model = (Model) iter.next();
- File moduleDir = new File(buildDirectory, model
- .getArtifactId());
+ File moduleDir = new File(buildDirectory, model.getArtifactId());
DirectoryScanner ds = new DirectoryScanner();
- ds.setFollowSymlinks( true );
- ds.setBasedir( moduleDir );
- ds.setIncludes(split);
- ds.addDefaultExcludes();
- ds.scan();
- String[] files = ds.getIncludedFiles();
- for (int i=0; i<files.length;i++) {
- File moduleFacesConfig = new File(moduleDir,files[i]);
+ ds.setFollowSymlinks(true);
+ ds.setBasedir(moduleDir);
+ ds.setIncludes(split);
+ ds.addDefaultExcludes();
+ ds.scan();
+ String[] files = ds.getIncludedFiles();
+ for (int i = 0; i < files.length; i++) {
+ File moduleFacesConfig = new File(moduleDir, files[i]);
getLog().info(
- "Process "+files[i]+" for module "
+ "Process " + files[i] + " for module "
+ model.getArtifactId());
XMLBody configBody = new XMLBody();
try {
@@ -423,7 +461,7 @@
context.put("models", models);
context.put("xmls", xmls);
try {
- writeParsedTemplate(templates+templateName, context, target);
+ writeParsedTemplate(templates + templateName, context, target);
} catch (Exception e) {
throw new MojoExecutionException("Error to process template "
+ templateName + " for files " + filename, e);
Modified:
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/CompileMojo.java
===================================================================
---
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/CompileMojo.java 2007-03-29
01:55:10 UTC (rev 43)
+++
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/CompileMojo.java 2007-03-30
01:56:34 UTC (rev 44)
@@ -21,83 +21,276 @@
package org.ajax4jsf.builder.mojo;
+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.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import org.apache.commons.beanutils.PropertyUtils;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.model.Parent;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
+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;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.context.Context;
import org.codehaus.plexus.context.ContextException;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
/**
- * Compile all xml templates, matched given pattern to Java classes. Sources will be
created in
- * {@link AbstractCDKMojo#outputJavaDirectory}
+ * 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;
+
+ /**
+ * The reactor projects.
+ *
+ * @parameter expression="${project.parent}"
+ * @readonly
+ */
+ private MavenProject parentProject;
+ /**
* @parameter default-value=${project.groupId}
*/
private String defaultPackage;
-
+
/**
- * A list of inclusion filters for the compiler. By default, include all files
- * in templates directory.
+ * 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;
+ /**
+ * The local repository.
+ *
+ * @parameter expression="${localRepository}"
+ */
+ private ArtifactRepository localRepository;
+
+ /**
+ * To look up Archiver/UnArchiver implementations
+ *
+ * @component
+ */
+ private ArchiverManager archiverManager;
+
+ /**
+ * Project builder
+ *
+ * @component
+ */
+ private MavenProjectBuilder mavenProjectBuilder;
private PlexusContainer container;
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.maven.plugin.Mojo#execute()
*/
public void execute() throws MojoExecutionException, MojoFailureException {
-
-// VelocityTemplates.init();
+
+ // VelocityTemplates.init();
try {
- List components =
container.lookupList("org.ajax4jsf.templatecompiler.elements.ElementsFactory");
+ List components = container
+ .lookupList("org.ajax4jsf.templatecompiler.elements.ElementsFactory");
for (Iterator iter = components.iterator(); iter.hasNext();) {
- Object element = iter.next();
+ Object element = iter.next();
System.out.println(element.getClass().getName());
-
+
}
System.out.println("Components Map");
- Map componentsMap =
container.lookupMap("org.ajax4jsf.templatecompiler.elements.ElementsFactory");
- for (Iterator iter = componentsMap.entrySet().iterator(); iter.hasNext();) {
+ Map componentsMap = container
+ .lookupMap("org.ajax4jsf.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());
+ System.out.println(element.getKey() + ":"
+ + element.getValue().getClass().getName());
}
} catch (ComponentLookupException e) {
- throw new MojoExecutionException("Error lookup ElementFactory components");
+ 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)
+ /*
+ * (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 );
-
+ 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 = PropertyUtils
+ .getPropertyDescriptors(obj);
+ 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) {
+ continue;
+ }
+ if (!first) {
+ ret.append(",\n\t");
+ }
+ addEncodedString(ret, key);
+ ret.append(":");
+ try {
+ ret.append(String.valueOf(PropertyUtils.getProperty(obj,
+ key)));
+
+ } catch (InvocationTargetException e) {
+ ret.append("Not ACCESIBLE");
+ }// 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:
trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/NekkoParser.java
===================================================================
---
trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/NekkoParser.java 2007-03-29
01:55:10 UTC (rev 43)
+++
trunk/framework/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/NekkoParser.java 2007-03-30
01:56:34 UTC (rev 44)
@@ -108,7 +108,7 @@
*/
public NekkoParser() {
_parser=new HtmlSAXParser(getHtmlConfig());
- Properties properties =
OutputPropertiesFactory.getDefaultMethodProperties(Method.XML);
+ Properties properties =
OutputPropertiesFactory.getDefaultMethodProperties(Method.XHTML);
// properties.put("encoding",_encoding);
_serializer = SerializerFactory.getSerializer(properties);
// serializer.setOutputStream(output);
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2007-03-29 01:55:10 UTC (rev 43)
+++ trunk/pom.xml 2007-03-30 01:56:34 UTC (rev 44)
@@ -8,6 +8,9 @@
<version>1.1.1-SNAPSHOT</version>
<name>Ajax for Java Server faces core project</name>
<
url>http://labs.jboss.com/jbossajax4jsf</url>
+ <properties>
+ <maven.test.failure.ignore>true</maven.test.failure.ignore>
+ </properties>
<licenses>
<license>
<name>LGPL 2.1</name>
@@ -107,7 +110,7 @@
</configuration>
<executions>
<execution>
- <phase>pre-site</phase>
+ <phase>verify</phase>
<goals>
<goal>instrument</goal>
<goal>aggregate</goal>
Modified: trunk/test/pom.xml
===================================================================
--- trunk/test/pom.xml 2007-03-29 01:55:10 UTC (rev 43)
+++ trunk/test/pom.xml 2007-03-30 01:56:34 UTC (rev 44)
@@ -47,7 +47,6 @@
<groupId>htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>1.10</version>
- <optional>true</optional>
</dependency>
<dependency>
<groupId>org.easymock</groupId>