ソースを参照

AMBARI-9928. StormMetricsReporter doesn't package dependencies in single jar. (mpapyrkovskyy)

Myroslav Papirkovskyy 10 年 前
コミット
3db526ca91

+ 53 - 22
ambari-metrics/ambari-metrics-storm-sink/pom.xml

@@ -31,32 +31,11 @@ limitations under the License.
   <packaging>jar</packaging>
 
   <properties>
-    <storm.version>0.9.3</storm.version>
+    <storm.version>0.9.3.2.2.1.0-2341</storm.version>
   </properties>
 
   <build>
     <plugins>
-      <plugin>
-        <artifactId>maven-assembly-plugin</artifactId>
-        <executions>
-          <execution>
-            <configuration>
-              <descriptors>
-                <descriptor>src/main/assemblies/jar-with-common.xml</descriptor>
-              </descriptors>
-              <attach>false</attach>
-              <tarLongFileMode>gnu</tarLongFileMode>
-              <appendAssemblyId>false</appendAssemblyId>
-              <finalName>${project.artifactId}-with-common-${project.version}</finalName>
-            </configuration>
-            <id>build-jar</id>
-            <phase>package</phase>
-            <goals>
-              <goal>single</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
       <plugin>
         <artifactId>maven-compiler-plugin</artifactId>
         <version>3.0</version>
@@ -99,6 +78,58 @@ limitations under the License.
           </execution>
         </executions>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <version>2.2</version>
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <outputFile>${project.build.directory}/${project.artifactId}-with-common-${project.version}.jar</outputFile>
+          <minimizeJar>false</minimizeJar>
+          <keepDependenciesWithProvidedScope>true</keepDependenciesWithProvidedScope>
+          <artifactSet>
+            <includes>
+              <include>org.apache.ambari:ambari-metrics-common</include>
+              <include>org.codehaus.jackson:jackson-mapper-asl</include>
+              <include>org.codehaus.jackson:jackson-core-asl</include>
+              <include>org.codehaus.jackson:jackson-xc</include>
+              <include>org.apache.hadoop:hadoop-annotations</include>
+              <include>commons-httpclient:commons-httpclient</include>
+              <include>commons-logging:commons-logging</include>
+              <include>commons-lang:commons-lang</include>
+            </includes>
+          </artifactSet>
+          <relocations>
+            <relocation>
+              <pattern>org.apache.commons.logging</pattern>
+              <shadedPattern>org.apache.hadoop.metrics2.sink.relocated.commons.logging</shadedPattern>
+            </relocation>
+            <relocation>
+              <pattern>org.apache.commons.httpclient</pattern>
+              <shadedPattern>org.apache.hadoop.metrics2.sink.relocated.commons.httpclient</shadedPattern>
+            </relocation>
+            <relocation>
+              <pattern>org.apache.commons.lang</pattern>
+              <shadedPattern>org.apache.hadoop.metrics2.sink.relocated.commons.lang</shadedPattern>
+            </relocation>
+            <relocation>
+              <pattern>org.apache.hadoop.classification</pattern>
+              <shadedPattern>org.apache.hadoop.metrics2.sink.relocated.hadoop.classification</shadedPattern>
+            </relocation>
+            <relocation>
+              <pattern>org.codehaus.jackson</pattern>
+              <shadedPattern>org.apache.hadoop.metrics2.sink.relocated.jackson</shadedPattern>
+            </relocation>
+          </relocations>
+        </configuration>
+      </plugin>
     </plugins>
   </build>
   <dependencies>

+ 0 - 38
ambari-metrics/ambari-metrics-storm-sink/src/main/assemblies/jar-with-common.xml

@@ -1,38 +0,0 @@
-<?xml version="1.0"?>
-<!--
-   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.
--->
-<assembly>
-  <id>jar-with-common</id>
-  <formats>
-    <format>jar</format>
-  </formats>
-  <includeBaseDirectory>false</includeBaseDirectory>
-  <dependencySets>
-    <dependencySet>
-      <outputDirectory>/</outputDirectory>
-      <unpack>true</unpack>
-      <includes>
-        <include>org.apache.ambari:ambari-metrics-common</include>
-        <include>org.apache.ambari:ambari-metrics-storm-sink</include>
-        <include>org.codehaus.jackson:jackson-mapper-asl</include> <!--missing in storm classpath-->
-        <include>org.codehaus.jackson:jackson-core-asl</include> <!--missing in storm classpath-->
-        <include>org.codehaus.jackson:jackson-xc</include> <!--missing in storm classpath-->
-        <include>commons-httpclient:commons-httpclient</include> <!--missing in storm classpath-->
-      </includes>
-    </dependencySet>
-  </dependencySets>
-</assembly>