This is an automated email from the ASF dual-hosted git repository.
xiangfu 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 7978d29031 Mark distribution as multi-release (#12300)
7978d29031 is described below
commit 7978d290311811a67e89853bba699cd249b21c20
Author: Gonzalo Ortiz Jaureguizar <[email protected]>
AuthorDate: Fri Jan 26 08:28:18 2024 +0100
Mark distribution as multi-release (#12300)
* Configure distribution shading to create multi-release images
* Prepare JarUtils to receive paths that end in '/'
---
pinot-distribution/pom.xml | 5 +++
.../org/apache/pinot/tools/utils/JarUtils.java | 47 +++++++++-------------
2 files changed, 24 insertions(+), 28 deletions(-)
diff --git a/pinot-distribution/pom.xml b/pinot-distribution/pom.xml
index d3170b1953..fb9caa4fc9 100644
--- a/pinot-distribution/pom.xml
+++ b/pinot-distribution/pom.xml
@@ -167,6 +167,11 @@
<transformers combine.self="override">
<transformer
implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer"/>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
+ <transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+ <manifestEntries>
+ <Multi-Release>true</Multi-Release>
+ </manifestEntries>
+ </transformer>
</transformers>
<!--
Usually in hadoop environment, there are multiple jars with
different versions.
diff --git
a/pinot-tools/src/main/java/org/apache/pinot/tools/utils/JarUtils.java
b/pinot-tools/src/main/java/org/apache/pinot/tools/utils/JarUtils.java
index b850e1a3d8..e315293e57 100644
--- a/pinot-tools/src/main/java/org/apache/pinot/tools/utils/JarUtils.java
+++ b/pinot-tools/src/main/java/org/apache/pinot/tools/utils/JarUtils.java
@@ -45,36 +45,27 @@ public class JarUtils {
if (fromJarFilePath.startsWith(FILE_PREFIX)) {
fromJarFilePath = fromJarFilePath.substring(FILE_PREFIX.length());
}
- JarFile fromJar = new JarFile(fromJarFilePath);
- for (Enumeration<JarEntry> entries = fromJar.entries();
entries.hasMoreElements(); ) {
- JarEntry entry = entries.nextElement();
- if (entry.getName().startsWith(jarDir + "/") && !entry.isDirectory()) {
- File dest = new File(destDir + "/" +
entry.getName().substring(jarDir.length() + 1));
- File parent = dest.getParentFile();
- if (parent != null) {
- parent.mkdirs();
- }
-
- FileOutputStream out = new FileOutputStream(dest);
- InputStream in = fromJar.getInputStream(entry);
+ String folderPath = jarDir.endsWith("/") ? jarDir : jarDir + "/";
+ String finalDestDir = destDir.endsWith("/") ? destDir : destDir + "/";
+ try (JarFile fromJar = new JarFile(fromJarFilePath)) {
+ for (Enumeration<JarEntry> entries = fromJar.entries();
entries.hasMoreElements(); ) {
+ JarEntry entry = entries.nextElement();
+ if (entry.getName().startsWith(folderPath) && !entry.isDirectory()) {
+ File dest = new File(finalDestDir +
entry.getName().substring(folderPath.length()));
+ File parent = dest.getParentFile();
+ if (parent != null) {
+ parent.mkdirs();
+ }
- try {
- byte[] buffer = new byte[8 * 1024];
+ try (FileOutputStream out = new FileOutputStream(dest); InputStream
in = fromJar.getInputStream(entry)) {
+ byte[] buffer = new byte[8 * 1024];
- int s = 0;
- while ((s = in.read(buffer)) > 0) {
- out.write(buffer, 0, s);
- }
- } catch (IOException e) {
- throw new IOException("Could not copy asset from jar file", e);
- } finally {
- try {
- in.close();
- } catch (IOException ignored) {
- }
- try {
- out.close();
- } catch (IOException ignored) {
+ int s = 0;
+ while ((s = in.read(buffer)) > 0) {
+ out.write(buffer, 0, s);
+ }
+ } catch (IOException e) {
+ throw new IOException("Could not copy asset from jar file", e);
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]