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

gortiz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new a076fce6ee Introduce pinot-plugin assembly-desciptor as a better 
alternative than shading (#13849)
a076fce6ee is described below

commit a076fce6ee320c78948bdd0ad3c83bbeb529ef89
Author: Robert Scholte <[email protected]>
AuthorDate: Mon Sep 2 10:11:10 2024 +0200

    Introduce pinot-plugin assembly-desciptor as a better alternative than 
shading (#13849)
    
    Shading is still supported
---
 pinot-plugins/assembly-descriptor/pom.xml          | 81 ++++++++++++++++++++
 .../src/it/projects/simple-assembly/pom.xml        | 88 ++++++++++++++++++++++
 .../src/main/java/org/apache/pinot/it/Simple.java  | 29 +++++++
 .../src/main/resources/pinot-plugin.properties     | 20 +++++
 .../src/it/projects/simple-assembly/verify.groovy  | 35 +++++++++
 .../src/main/resources/assemblies/pinot-plugin.xml | 54 +++++++++++++
 .../pinot-metrics/pinot-dropwizard/pom.xml         |  9 +++
 pinot-plugins/pom.xml                              | 34 +++++++++
 8 files changed, 350 insertions(+)

diff --git a/pinot-plugins/assembly-descriptor/pom.xml 
b/pinot-plugins/assembly-descriptor/pom.xml
new file mode 100644
index 0000000000..d494892405
--- /dev/null
+++ b/pinot-plugins/assembly-descriptor/pom.xml
@@ -0,0 +1,81 @@
+<?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.
+
+-->
+<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>
+    <groupId>org.apache.pinot</groupId>
+    <artifactId>pinot-plugins</artifactId>
+    <version>1.3.0-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>assembly-descriptor</artifactId>
+  <name>Pinot Plugin Assembly Descriptor</name>
+  <description>By adding this descriptor to the maven-assembly-plugin of your 
project an extra artifact will be created.
+    It will be a zip, classified with plugin, putting all classes under 
/classes/
+    and all runtime dependencies in the root of the zip
+    See also 
https://maven.apache.org/plugins/maven-assembly-plugin/examples/sharing-descriptors.html
+  </description>
+
+  <properties>
+    <pinot.root>${basedir}/../..</pinot.root>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-invoker-plugin</artifactId>
+        <version>3.8.0</version>
+        <configuration>
+          
<localRepositoryPath>${project.build.directory}/it-repo</localRepositoryPath>
+          <extraArtifacts>
+            
<artifact>org.apache.pinot:pinot-spi:${project.version}:jar</artifact>
+          </extraArtifacts>
+          <projectsDirectory>src/it/projects</projectsDirectory>
+          <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
+          <postBuildHookScript>verify</postBuildHookScript>
+          <filterProperties> <!-- for @property@ in pom.xml -->
+            
<commons-lang3.version>${commons-lang3.version}</commons-lang3.version>
+            
<version.maven-compiler-plugin>${version.maven-compiler-plugin}</version.maven-compiler-plugin>
+            
<maven.compiler.release>${maven.compiler.release}</maven.compiler.release>
+            <pinot.version>${project.version}</pinot.version>
+          </filterProperties>
+          <scriptVariables> <!-- ${property} for verify.groovy-->
+            
<commonslang3_version>${commons-lang3.version}</commonslang3_version>
+          </scriptVariables>
+        </configuration>
+        <executions>
+          <execution>
+            <id>its</id>
+            <goals>
+              <goal>install</goal>
+              <goal>integration-test</goal>
+              <goal>verify</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
\ No newline at end of file
diff --git 
a/pinot-plugins/assembly-descriptor/src/it/projects/simple-assembly/pom.xml 
b/pinot-plugins/assembly-descriptor/src/it/projects/simple-assembly/pom.xml
new file mode 100644
index 0000000000..f0dceb03a0
--- /dev/null
+++ b/pinot-plugins/assembly-descriptor/src/it/projects/simple-assembly/pom.xml
@@ -0,0 +1,88 @@
+<?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.
+
+-->
+<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>
+  <groupId>org.apache.pinot.it</groupId>
+  <artifactId>simple-assembly</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+
+  <properties>
+    <maven.compiler.release>@maven.compiler.release@</maven.compiler.release>
+  </properties>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <version>@version.maven-compiler-plugin@</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <version>3.7.1</version>
+        <dependencies>
+          <dependency>
+            <groupId>@project.groupId@</groupId>
+            <artifactId>@project.artifactId@</artifactId>
+            <version>@project.version@</version>
+          </dependency>
+        </dependencies>
+        <executions>
+          <execution>
+            <id>make-assembly</id>
+            <phase>package</phase>
+            <goals>
+              <goal>single</goal>
+            </goals>
+            <configuration>
+              <descriptorRefs>
+                <descriptorRef>pinot-plugin</descriptorRef>
+              </descriptorRefs>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-lang3</artifactId>
+      <version>@commons-lang3.version@</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.pinot</groupId>
+      <artifactId>pinot-spi</artifactId>
+      <version>@pinot.version@</version>
+      <scope>provided</scope>
+    </dependency>
+  </dependencies>
+
+</project>
\ No newline at end of file
diff --git 
a/pinot-plugins/assembly-descriptor/src/it/projects/simple-assembly/src/main/java/org/apache/pinot/it/Simple.java
 
b/pinot-plugins/assembly-descriptor/src/it/projects/simple-assembly/src/main/java/org/apache/pinot/it/Simple.java
new file mode 100644
index 0000000000..97f7b990f7
--- /dev/null
+++ 
b/pinot-plugins/assembly-descriptor/src/it/projects/simple-assembly/src/main/java/org/apache/pinot/it/Simple.java
@@ -0,0 +1,29 @@
+/**
+ * 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.pinot.it;
+
+import java.util.stream.Stream;
+import org.apache.commons.lang3.StringUtils;
+
+public class Simple {
+
+  public static void main(String[] args) {
+    Stream.of(args).map(StringUtils::upperCase).forEach(System.out::println);
+  }
+}
\ No newline at end of file
diff --git 
a/pinot-plugins/assembly-descriptor/src/it/projects/simple-assembly/src/main/resources/pinot-plugin.properties
 
b/pinot-plugins/assembly-descriptor/src/it/projects/simple-assembly/src/main/resources/pinot-plugin.properties
new file mode 100644
index 0000000000..cb282a48f3
--- /dev/null
+++ 
b/pinot-plugins/assembly-descriptor/src/it/projects/simple-assembly/src/main/resources/pinot-plugin.properties
@@ -0,0 +1,20 @@
+#
+# 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.
+#
+
+importFrom.pinot=org.apache.pinot.segment.spi
\ No newline at end of file
diff --git 
a/pinot-plugins/assembly-descriptor/src/it/projects/simple-assembly/verify.groovy
 
b/pinot-plugins/assembly-descriptor/src/it/projects/simple-assembly/verify.groovy
new file mode 100644
index 0000000000..0737682722
--- /dev/null
+++ 
b/pinot-plugins/assembly-descriptor/src/it/projects/simple-assembly/verify.groovy
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+import java.util.zip.ZipFile
+
+def expected = [
+    'pinot-plugin.properties',
+    'classes/org/apache/pinot/it/Simple.class',
+    "commons-lang3-${commonslang3_version}.jar"
+] as Set
+
+def entries = new 
File(basedir,'target/simple-assembly-0.0.1-SNAPSHOT-plugin.zip').with {
+  f ->
+    def archive = new ZipFile(f)
+    def result = archive.entries().findAll{ !it.directory }.collect { it.name 
} as Set
+    archive.close()
+    return result
+}
+
+assert entries == expected
diff --git 
a/pinot-plugins/assembly-descriptor/src/main/resources/assemblies/pinot-plugin.xml
 
b/pinot-plugins/assembly-descriptor/src/main/resources/assemblies/pinot-plugin.xml
new file mode 100644
index 0000000000..475ec64021
--- /dev/null
+++ 
b/pinot-plugins/assembly-descriptor/src/main/resources/assemblies/pinot-plugin.xml
@@ -0,0 +1,54 @@
+<?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 xmlns="http://maven.apache.org/ASSEMBLY/2.2.0";
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+          xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.2.0 
https://maven.apache.org/xsd/assembly-2.2.0.xsd";>
+  <id>plugin</id>
+  <formats>
+    <format>zip</format>
+  </formats>
+  <includeBaseDirectory>false</includeBaseDirectory>
+  <fileSets>
+    <!-- the pinot-plugin.properties is the plugin metadata file and is moved 
to the root of the zip -->
+    <fileSet>
+      <directory>${project.build.outputDirectory}</directory>
+      <excludes>
+        <exclude>pinot-plugin.properties</exclude>
+      </excludes>
+      <outputDirectory>classes</outputDirectory>
+    </fileSet>
+    <fileSet>
+      <directory>${project.build.outputDirectory}</directory>
+      <includes>
+        <include>pinot-plugin.properties</include>
+      </includes>
+      <outputDirectory>./</outputDirectory>
+    </fileSet>
+  </fileSets>
+  <dependencySets>
+    <dependencySet>
+      <useProjectArtifact>false</useProjectArtifact>
+      <scope>runtime</scope>
+      <outputDirectory>./</outputDirectory>
+    </dependencySet>
+  </dependencySets>
+</assembly>
\ No newline at end of file
diff --git a/pinot-plugins/pinot-metrics/pinot-dropwizard/pom.xml 
b/pinot-plugins/pinot-metrics/pinot-dropwizard/pom.xml
index b030d22edc..79fbffdfd2 100644
--- a/pinot-plugins/pinot-metrics/pinot-dropwizard/pom.xml
+++ b/pinot-plugins/pinot-metrics/pinot-dropwizard/pom.xml
@@ -36,6 +36,15 @@
     <shade.phase.prop>package</shade.phase.prop>
   </properties>
 
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-assembly-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
+
   <dependencies>
     <dependency>
       <groupId>io.dropwizard.metrics</groupId>
diff --git a/pinot-plugins/pom.xml b/pinot-plugins/pom.xml
index 25e1fed16c..33f10d7bd1 100644
--- a/pinot-plugins/pom.xml
+++ b/pinot-plugins/pom.xml
@@ -47,8 +47,42 @@
     <module>pinot-segment-writer</module>
     <module>pinot-segment-uploader</module>
     <module>pinot-environment</module>
+    <module>assembly-descriptor</module>
   </modules>
 
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-assembly-plugin</artifactId>
+          <version>3.7.1</version>
+          <dependencies>
+            <dependency>
+              <groupId>org.apache.pinot</groupId>
+              <artifactId>assembly-descriptor</artifactId>
+              <version>${project.version}</version>
+            </dependency>
+          </dependencies>
+          <executions>
+            <execution>
+              <id>make-assembly</id>
+              <phase>package</phase>
+              <goals>
+                <goal>single</goal>
+              </goals>
+              <configuration>
+                <descriptorRefs>
+                  <descriptorRef>pinot-plugin</descriptorRef>
+                </descriptorRefs>
+              </configuration>
+            </execution>
+          </executions>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+
   <dependencies>
     <dependency>
       <groupId>org.apache.pinot</groupId>


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to