storm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ptgo...@apache.org
Subject [1/3] git commit: add maven shade transformer to relocate package names in clojure sources
Date Mon, 03 Feb 2014 22:30:39 GMT
Updated Branches:
  refs/heads/master 263fade3d -> f1c9332cb


add maven shade transformer to relocate package names in clojure sources


Project: http://git-wip-us.apache.org/repos/asf/incubator-storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-storm/commit/5eaf09f4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-storm/tree/5eaf09f4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-storm/diff/5eaf09f4

Branch: refs/heads/master
Commit: 5eaf09f44f499c0728ceaafa2c307175c1d391ef
Parents: 263fade
Author: P. Taylor Goetz <ptgoetz@gmail.com>
Authored: Fri Jan 31 16:33:24 2014 -0500
Committer: P. Taylor Goetz <ptgoetz@gmail.com>
Committed: Fri Jan 31 16:33:24 2014 -0500

----------------------------------------------------------------------
 pom.xml                                         |  7 ++
 .../maven-shade-clojure-transformer/pom.xml     | 41 +++++++++++
 .../maven/shade/clojure/ClojureTransformer.java | 72 ++++++++++++++++++++
 storm-core/pom.xml                              | 23 ++++++-
 4 files changed, 141 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/5eaf09f4/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index a693195..5e8a22e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -128,6 +128,7 @@
     </prerequisites>
 
     <modules>
+        <module>storm-buildtools/maven-shade-clojure-transformer</module>
         <module>storm-core</module>
     </modules>
 
@@ -151,6 +152,7 @@
         <compojure.version>1.1.3</compojure.version>
         <hiccup.version>0.3.6</hiccup.version>
         <commons-io.verson>1.4</commons-io.verson>
+        <commons-lang.version>2.5</commons-lang.version>
         <commons-exec.version>1.1</commons-exec.version>
         <clj-time.version>0.4.1</clj-time.version>
         <curator.version>1.0.1</curator.version>
@@ -273,6 +275,11 @@
                 <version>${commons-exec.version}</version>
             </dependency>
             <dependency>
+                <groupId>commons-lang</groupId>
+                <artifactId>commons-lang</artifactId>
+                <version>${commons-lang.version}</version>
+            </dependency>
+            <dependency>
                 <groupId>clj-time</groupId>
                 <artifactId>clj-time</artifactId>
                 <version>${clj-time.version}</version>

http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/5eaf09f4/storm-buildtools/maven-shade-clojure-transformer/pom.xml
----------------------------------------------------------------------
diff --git a/storm-buildtools/maven-shade-clojure-transformer/pom.xml b/storm-buildtools/maven-shade-clojure-transformer/pom.xml
new file mode 100644
index 0000000..41153d2
--- /dev/null
+++ b/storm-buildtools/maven-shade-clojure-transformer/pom.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+	
+	<parent>
+	        <artifactId>storm</artifactId>
+	        <groupId>org.apache.storm</groupId>
+	        <version>0.9.2-incubating-SNAPSHOT</version>
+            <relativePath>../../pom.xml</relativePath>
+	    </parent>
+
+    <groupId>org.apache.storm</groupId>
+    <artifactId>maven-shade-clojure-transformer</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-shade-plugin</artifactId>
+            <version>2.2</version>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/5eaf09f4/storm-buildtools/maven-shade-clojure-transformer/src/main/java/org/apache/storm/maven/shade/clojure/ClojureTransformer.java
----------------------------------------------------------------------
diff --git a/storm-buildtools/maven-shade-clojure-transformer/src/main/java/org/apache/storm/maven/shade/clojure/ClojureTransformer.java
b/storm-buildtools/maven-shade-clojure-transformer/src/main/java/org/apache/storm/maven/shade/clojure/ClojureTransformer.java
new file mode 100644
index 0000000..a24c67d
--- /dev/null
+++ b/storm-buildtools/maven-shade-clojure-transformer/src/main/java/org/apache/storm/maven/shade/clojure/ClojureTransformer.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.maven.shade.clojure;
+
+import org.apache.maven.plugins.shade.relocation.Relocator;
+import org.apache.maven.plugins.shade.resource.ResourceTransformer;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+
+
+public class ClojureTransformer implements ResourceTransformer {
+
+    private HashMap<String, String> entries = new HashMap<String, String>();
+
+    @Override
+    public boolean canTransformResource(String s) {
+        if(s.endsWith(".clj")){
+            return true;
+        }
+        return false;
+    }
+
+    @Override
+    public void processResource(String s, InputStream inputStream, List<Relocator>
relocators) throws IOException {
+
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        int b;
+        while((b = inputStream.read()) != -1){
+            out.write(b);
+        }
+        String data = out.toString();
+
+        for(Relocator rel : relocators){
+            data = rel.applyToSourceContent(data);
+        }
+        this.entries.put(s, data);
+    }
+
+    @Override
+    public boolean hasTransformedResource() {
+        return true;
+    }
+
+    @Override
+    public void modifyOutputStream(JarOutputStream jarOut) throws IOException {
+        for(String key : this.entries.keySet()){
+            jarOut.putNextEntry(new JarEntry(key));
+            jarOut.write(this.entries.get(key).getBytes());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/5eaf09f4/storm-core/pom.xml
----------------------------------------------------------------------
diff --git a/storm-core/pom.xml b/storm-core/pom.xml
index fd9ed21..0de9a94 100644
--- a/storm-core/pom.xml
+++ b/storm-core/pom.xml
@@ -87,6 +87,10 @@
             <artifactId>commons-exec</artifactId>
         </dependency>
         <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+        </dependency>
+        <dependency>
             <groupId>org.apache.thrift</groupId>
             <artifactId>libthrift</artifactId>
             <version>0.7.0</version>
@@ -96,6 +100,10 @@
                     <groupId>org.slf4j</groupId>
                     <artifactId>slf4j-api</artifactId>
                 </exclusion>
+                <exclusion>
+                    <groupId>javax.servlet</groupId>
+                    <artifactId>servlet-api</artifactId>
+                </exclusion>
             </exclusions>
         </dependency>
 
@@ -223,12 +231,13 @@
                 </executions>
                 <configuration>
                     <keepDependenciesWithProvidedScope>true</keepDependenciesWithProvidedScope>
-                    <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
-                    <createDependencyReducedPom>true</createDependencyReducedPom>
                     <promoteTransitiveDependencies>false</promoteTransitiveDependencies>
+                    <createDependencyReducedPom>true</createDependencyReducedPom>
+                    <minimizeJar>false</minimizeJar>
                     <artifactSet>
                         <includes>
                             <include>org.apache.thrift:*</include>
+                            <include>odg.apache.storm:*</include>
                         </includes>
                     </artifactSet>
 
@@ -238,6 +247,9 @@
                             <shadedPattern>org.apache.thrift7</shadedPattern>
                         </relocation>
                     </relocations>
+                    <transformers>
+                        <transformer implementation="org.apache.storm.maven.shade.clojure.ClojureTransformer"/>
+                    </transformers>
                     <filters>
                         <filter>
                             <artifact>*:*</artifact>
@@ -253,6 +265,13 @@
                         </filter>
                     </filters>
                 </configuration>
+                <dependencies>
+                    <dependency>
+                        <groupId>org.apache.storm</groupId>
+                        <artifactId>maven-shade-clojure-transformer</artifactId>
+                        <version>${project.version}</version>
+                    </dependency>
+                </dependencies>
             </plugin>
 
         </plugins>


Mime
View raw message