[seam-commits] Seam SVN: r13042 - in build/trunk: tools and 8 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Fri Jun 4 13:10:06 EDT 2010


Author: pete.muir at jboss.org
Date: 2010-06-04 13:10:06 -0400 (Fri, 04 Jun 2010)
New Revision: 13042

Added:
   build/trunk/tools/
   build/trunk/tools/pom.xml
   build/trunk/tools/src/
   build/trunk/tools/src/main/
   build/trunk/tools/src/main/java/
   build/trunk/tools/src/main/java/org/
   build/trunk/tools/src/main/java/org/jboss/
   build/trunk/tools/src/main/java/org/jboss/seam/
   build/trunk/tools/src/main/java/org/jboss/seam/build/
   build/trunk/tools/src/main/java/org/jboss/seam/build/tools/
   build/trunk/tools/src/main/java/org/jboss/seam/build/tools/XmlAppendingTransformer.java
Log:
add build tools

Added: build/trunk/tools/pom.xml
===================================================================
--- build/trunk/tools/pom.xml	                        (rev 0)
+++ build/trunk/tools/pom.xml	2010-06-04 17:10:06 UTC (rev 13042)
@@ -0,0 +1,66 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+   <modelVersion>4.0.0</modelVersion>
+
+   <groupId>org.jboss.seam.build</groupId>
+   <artifactId>seam-maven-tools</artifactId>
+   <packaging>jar</packaging>
+   <version>1.0.0-SNAPSHOT</version>
+   <name>Seam Build Tools</name>
+
+   <parent>
+      <groupId>org.jboss.weld</groupId>
+      <artifactId>weld-parent</artifactId>
+      <version>11</version>
+   </parent>
+
+   <description>
+      Seam build tools
+   </description>
+
+   <url>http://www.seamframework.org</url>
+
+   <licenses>
+      <license>
+         <name>GNU Lesser General Public License, Version 2.1</name>
+         <distribution>repo</distribution>
+         <url>http://www.gnu.org/licenses/lgpl-2.1.txt</url>
+      </license>
+   </licenses>
+
+   <developers>
+      <developer>
+         <name>Seam committers</name>
+      </developer>
+   </developers>
+
+   <properties>
+      <maven.shade.version>1.3.3</maven.shade.version>
+   </properties>
+
+   <dependencyManagement>
+      <dependencies>
+
+         <dependency>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-shade-plugin</artifactId>
+            <version>${maven.shade.version}</version>
+         </dependency>
+
+      </dependencies>
+   </dependencyManagement>
+
+   <dependencies>
+      <dependency>
+         <groupId>org.apache.maven.plugins</groupId>
+         <artifactId>maven-shade-plugin</artifactId>
+      </dependency>
+   </dependencies>
+
+   <scm>
+      <connection>scm:svn:http://anonsvn.jboss.org/repos/seam/build/trunk/parent</connection>
+      <developerConnection>scm:svn:https://svn.jboss.org/repos/seam/build/trunk/parent</developerConnection>
+      <url>http://fisheye.jboss.org/browse/Seam/seam/build/trunk/parent</url>
+   </scm>
+
+</project>

Added: build/trunk/tools/src/main/java/org/jboss/seam/build/tools/XmlAppendingTransformer.java
===================================================================
--- build/trunk/tools/src/main/java/org/jboss/seam/build/tools/XmlAppendingTransformer.java	                        (rev 0)
+++ build/trunk/tools/src/main/java/org/jboss/seam/build/tools/XmlAppendingTransformer.java	2010-06-04 17:10:06 UTC (rev 13042)
@@ -0,0 +1,112 @@
+package org.jboss.seam.build.tools;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.util.Iterator;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+
+import org.apache.maven.plugins.shade.resource.ResourceTransformer;
+import org.jdom.Attribute;
+import org.jdom.Content;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.jdom.input.SAXBuilder;
+import org.jdom.output.Format;
+import org.jdom.output.XMLOutputter;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class XmlAppendingTransformer implements ResourceTransformer
+{
+   
+   String resource;
+
+   private Document doc;
+
+   public boolean canTransformResource(String resource)
+   {
+      if ( this.resource != null && this.resource.equalsIgnoreCase( resource ) )
+      {
+          return true;
+      }
+
+      return false;
+   }
+
+   public boolean hasTransformedResource()
+   {
+      return doc != null;
+   }
+
+   public void modifyOutputStream(JarOutputStream os) throws IOException
+   {
+      os.putNextEntry(new JarEntry(resource));
+
+      new XMLOutputter(Format.getPrettyFormat()).output(doc, os);
+
+      doc = null;
+   }
+
+   public void processResource(String resource, InputStream is, List relocators) throws IOException
+   {
+      Document r;
+      try
+      {
+         SAXBuilder builder = new SAXBuilder(false);
+         builder.setExpandEntities(false);
+         builder.setEntityResolver(new EntityResolver()
+         {
+            public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
+            {
+               return new InputSource(new StringReader(""));
+            }
+         });
+         // Allow empty files
+         if (is.available() == 0)
+         {
+            return;
+         }
+         r = builder.build(is);
+      }
+      catch (JDOMException e)
+      {
+         throw new RuntimeException(e);
+      }
+
+      if (doc == null)
+      {
+         doc = r;
+      }
+      else
+      {
+         Element root = r.getRootElement();
+
+         for (Iterator itr = root.getAttributes().iterator(); itr.hasNext();)
+         {
+            Attribute a = (Attribute) itr.next();
+            itr.remove();
+
+            Element mergedEl = doc.getRootElement();
+            Attribute mergedAtt = mergedEl.getAttribute(a.getName(), a.getNamespace());
+            if (mergedAtt == null)
+            {
+               mergedEl.setAttribute(a);
+            }
+         }
+
+         for (Iterator itr = root.getChildren().iterator(); itr.hasNext();)
+         {
+            Content n = (Content) itr.next();
+            itr.remove();
+
+            doc.getRootElement().addContent(n);
+         }
+      }
+   }
+
+}


Property changes on: build/trunk/tools/src/main/java/org/jboss/seam/build/tools/XmlAppendingTransformer.java
___________________________________________________________________
Name: svn:eol-style
   + native



More information about the seam-commits mailing list