Author: maksimkaszynski
Date: 2008-04-11 11:16:20 -0400 (Fri, 11 Apr 2008)
New Revision: 7770
Added:
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/MavenXMLMerge.java
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/VelocityTaglibMergeCallBack.java
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/XMLMergeCallback.java
Modified:
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyAttachedLibraryMojo.java
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyLibraryMojo.java
Log:
http://jira.jboss.com/jira/browse/RF-2526
Copied:
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/MavenXMLMerge.java
(from rev 7763,
branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/MavenXMLMerge.java)
===================================================================
---
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/MavenXMLMerge.java
(rev 0)
+++
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/MavenXMLMerge.java 2008-04-11
15:16:20 UTC (rev 7770)
@@ -0,0 +1,120 @@
+/**
+ *
+ */
+package org.ajax4jsf.builder.maven;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.ajax4jsf.builder.config.ParsingException;
+import org.ajax4jsf.builder.xml.XMLBody;
+import org.ajax4jsf.builder.xml.XMLBodyMerge;
+import org.ajax4jsf.builder.xml.XPathComparator;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.logging.Log;
+import org.codehaus.plexus.util.DirectoryScanner;
+
+/**
+ * Class is used to locate and merge several xml files
+ * @author Maksim Kaszynski
+ *
+ */
+public class MavenXMLMerge {
+
+ class DirectoryItem {
+ private File baseDir;
+ private String [] includes;
+ public DirectoryItem(File baseDir, String[] includes) {
+ super();
+ this.baseDir = baseDir;
+ this.includes = includes;
+ }
+
+ }
+
+ private boolean namespaceAware = false;
+
+ private Log log;
+
+ private String xPath;
+
+ private String keyXPath;
+
+ private String [] sortBy = {};
+
+ private List<DirectoryItem> directories = new ArrayList<DirectoryItem>();
+
+ public MavenXMLMerge() {
+ }
+
+ public void addDirectory(File dir, String [] includes) {
+ directories.add(new DirectoryItem(dir, includes));
+ }
+
+ public void setSortBy(String ... sortBy) {
+ this.sortBy = sortBy;
+ }
+
+ public void performMerge(XMLMergeCallback callback) throws MojoExecutionException {
+ XMLBodyMerge merge = new XMLBodyMerge(xPath, keyXPath);
+
+ for (DirectoryItem item : directories) {
+ DirectoryScanner ds = new DirectoryScanner();
+ ds.setFollowSymlinks(true);
+ ds.setBasedir(item.baseDir);
+ ds.setIncludes(item.includes);
+ ds.addDefaultExcludes();
+ ds.scan();
+ String[] files = ds.getIncludedFiles();
+ for (String file : files) {
+ File sourceFile = new File(item.baseDir, file);
+ if (log != null){
+ log.info("Process file " + sourceFile.getPath());
+ }
+ try {
+ XMLBody configBody = new XMLBody();
+ configBody.loadXML(new FileInputStream(sourceFile), namespaceAware);
+ merge.add(configBody);
+
+ } catch (FileNotFoundException e) {
+ throw new MojoExecutionException("Could't read file "
+ + sourceFile.getPath(), e);
+ } catch (ParsingException e) {
+ throw new MojoExecutionException(
+ "Error parsing config file "
+ + sourceFile.getPath(), e);
+ }
+
+ }
+ }
+
+ if (sortBy != null) {
+ merge.sort(new XPathComparator(sortBy));
+ }
+
+ try {
+ callback.onMergeComplete(merge.getContent());
+ } catch (Exception e) {
+ throw new MojoExecutionException("Exception uring XML merge", e);
+ }
+ }
+
+ public void setNamespaceAware(boolean namespaceAware) {
+ this.namespaceAware = namespaceAware;
+ }
+
+ public void setLog(Log log) {
+ this.log = log;
+ }
+
+ public void setXPath(String path) {
+ xPath = path;
+ }
+
+ public void setKeyXPath(String keyXPath) {
+ this.keyXPath = keyXPath;
+ }
+}
Copied:
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/VelocityTaglibMergeCallBack.java
(from rev 7763,
branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/VelocityTaglibMergeCallBack.java)
===================================================================
---
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/VelocityTaglibMergeCallBack.java
(rev 0)
+++
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/VelocityTaglibMergeCallBack.java 2008-04-11
15:16:20 UTC (rev 7770)
@@ -0,0 +1,56 @@
+/**
+ *
+ */
+package org.ajax4jsf.builder.maven;
+
+import java.io.File;
+import java.io.FileWriter;
+
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.codehaus.plexus.velocity.VelocityComponent;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class VelocityTaglibMergeCallBack implements XMLMergeCallback {
+
+ private File target;
+
+ private String template;
+
+ private VelocityComponent velocity;
+
+ private VelocityContext initialContext;
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.builder.maven.XMLMergeCallback#onMergeComplete(java.lang.String)
+ */
+ public void onMergeComplete(String mergedContent) throws Exception{
+
+ VelocityContext velocityContext;
+
+ if (initialContext != null) {
+ velocityContext = new VelocityContext(initialContext);
+ } else {
+ velocityContext = new VelocityContext();
+ }
+
+ VelocityEngine velocityEngine = velocity.getEngine();
+ Template template2 = velocityEngine.getTemplate(template);
+
+ File parentFile = target.getParentFile();
+ if (!parentFile.exists()) {
+ parentFile.mkdirs();
+ }
+
+ FileWriter fileWriter = new FileWriter(target);
+
+ template2.merge(velocityContext, fileWriter);
+ fileWriter.flush();
+ fileWriter.close();
+ }
+
+}
Copied:
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/XMLMergeCallback.java
(from rev 7763,
branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/XMLMergeCallback.java)
===================================================================
---
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/XMLMergeCallback.java
(rev 0)
+++
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/XMLMergeCallback.java 2008-04-11
15:16:20 UTC (rev 7770)
@@ -0,0 +1,13 @@
+/**
+ *
+ */
+package org.ajax4jsf.builder.maven;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public interface XMLMergeCallback {
+ void onMergeComplete(String mergedContent) throws Exception;
+
+}
Modified:
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyAttachedLibraryMojo.java
===================================================================
---
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyAttachedLibraryMojo.java 2008-04-11
15:16:12 UTC (rev 7769)
+++
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyAttachedLibraryMojo.java 2008-04-11
15:16:20 UTC (rev 7770)
@@ -30,6 +30,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -39,6 +40,8 @@
import org.ajax4jsf.builder.config.ParsingException;
import org.ajax4jsf.builder.xml.XMLBody;
+import org.ajax4jsf.builder.xml.XMLBodyMerge;
+import org.ajax4jsf.builder.xml.XPathComparator;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
@@ -55,15 +58,11 @@
import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.project.MavenProjectHelper;
import org.apache.maven.project.ProjectBuildingException;
-import org.apache.maven.shared.io.scan.ResourceInclusionScanner;
-import org.apache.maven.shared.io.scan.SimpleResourceInclusionScanner;
import org.apache.velocity.VelocityContext;
-import org.apache.velocity.exception.MethodInvocationException;
-import org.apache.velocity.exception.ParseErrorException;
-import org.apache.velocity.exception.ResourceNotFoundException;
import org.codehaus.plexus.archiver.UnArchiver;
import org.codehaus.plexus.archiver.manager.ArchiverManager;
import org.codehaus.plexus.util.DirectoryScanner;
+import org.w3c.dom.Node;
/**
* This plugin assembly full components library from modules, included in parent
@@ -357,17 +356,17 @@
"META-INF/resources-config.xml");
mergeXML(models, "META-INF/resources-config.xml",
RESOURCES_CONFIG_TEMPLATE, "/resource-config/resource",
"name/text()",
- new VelocityContext(), resourcesConfig);
+ new VelocityContext(), resourcesConfig, null);
File tld = new File(outputDirectory, "META-INF/"
+ library.getTaglib().getShortName() + ".tld");
mergeXML(models, includeTld, TLD_TEMPLATE,
"/taglib/tag | /taglib/listener",
- null, new VelocityContext(), tld);
+ null, new VelocityContext(), tld, new XPathComparator("local-name()",
"name/text()", "listener-class/text()"));
File taglib = new File(outputDirectory, "META-INF/"
+ library.getTaglib().getShortName() + ".taglib.xml");
mergeXML(models, includeTaglib, TAGLIB_TEMPLATE,
"/facelet-taglib/tag | /facelet-taglib/function",
- null, new VelocityContext(), taglib);
+ null, new VelocityContext(), taglib, new XPathComparator("local-name()",
"tag-name/text()", "function-name/text()"));
}else {
throw new MojoFailureException("Components library project must have parent pom
with components modules");
}
@@ -447,15 +446,15 @@
* Velocity context for template processing.
* @throws MojoExecutionException
*/
- private void mergeXML(List models, String filename, String templateName,
- String commonXpath, String keyXPath, VelocityContext context, File target)
+ private void mergeXML(List<Model> models, String filename, String templateName,
+ String commonXpath, String keyXPath, VelocityContext context, File target,
Comparator<Node> comparator)
throws MojoExecutionException {
- Set<String> keySet = new HashSet<String>();
- StringBuffer content = new StringBuffer();
+ StringBuilder content = new StringBuilder();
+ XMLBodyMerge bodyMerge = new XMLBodyMerge(commonXpath, keyXPath);
List<XMLBody> xmls = new ArrayList<XMLBody>(models.size());
String[] split = filename.split(",");
- for (Iterator iter = models.iterator(); iter.hasNext();) {
- Model model = (Model) iter.next();
+ for (Iterator<Model> iter = models.iterator(); iter.hasNext();) {
+ Model model = iter.next();
File moduleDir = new File(buildDirectory, model.getArtifactId());
DirectoryScanner ds = new DirectoryScanner();
ds.setFollowSymlinks(true);
@@ -473,15 +472,7 @@
try {
configBody.loadXML(new FileInputStream(moduleFacesConfig));
xmls.add(configBody);
- if (commonXpath != null) {
- if (keyXPath == null) {
- content.append(configBody.getContent(commonXpath));
- } else {
- content.append(configBody.getContentUnique(commonXpath, keyXPath, keySet));
- }
- } else {
- content.append(configBody.getContent());
- }
+ bodyMerge.add(configBody);
} catch (FileNotFoundException e) {
throw new MojoExecutionException("Could't read file "
+ moduleFacesConfig.getPath(), e);
@@ -490,10 +481,22 @@
"Error parsing config file "
+ moduleFacesConfig.getPath(), e);
}
+
+
}
}
+ if (comparator != null) {
+ bodyMerge.sort(comparator);
+ }
+
+ try {
+ content.append(bodyMerge.getContent());
+ } catch (Exception e) {
+ // TODO: handle exception
+ }
+
if (xmls.size() > 0) {
- context.put("content", content.toString());
+ context.put("content", content);
context.put("library", library);
context.put("models", models);
context.put("xmls", xmls);
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 2008-04-11
15:16:12 UTC (rev 7769)
+++
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyLibraryMojo.java 2008-04-11
15:16:20 UTC (rev 7770)
@@ -40,6 +40,8 @@
import org.ajax4jsf.builder.config.ParsingException;
import org.ajax4jsf.builder.xml.XMLBody;
+import org.ajax4jsf.builder.xml.XMLBodyMerge;
+import org.ajax4jsf.builder.xml.XPathComparator;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
@@ -59,6 +61,7 @@
import org.codehaus.plexus.archiver.UnArchiver;
import org.codehaus.plexus.archiver.manager.ArchiverManager;
import org.codehaus.plexus.util.DirectoryScanner;
+import org.w3c.dom.Node;
/**
* This plugin assembly full components library from modules, included in parent
@@ -92,6 +95,10 @@
private static final String TAGLIB_TEMPLATE = "taglib.vm";
+ private static final Comparator<Node> TLD_COMPARATOR = new
XPathComparator("local-name()", "listener-class/text()",
"name/text()");
+ private static final Comparator<Node> FACELET_COMPARATOR = new
XPathComparator("local-name()", "function-name/text()",
"tag-name/text()");
+
+
/**
* Used to look up Artifacts in the remote repository.
*
@@ -237,17 +244,17 @@
templates = Library.JSF12.equals(library.getJsfVersion()) ? TEMPLATES12_PREFIX
: TEMPLATES_PREFIX;
}
- List models = extractModules();
+ List<Model> models = extractModules();
mergeFacesConfig(models);
File resourcesConfig = new File(outputDirectory,
"META-INF/resources-config.xml");
mergeXML(models, "META-INF/resources-config.xml", null,
RESOURCES_CONFIG_TEMPLATE, "/resource-config/resource",
- "name/text()", new VelocityContext(), resourcesConfig, false);
+ "name/text()", new VelocityContext(), resourcesConfig, false, null);
if (null != commonStyle) {
File commonXcss = new File(outputDirectory, commonStyle);
mergeXML(models, includeXcss, excludeXcss, XCSS_TEMPLATE,
- templateXpath, null, new VelocityContext(), commonXcss, true);
+ templateXpath, null, new VelocityContext(), commonXcss, true, null);
}
if (null != library.getTaglibs() && library.getTaglibs().length > 0) {
@@ -268,7 +275,7 @@
excludeModules = taglib.getExcludeModules().split(",");
Arrays.sort(excludeModules);
}
- taglibModels = new ArrayList();
+ taglibModels = new ArrayList<Model>();
for (Iterator iterator = models.iterator(); iterator
.hasNext();) {
Model model = (Model) iterator.next();
@@ -281,27 +288,6 @@
}
}
}
- // sort taglib models by artifactIds in ASC order
- Collections.sort(taglibModels, new Comparator<Model>() {
- /**
- * Compares two <code>Model</code> objects by artifactIds
- * for sorting in ASC order
- * @param m1 - model object
- * @param m2 - model object
- * @return result of comparing
- */
- public int compare(Model m1, Model m2) {
- // check incoming parameters for null
- if ((m1 == null) || (m1.getArtifactId() == null)) {
- return -1;
- } else
- if ((m2 == null) || (m2.getArtifactId() == null)) {
- return 1;
- }
-
- return m1.getArtifactId().compareTo(m2.getArtifactId());
- }
- });
generateTaglib(taglibModels, taglib);
}
} else {
@@ -313,7 +299,7 @@
* @param models
* @throws MojoExecutionException
*/
- private void generateTaglib(List models, Taglib taglib)
+ private void generateTaglib(List<Model> models, Taglib taglib)
throws MojoExecutionException {
getLog().debug(
"Assembly taglib for uri " + taglib.getUri()
@@ -326,15 +312,21 @@
File tld = new File(outputDirectory, "META-INF/" + taglib.getTaglib()
+ ".tld");
getLog().debug("Write JSP taglib " + tld.getPath());
- mergeXML(models, includeTld, null, TLD_TEMPLATE, "/taglib/tag"
- + createTagCondition(taglib, "name") + " | /taglib/listener",
- null, new VelocityContext(taglibContext), tld, false);
+ String commonXPath = "/taglib/tag"
+ + createTagCondition(taglib, "name") + " | /taglib/listener |
/taglib/function";
+
+ mergeXML(models, includeTld, null, TLD_TEMPLATE, commonXPath,
+ "listener-class/text() | name/text()", new VelocityContext(taglibContext),
tld, false, TLD_COMPARATOR);
+
+
File faceletsTaglib = new File(outputDirectory, "META-INF/"
+ taglib.getTaglib() + ".taglib.xml");
- mergeXML(models, includeTaglib, null, TAGLIB_TEMPLATE, "/facelet-taglib/tag"
- + createTagCondition(taglib, "tag-name")
- + " | /facelet-taglib/function", null, new VelocityContext(
- taglibContext), faceletsTaglib, false);
+ commonXPath = "/facelet-taglib/tag"
+ + createTagCondition(taglib, "tag-name")
+ + " | /facelet-taglib/function";
+
+ mergeXML(models, includeTaglib, null, TAGLIB_TEMPLATE, commonXPath,
"tag-name/text() | function-name/text()", new VelocityContext(
+ taglibContext), faceletsTaglib, false, FACELET_COMPARATOR);
getLog().debug("Write Facelets taglib " + faceletsTaglib.getPath());
}
@@ -385,12 +377,12 @@
* @return
* @throws MojoExecutionException
*/
- private List extractModules() throws MojoExecutionException {
- List modules = parentProject.getModules();
- List models = new ArrayList(modules.size());
+ private List<Model> extractModules() throws MojoExecutionException {
+ List<String> modules = parentProject.getModules();
+ List<Model> models = new ArrayList<Model>(modules.size());
Map<String, Dependency> projectsDependencies = new HashMap<String,
Dependency>();
- for (Iterator iter = modules.iterator(); iter.hasNext();) {
- String moduleName = (String) iter.next();
+ for (Iterator<String> iter = modules.iterator(); iter.hasNext();) {
+ String moduleName = iter.next();
getLog().info("Parent project have module " + moduleName);
Model model;
File f = new File(parentProject.getBasedir(), moduleName
@@ -417,10 +409,10 @@
getLog().debug(
"Project " + model.getName()
+ " included to library set");
- List dependencies = model.getDependencies();
- for (Iterator iterator = dependencies.iterator(); iterator
+ List<Dependency> dependencies = model.getDependencies();
+ for (Iterator<Dependency> iterator = dependencies.iterator(); iterator
.hasNext();) {
- Dependency dependency = (Dependency) iterator.next();
+ Dependency dependency = iterator.next();
getLog().debug(
dependency.getClass().getName() + " : "
+ dependency + " with key: "
@@ -436,9 +428,9 @@
}
// Remove modules projects from dependencise
Set<String> unwanted = new HashSet<String>(projectsDependencies.size());
- for (Iterator iter = models.iterator(); iter.hasNext();) {
+ for (Iterator<Model> iter = models.iterator(); iter.hasNext();) {
Model model = (Model) iter.next();
- for (Iterator iterator = projectsDependencies.values().iterator(); iterator
+ for (Iterator<Dependency> iterator = projectsDependencies.values().iterator();
iterator
.hasNext();) {
Dependency dependency = (Dependency) iterator.next();
if (model.getGroupId().equals(dependency.getGroupId())
@@ -485,7 +477,7 @@
generatedProject.getDependencies()
.addAll(projectsDependencies.values());
writePom(generatedProject);
- project.setDependencies(new ArrayList(projectsDependencies.values()));
+ project.setDependencies(new
ArrayList<Dependency>(projectsDependencies.values()));
// project.setFile(generatedPom);
}
@@ -533,15 +525,15 @@
* @param models
* @throws MojoExecutionException
*/
- private void mergeFacesConfig(List models) throws MojoExecutionException {
+ private void mergeFacesConfig(List<Model> models) throws MojoExecutionException {
StringBuffer facesConfig = new StringBuffer();
for (int i = 0; i < library.getRenderkits().length; i++) {
Renderkit kit = library.getRenderkits()[i];
kit.setContent(new StringBuffer());
}
// Process all faces-config.xml from modules
- for (Iterator iter = models.iterator(); iter.hasNext();) {
- Model model = (Model) iter.next();
+ for (Iterator<Model> iter = models.iterator(); iter.hasNext();) {
+ Model model = iter.next();
File moduleFacesConfig = new File(modulesDirectory, model
.getArtifactId()
+ "/META-INF/faces-config.xml");
@@ -605,7 +597,7 @@
*
* @param models
* models collected in library.
- * @param filename
+ * @param includes
* relative path to config file in models/output.
* @param templateName -
* name of velocity template for result file.
@@ -620,34 +612,39 @@
* {@link Set} to check for duplicate keys. Must not be null
* @throws MojoExecutionException
*/
- private void mergeXML(List models, String filename, String excludes, String
templateName,
+ private void mergeXML(List<Model> models, String includes, String excludes, String
templateName,
String commonXpath, String keyXPath, VelocityContext context,
- File target, boolean namespaceAware) throws MojoExecutionException {
- Set<String> keySet = new HashSet<String>();
+ File target, boolean namespaceAware, Comparator<Node> comparator) throws
MojoExecutionException {
StringBuffer content = new StringBuffer();
- List<XMLBody> xmls = new ArrayList<XMLBody>(models.size());
- String[] split = filename.split(",");
+ String[] split = includes.split(",");
String[] excludesSplit = excludes != null ? excludes.split(",") : null;
- for (Iterator iter = models.iterator(); iter.hasNext();) {
- Model model = (Model) iter.next();
+ XMLBodyMerge xBodyMerge = new XMLBodyMerge(commonXpath, keyXPath);
+ for (Iterator<Model> iter = models.iterator(); iter.hasNext();) {
+ Model model = iter.next();
File moduleDir = new File(modulesDirectory, model.getArtifactId());
- mergeXMLdir(moduleDir, commonXpath, keyXPath, namespaceAware,
- keySet, content, xmls, split, excludesSplit);
+ mergeXMLdir(moduleDir, namespaceAware, split, excludesSplit, xBodyMerge);
}
if(null!=config){
- mergeXMLdir(config, commonXpath, keyXPath, namespaceAware,
- keySet, content, xmls, split, excludesSplit);
+ mergeXMLdir(config, namespaceAware, split, excludesSplit, xBodyMerge);
}
- if (xmls.size() > 0) {
+
+ if (comparator != null) {
+ xBodyMerge.sort(comparator);
+ }
+ try {
+ content.append(xBodyMerge.getContent());
+ } catch (Exception e1) {
+ throw new MojoExecutionException("XML Merge Exception Occured", e1);
+ }
+ if (content.length() > 0) {
context.put("content", content.toString());
context.put("library", library);
context.put("models", models);
- context.put("xmls", xmls);
try {
writeParsedTemplate(templates + templateName, context, target);
} catch (Exception e) {
throw new MojoExecutionException("Error to process template "
- + templateName + " for files " + filename, e);
+ + templateName + " for files " + includes, e);
}
}
@@ -665,9 +662,7 @@
* @throws IllegalStateException
* @throws MojoExecutionException
*/
- private void mergeXMLdir(File moduleDir, String commonXpath,
- String keyXPath, boolean namespaceAware, Set<String> keySet,
- StringBuffer content, List<XMLBody> xmls, String[] split, String[]
excludesSplit)
+ private void mergeXMLdir(File moduleDir, boolean namespaceAware, String[] split,
String[] excludesSplit, XMLBodyMerge xBodyMerge)
throws IllegalStateException, MojoExecutionException {
DirectoryScanner ds = new DirectoryScanner();
ds.setFollowSymlinks(true);
@@ -684,17 +679,7 @@
XMLBody configBody = new XMLBody();
try {
configBody.loadXML(new FileInputStream(moduleFacesConfig),namespaceAware);
- xmls.add(configBody);
- if (commonXpath != null) {
- if (keyXPath == null) {
- content.append(configBody.getContent(commonXpath));
- } else {
- content.append(configBody.getContentUnique(
- commonXpath, keyXPath, keySet));
- }
- } else {
- content.append(configBody.getContent());
- }
+ xBodyMerge.add(configBody);
} catch (FileNotFoundException e) {
throw new MojoExecutionException("Could't read file "
+ moduleFacesConfig.getPath(), e);