You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2019/08/28 12:45:51 UTC

[plc4x] 01/02: - Replaced using the assembly plugin for building most of the fat-jars with the shade-plugin

This is an automated email from the ASF dual-hosted git repository.

cdutz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git

commit 1cbfee788a32a2ce0a4bc6ec4124eae8c6c61253
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Wed Aug 28 14:45:03 2019 +0200

    - Replaced using the assembly plugin for building most of the fat-jars with the shade-plugin
---
 plc4j/examples/dummy-driver/pom.xml                |  15 +++
 plc4j/examples/hello-webapp/pom.xml                |  24 +++--
 plc4j/examples/pom.xml                             | 117 ++++++++-------------
 plc4j/integrations/apache-kafka/pom.xml            |  10 +-
 .../apache-kafka/src/assembly/assembly.xml         |  42 --------
 plc4j/utils/interop/pom.xml                        |   1 -
 pom.xml                                            |  16 +++
 7 files changed, 93 insertions(+), 132 deletions(-)

diff --git a/plc4j/examples/dummy-driver/pom.xml b/plc4j/examples/dummy-driver/pom.xml
index f1f40df..af91fdf 100644
--- a/plc4j/examples/dummy-driver/pom.xml
+++ b/plc4j/examples/dummy-driver/pom.xml
@@ -67,6 +67,21 @@
 
   <build>
     <plugins>
+      <!-- Disable building the uber-jar -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <version>3.2.1</version>
+        <executions>
+          <execution>
+            <id>generate-uber-jar</id>
+            <phase>none</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
       <!-- This is currently a work in progress ... skip this till it reaches a slightly more mature state -->
       <plugin>
         <groupId>org.sonarsource.scanner.maven</groupId>
diff --git a/plc4j/examples/hello-webapp/pom.xml b/plc4j/examples/hello-webapp/pom.xml
index ed2273f..4293ccd 100644
--- a/plc4j/examples/hello-webapp/pom.xml
+++ b/plc4j/examples/hello-webapp/pom.xml
@@ -43,6 +43,23 @@
   </modules>
 
   <build>
+    <plugins>
+      <!-- Disable building the uber-jar -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <version>3.2.1</version>
+        <executions>
+          <execution>
+            <id>generate-uber-jar</id>
+            <phase>none</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
     <pluginManagement>
       <plugins>
         <plugin>
@@ -52,13 +69,6 @@
             <skip>true</skip>
           </configuration>
         </plugin>
-        <plugin>
-          <groupId>org.apache.maven.plugins</groupId>
-          <artifactId>maven-assembly-plugin</artifactId>
-          <configuration>
-            <skipAssembly>true</skipAssembly>
-          </configuration>
-        </plugin>
       </plugins>
     </pluginManagement>
   </build>
diff --git a/plc4j/examples/pom.xml b/plc4j/examples/pom.xml
index 36340f9..982e01c 100644
--- a/plc4j/examples/pom.xml
+++ b/plc4j/examples/pom.xml
@@ -34,6 +34,10 @@
   <name>PLC4J: Examples</name>
   <description>Parent of all java based application example modules.</description>
 
+  <properties>
+    <app.main.class>override-this-property-in-application-pom</app.main.class>
+  </properties>
+
   <modules>
     <module>dummy-driver</module>
     <module>hello-cloud-azure</module>
@@ -47,23 +51,6 @@
     <module>hello-world-plc4x</module>
   </modules>
 
-  <dependencyManagement>
-    <dependencies>
-      <dependency>
-        <groupId>ch.qos.logback</groupId>
-        <artifactId>logback-core</artifactId>
-        <version>${logback.version}</version>
-        <scope>compile</scope>
-      </dependency>
-      <dependency>
-        <groupId>ch.qos.logback</groupId>
-        <artifactId>logback-classic</artifactId>
-        <version>${logback.version}</version>
-        <scope>compile</scope>
-      </dependency>
-    </dependencies>
-  </dependencyManagement>
-
   <build>
     <plugins>
       <!-- This is just examples including these checks here requires an insane amount of housekeeping. -->
@@ -74,14 +61,30 @@
           <skip>true</skip>
         </configuration>
       </plugin>
+      <!-- Build a fat jar containing all dependencies -->
       <plugin>
-        <groupId>org.owasp</groupId>
-        <artifactId>dependency-check-maven</artifactId>
-        <configuration>
-          <skip>true</skip>
-        </configuration>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <version>3.2.1</version>
+        <executions>
+          <execution>
+            <id>generate-uber-jar</id>
+            <phase>package</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+            <configuration>
+              <transformers combine.children="append">
+                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+                  <mainClass>${app.main.class}</mainClass>
+                </transformer>
+              </transformers>
+            </configuration>
+          </execution>
+        </executions>
       </plugin>
     </plugins>
+
     <pluginManagement>
       <plugins>
         <!-- No need to deploy examples in a maven repo -->
@@ -96,59 +99,21 @@
     </pluginManagement>
   </build>
 
-  <profiles>
-    <profile>
-      <id>build-executable-jars</id>
-      <properties>
-        <app.main.class>override-this-property-in-application-pom</app.main.class>
-      </properties>
-      <build>
-        <plugins>
-          <plugin>
-            <groupId>org.apache.maven.plugins</groupId>
-            <artifactId>maven-assembly-plugin</artifactId>
-            <version>3.1.0</version>
-            <executions>
-              <execution>
-                <id>create-no-deps-jar</id>
-                <phase>package</phase>
-                <goals>
-                  <goal>single</goal>
-                </goals>
-                <configuration>
-                  <finalName>${project.artifactId}-${project.version}</finalName>
-                  <archive>
-                    <manifest>
-                      <mainClass>${app.main.class}</mainClass>
-                    </manifest>
-                  </archive>
-                  <descriptorRefs>
-                    <descriptorRef>jar-with-dependencies</descriptorRef>
-                  </descriptorRefs>
-                </configuration>
-              </execution>
-            </executions>
-          </plugin>
-        </plugins>
-        <!--
-          We don't want to build an assembly of this module, so we make sure "skipAssembly" is
-          set to "true", but this configuration is not inherited.
-        -->
-        <pluginManagement>
-          <plugins>
-            <plugin>
-              <groupId>org.apache.maven.plugins</groupId>
-              <artifactId>maven-assembly-plugin</artifactId>
-              <version>3.1.0</version>
-              <inherited>false</inherited>
-              <configuration>
-                <skipAssembly>true</skipAssembly>
-              </configuration>
-            </plugin>
-          </plugins>
-        </pluginManagement>
-      </build>
-    </profile>
-  </profiles>
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>ch.qos.logback</groupId>
+        <artifactId>logback-core</artifactId>
+        <version>${logback.version}</version>
+        <scope>compile</scope>
+      </dependency>
+      <dependency>
+        <groupId>ch.qos.logback</groupId>
+        <artifactId>logback-classic</artifactId>
+        <version>${logback.version}</version>
+        <scope>compile</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
 
 </project>
\ No newline at end of file
diff --git a/plc4j/integrations/apache-kafka/pom.xml b/plc4j/integrations/apache-kafka/pom.xml
index 71f4b08..58fbbb8 100644
--- a/plc4j/integrations/apache-kafka/pom.xml
+++ b/plc4j/integrations/apache-kafka/pom.xml
@@ -38,19 +38,17 @@
   <!-- Build a fat jar so the user only needs to drop in this one jar -->
   <build>
     <plugins>
+      <!-- Build a fat jar containing all dependencies -->
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-assembly-plugin</artifactId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <version>3.2.1</version>
         <executions>
           <execution>
-            <id>assemble-all</id>
             <phase>package</phase>
             <goals>
-              <goal>single</goal>
+              <goal>shade</goal>
             </goals>
-            <configuration>
-              <descriptors>src/assembly/assembly.xml</descriptors>
-            </configuration>
           </execution>
         </executions>
       </plugin>
diff --git a/plc4j/integrations/apache-kafka/src/assembly/assembly.xml b/plc4j/integrations/apache-kafka/src/assembly/assembly.xml
deleted file mode 100644
index a1a8793..0000000
--- a/plc4j/integrations/apache-kafka/src/assembly/assembly.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?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.
-
--->
-<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
-          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-          xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
-  <id>jar-with-dependencies</id>
-  <formats>
-    <format>jar</format>
-  </formats>
-  <includeBaseDirectory>false</includeBaseDirectory>
-  <dependencySets>
-    <dependencySet>
-      <outputDirectory>/</outputDirectory>
-      <useProjectArtifact>true</useProjectArtifact>
-      <unpack>true</unpack>
-      <scope>runtime</scope>
-    </dependencySet>
-  </dependencySets>
-  <containerDescriptorHandlers>
-    <!-- Make sure the service descriptors are merged (Otherwise only one driver is found) -->
-    <containerDescriptorHandler>
-      <handlerName>metaInf-services</handlerName>
-    </containerDescriptorHandler>
-  </containerDescriptorHandlers>
-</assembly>
\ No newline at end of file
diff --git a/plc4j/utils/interop/pom.xml b/plc4j/utils/interop/pom.xml
index 2482eac..56e0d02 100644
--- a/plc4j/utils/interop/pom.xml
+++ b/plc4j/utils/interop/pom.xml
@@ -130,7 +130,6 @@
               <mainClass>org.apache.plc4x.interop.impl.Server</mainClass>
             </manifest>
           </archive>
-
         </configuration>
         <executions>
           <execution>
diff --git a/pom.xml b/pom.xml
index 7b46a4a..e48c26c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -833,6 +833,7 @@
           </execution>
         </executions>
         <configuration>
+          <useMavenDefaultExcludes>true</useMavenDefaultExcludes>
           <excludes>
             <!-- Git related files -->
             <exclude>**/.git/**</exclude>
@@ -848,6 +849,7 @@
 
             <!-- Maven related files -->
             <exclude>**/target/**</exclude>
+            <exclude>target/**</exclude>
 
             <!-- Eclipse related files -->
             <exclude>**/.project</exclude>
@@ -1105,6 +1107,7 @@
         <plugin>
           <groupId>org.apache.rat</groupId>
           <artifactId>apache-rat-plugin</artifactId>
+          <version>0.13</version>
           <configuration>
             <!--
                 Make rat output the files with missing licensed directly into the
@@ -1211,6 +1214,19 @@
         </plugin>
 
         <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-shade-plugin</artifactId>
+          <version>3.2.1</version>
+          <configuration>
+            <outputFile>${project.build.directory}/${project.artifactId}-${project.version}-uber-jar.${project.packaging}</outputFile>
+            <transformers>
+              <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
+            </transformers>
+            <dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
+          </configuration>
+        </plugin>
+
+        <plugin>
           <groupId>org.sonarsource.scanner.maven</groupId>
           <artifactId>sonar-maven-plugin</artifactId>
           <version>3.6.0.1398</version>