gortiz commented on code in PR #19448:
URL: https://github.com/apache/pinot/pull/19448#discussion_r4666361488


##########
pinot-tools/src/main/resources/appAssemblerScriptTemplate:
##########
@@ -134,16 +139,31 @@ if [ -z "$PLUGINS_CLASSPATH" ] ; then
             exit 1
         fi
         export IFS=';'
-        for PLUGIN_JAR in $PLUGINS_INCLUDE; do
-            case "$PLUGIN_JAR" in
-              pinot-kafka-2.0|pinot-kafka-3.0) PLUGIN_JAR=pinot-kafka-4.0 ;;
+        for PLUGIN_NAME in $PLUGINS_INCLUDE; do
+            unset IFS
+            case "$PLUGIN_NAME" in
+              pinot-kafka-2.0|pinot-kafka-3.0) PLUGIN_NAME=pinot-kafka-4.0 ;;
             esac
-            PLUGIN_JAR_PATH=$(find "$DIR" -path 
\*/"$PLUGIN_JAR"/"$PLUGIN_JAR"-\*.jar)
-            if [ -n "$PLUGINS_CLASSPATH" ] ; then
-              PLUGINS_CLASSPATH=$PLUGINS_CLASSPATH:$PLUGIN_JAR_PATH
-            else
-              PLUGINS_CLASSPATH=$PLUGIN_JAR_PATH
-            fi
+            for PLUGIN_JAR_PATH in $(find "$DIR" -path 
\*/"$PLUGIN_NAME"/\*.jar) ; do

Review Comment:
   Fixed in f348f6aeed. All three loops read `find -print0` now, including the 
one without a selection. While doing this I introduced a bug and caught it 
before pushing: `build-classpath` writes no final newline, so a plain `while 
read` loop dropped the last entry of every index. The loop handles that now, 
and the smoke test checks that a selected plugin gets every entry of its index.
   



##########
pinot-plugins/pom.xml:
##########
@@ -110,6 +125,60 @@
         </plugins>
       </build>
     </profile>
+    <profile>
+      <!--
+        Thin plugin layout; see the thin-plugins profile in the root pom. A 
plugin no longer bundles
+        its dependencies, so this collects them into target/plugin-libs, from 
where the
+        distribution assembly merges every plugin's into one shared 
plugin-libs/ store. It also
+        writes pinot-plugin.classpath, the list of store jars this plugin 
needs, one
+        distribution-relative path per line. The store cannot say which plugin 
needs which jar,
+        and the launcher (PLUGINS_INCLUDE) and 
LaunchSparkDataIngestionJobCommand
+        (-pluginsToLoad / -pluginsToExclude) both have to know.
+      -->
+      <id>thin-plugins</id>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-dependency-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>collect-plugin-libs</id>
+                <phase>package</phase>
+                <goals>
+                  <goal>copy-dependencies</goal>
+                </goals>
+                <configuration>
+                  <skip>${plugin.libs.skip}</skip>
+                  
<outputDirectory>${project.build.directory}/plugin-libs</outputDirectory>
+                  <!-- compile + runtime: `provided` dependencies such as 
pinot-spi are already in
+                       lib/pinot-all.jar -->
+                  <includeScope>runtime</includeScope>
+                  
<excludeGroupIds>${plugin.platform.groupIds}</excludeGroupIds>
+                  
<excludeArtifactIds>${plugin.platform.artifactIds}</excludeArtifactIds>
+                </configuration>
+              </execution>
+              <execution>
+                <id>plugin-classpath-index</id>
+                <phase>package</phase>
+                <goals>
+                  <goal>build-classpath</goal>
+                </goals>
+                <configuration>
+                  <skip>${plugin.libs.skip}</skip>
+                  
<outputFile>${project.build.directory}/pinot-plugin.classpath</outputFile>
+                  <includeScope>runtime</includeScope>
+                  
<excludeGroupIds>${plugin.platform.groupIds}</excludeGroupIds>
+                  
<excludeArtifactIds>${plugin.platform.artifactIds}</excludeArtifactIds>
+                  <prefix>plugin-libs</prefix>
+                  <pathSeparator>&#10;</pathSeparator>

Review Comment:
   Fixed in 88df65864f: `pathSeparator` and `fileSeparator` are explicit now. 
`ThinDistributionCheck` also fails on an index that contains `;` or `\`.
   



##########
pinot-distribution/pom.xml:
##########
@@ -168,6 +169,90 @@
       </build>
     </profile>
 
+    <profile>
+      <!--
+        Thin plugin layout; see the thin-plugins profile in the root pom. 
Builds the binary
+        distribution from pinot-assembly-thin.xml, which ships each plugin as 
its own jar plus a
+        pinot-plugin.classpath index into the shared plugin-libs/ store.
+
+        It also keeps plugins out of lib/pinot-all.jar. pinot-tools depends on 
plugin modules, so
+        without these exclusions the uber-jar would carry each of them a 
second time, and that copy
+        would win on the classpath over the one under plugins/. Only plugins 
pinot-tools never
+        references at compile time are excluded: it imports classes from 
pinot-avro, pinot-json,
+        pinot-parquet and pinot-minion-builtin-tasks, so those stay. A plugin 
may only be excluded
+        here if pinot-assembly-thin.xml ships it under plugins/, otherwise it 
disappears from the
+        distribution instead of moving; that is why pinot-compound-metrics 
stays.
+
+        Declaring these dependencies `provided` in pinot-tools would keep the 
list next to what it
+        describes, but `provided` is not on the runtime classpath, so 
quickstarts launched from
+        Maven or an IDE, where there is no plugins/ directory, would lose 
these plugins.
+      -->
+      <id>thin-plugins</id>
+      <properties>
+        <bin.dist.descriptor>pinot-assembly-thin.xml</bin.dist.descriptor>
+      </properties>
+      <dependencies>
+        <dependency>
+          <groupId>org.apache.pinot</groupId>
+          <artifactId>pinot-tools</artifactId>
+          <exclusions>
+            <exclusion>
+              <groupId>org.apache.pinot</groupId>
+              <artifactId>pinot-kafka-4.0</artifactId>
+            </exclusion>
+            <exclusion>
+              <groupId>org.apache.pinot</groupId>
+              <artifactId>pinot-kinesis</artifactId>
+            </exclusion>
+            <exclusion>
+              <groupId>org.apache.pinot</groupId>
+              <artifactId>pinot-pulsar</artifactId>
+            </exclusion>
+            <exclusion>
+              <groupId>org.apache.pinot</groupId>
+              <artifactId>pinot-batch-ingestion-standalone</artifactId>
+            </exclusion>
+            <exclusion>
+              <groupId>org.apache.pinot</groupId>
+              <artifactId>pinot-s3</artifactId>
+            </exclusion>
+            <exclusion>
+              <groupId>org.apache.pinot</groupId>
+              <artifactId>pinot-confluent-avro</artifactId>
+            </exclusion>
+            <exclusion>
+              <groupId>org.apache.pinot</groupId>
+              <artifactId>pinot-csv</artifactId>
+            </exclusion>
+            <exclusion>
+              <groupId>org.apache.pinot</groupId>
+              <artifactId>pinot-protobuf</artifactId>
+            </exclusion>
+            <exclusion>
+              <groupId>org.apache.pinot</groupId>
+              <artifactId>pinot-bson</artifactId>
+            </exclusion>
+            <exclusion>
+              <groupId>org.apache.pinot</groupId>
+              <artifactId>pinot-orc</artifactId>
+            </exclusion>
+            <exclusion>
+              <groupId>org.apache.pinot</groupId>
+              <artifactId>pinot-thrift</artifactId>
+            </exclusion>
+            <exclusion>
+              <groupId>org.apache.pinot</groupId>
+              <artifactId>pinot-yammer</artifactId>

Review Comment:
   Agreed. Fixed in 88df65864f: `pinot-yammer` and `pinot-dropwizard` stay in 
`pinot-all`, and they also ship under `plugins/`, as in the default layout. A 
controller starts with `PLUGINS_INCLUDE=pinot-s3` now. The description now says 
that in the thin layout a selection must name every other plugin the deployment 
uses, such as the input formats and `pinot-batch-ingestion-standalone`.
   



##########
.github/workflows/scripts/.pinot_linter.sh:
##########
@@ -31,3 +31,5 @@ mvn -B -ntp -T1C checkstyle:check || exit 1
 mvn -B -ntp -T1C spotless:check || exit 1
 mvn -B -ntp -T1C enforcer:enforce || exit 1
 mvn -B -ntp -T1C enforcer:enforce -Pdependency-verifier || exit 1
+# Plugins built with thin-plugins must not bundle the third-party jars that 
pinot-dependency-patches replaces
+mvn -B -ntp -T1C enforcer:enforce@thin-plugin-dependencies -Pthin-plugins || 
exit 1

Review Comment:
   Done in 2af2817301. The quickstart workflow has a second matrix entry, 
`thin-plugins`. It builds `-Pbin-dist,thin-plugins`, runs 
`ThinDistributionCheck` on the result, and then runs the same quickstarts. The 
check covers the layout of `plugin-libs/` and the indexes, the plugin set 
against `pinot-assembly.xml` (the parity you asked for), the legal files of the 
Pinot jars, and class linkage.
   



##########
pinot-dependency-patches/pom.xml:
##########
@@ -0,0 +1,187 @@
+<?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.
+
+-->
+<!--
+  Patched copies of third-party jars that embed their own (shaded) copy of 
Guava or Jackson, or that
+  ship code Pinot must not ship.
+
+  Each child module rebuilds exactly one third-party jar: it drops the 
embedded copy and puts the
+  version Pinot manages in its place, relocated into the same package the 
original used. The
+  third-party code is not modified, so it keeps working against its private 
namespace. Plugins
+  exclude the original artifact and depend on the patched one instead.
+
+  Before this, the only fix was the filters and relocations of the shared 
maven-shade-plugin
+  configuration in the root pom, applied when each plugin was shaded into a 
fat jar. That does not
+  happen for jars that are not shaded, such as the plugins built with the 
thin-plugins profile. The
+  patched artifacts fix the jar itself, so the result no longer depends on how 
the plugin is
+  packaged. A plugin that is still shaded gives the same result as before: the 
shared shade
+  configuration drops and relocates the patched packages exactly as it did the 
original ones.
+
+  How a child module is built. Each step uses its own phase, because the order 
of executions from
+  different plugins in one phase depends on the order in which the poms 
declare the plugins.
+  1. process-classes: default-jar writes an empty main artifact to 
target/main/.
+     maven-shade-plugin refuses to run without a main artifact. This step 
cannot run earlier: at
+     compile, Maven points the main artifact to target/classes.
+  2. generate-test-sources: maven-shade-plugin writes the patched jar to 
target/patched/.
+  3. process-test-sources: maven-antrun-plugin copies the patched jar over the 
empty main artifact,
+     and unpacks it into target/classes.
+  From step 3 on, both places that a reactor build can resolve a sibling 
module to hold the patched
+  classes. Maven 4 resolves it to the main artifact. Maven 3 resolves it to 
target/classes until
+  the module is packaged (for example in `mvn test`). A build that stops 
before step 3 (for example
+  `mvn compile`) sees no patched classes.
+
+  Each child module declares:
+  - the original artifact and the managed library as optional dependencies, so 
consumers do not get
+    them transitively;
+  - the other runtime dependencies of the original artifact, so consumers keep 
them;

Review Comment:
   The second guard is in (2af2817301): `ThinDistributionCheck` fails when a 
`pinot-patched-*` jar carries a Guava or Jackson class outside the package that 
the original relocates into. The first one, comparing the dependencies of each 
patch with the pom of the original, needs the original poms, so it fits better 
as a Maven-side check. I'd like to do it as a follow-up, and I listed it in the 
description.
   



##########
pinot-dependency-patches/pom.xml:
##########
@@ -0,0 +1,187 @@
+<?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.
+
+-->
+<!--
+  Patched copies of third-party jars that embed their own (shaded) copy of 
Guava or Jackson, or that
+  ship code Pinot must not ship.
+
+  Each child module rebuilds exactly one third-party jar: it drops the 
embedded copy and puts the
+  version Pinot manages in its place, relocated into the same package the 
original used. The
+  third-party code is not modified, so it keeps working against its private 
namespace. Plugins
+  exclude the original artifact and depend on the patched one instead.
+
+  Before this, the only fix was the filters and relocations of the shared 
maven-shade-plugin
+  configuration in the root pom, applied when each plugin was shaded into a 
fat jar. That does not
+  happen for jars that are not shaded, such as the plugins built with the 
thin-plugins profile. The
+  patched artifacts fix the jar itself, so the result no longer depends on how 
the plugin is
+  packaged. A plugin that is still shaded gives the same result as before: the 
shared shade
+  configuration drops and relocates the patched packages exactly as it did the 
original ones.
+
+  How a child module is built. Each step uses its own phase, because the order 
of executions from
+  different plugins in one phase depends on the order in which the poms 
declare the plugins.
+  1. process-classes: default-jar writes an empty main artifact to 
target/main/.
+     maven-shade-plugin refuses to run without a main artifact. This step 
cannot run earlier: at
+     compile, Maven points the main artifact to target/classes.
+  2. generate-test-sources: maven-shade-plugin writes the patched jar to 
target/patched/.
+  3. process-test-sources: maven-antrun-plugin copies the patched jar over the 
empty main artifact,
+     and unpacks it into target/classes.
+  From step 3 on, both places that a reactor build can resolve a sibling 
module to hold the patched
+  classes. Maven 4 resolves it to the main artifact. Maven 3 resolves it to 
target/classes until
+  the module is packaged (for example in `mvn test`). A build that stops 
before step 3 (for example
+  `mvn compile`) sees no patched classes.
+
+  Each child module declares:
+  - the original artifact and the managed library as optional dependencies, so 
consumers do not get
+    them transitively;
+  - the other runtime dependencies of the original artifact, so consumers keep 
them;
+  - an execution with id patch-dependency for maven-shade-plugin, with the 
artifactSet, filters and
+    relocations of the patch. filters and relocations use 
combine.self="override" to drop the
+    plugin-level configuration that the root pom applies to every module.
+-->
+<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>pinot</artifactId>
+    <groupId>org.apache.pinot</groupId>
+    <version>1.7.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>pinot-dependency-patches</artifactId>
+  <packaging>pom</packaging>
+  <name>Pinot Dependency Patches</name>
+  <url>https://pinot.apache.org/</url>
+  <properties>
+    <pinot.root>${basedir}/..</pinot.root>
+    
<patched.jar>${project.build.directory}/patched/${project.build.finalName}.jar</patched.jar>
+    
<main.jar>${project.build.directory}/main/${project.build.finalName}.jar</main.jar>
+  </properties>
+
+  <modules>
+    <module>pinot-patched-third-party-jackson-core</module>
+    <module>pinot-patched-hadoop-shaded-guava</module>
+    <module>pinot-patched-curator-client</module>
+    <module>pinot-patched-parquet-jackson</module>
+    <module>pinot-patched-pulsar-client-all</module>
+    <module>pinot-patched-reactor-netty-http</module>
+  </modules>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-jar-plugin</artifactId>
+          <executions>
+            <execution>
+              <!-- Step 1 -->
+              <id>default-jar</id>
+              <phase>process-classes</phase>
+              <configuration>
+                
<outputDirectory>${project.build.directory}/main</outputDirectory>
+                <excludes>
+                  <exclude>**</exclude>
+                </excludes>
+              </configuration>
+            </execution>
+          </executions>
+        </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-shade-plugin</artifactId>
+          <executions>
+            <execution>
+              <!-- Step 2 -->
+              <id>patch-dependency</id>
+              <phase>generate-test-sources</phase>
+              <goals>
+                <goal>shade</goal>
+              </goals>
+              <configuration>
+                <outputFile>${patched.jar}</outputFile>
+                <transformers combine.self="override">

Review Comment:
   Fixed in 46cb623cc2. Each patched jar now carries the Pinot `LICENSE` and 
`DEPENDENCIES`, and one `NOTICE` with the Pinot notice followed by the notices 
of the bundled code (`ApacheNoticeResourceTransformer`). 
`ThinDistributionCheck` checks it for every Pinot jar under `plugins/` and 
`plugin-libs/`. While at it I found that an incremental build shaded the 
previous patched jar again, because `maven-jar-plugin` kept the newer file in 
`target/main`. `forceCreation` fixes that.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to