From 6676e207ee7cce79ccd20d26b9a16c2ab3c545f3 Mon Sep 17 00:00:00 2001 From: jarvis Date: Fri, 12 Jul 2024 10:46:30 +0800 Subject: [PATCH] [Feature] split transform lib to a special folder --- .../seatunnel/common/config/Common.java | 25 ++++++++++++-- .../src/main/assembly/assembly-bin-ci.xml | 33 +++++++++---------- .../src/main/assembly/assembly-bin.xml | 13 +++++++- .../SeaTunnelTransformPluginDiscovery.java | 2 +- 4 files changed, 50 insertions(+), 23 deletions(-) diff --git a/seatunnel-common/src/main/java/org/apache/seatunnel/common/config/Common.java b/seatunnel-common/src/main/java/org/apache/seatunnel/common/config/Common.java index 95928d1e4ccd..059340a33400 100644 --- a/seatunnel-common/src/main/java/org/apache/seatunnel/common/config/Common.java +++ b/seatunnel-common/src/main/java/org/apache/seatunnel/common/config/Common.java @@ -139,19 +139,38 @@ public static Path libDir() { return Paths.get(getSeaTunnelHome(), "lib"); } + /** transform Dir */ + public static Path transformsDir() { + return Paths.get(getSeaTunnelHome(), "transforms"); + } + /** return lib jars, which located in 'lib/*' or 'lib/{dir}/*'. */ public static List getLibJars() { Path libRootDir = Common.libDir(); + Path transformsRootDir = Common.transformsDir(); if (!Files.exists(libRootDir) || !Files.isDirectory(libRootDir)) { return Collections.emptyList(); } + List libPaths; try (Stream stream = Files.walk(libRootDir, APP_LIB_DIR_DEPTH, FOLLOW_LINKS)) { - return stream.filter(it -> !it.toFile().isDirectory()) - .filter(it -> it.getFileName().toString().endsWith(".jar")) - .collect(Collectors.toList()); + libPaths = + stream.filter(it -> !it.toFile().isDirectory()) + .filter(it -> it.getFileName().toString().endsWith(".jar")) + .collect(Collectors.toList()); + } catch (IOException e) { + throw new RuntimeException(e); + } + List transformPaths; + try (Stream stream = Files.walk(transformsRootDir, APP_LIB_DIR_DEPTH, FOLLOW_LINKS)) { + transformPaths = + stream.filter(it -> !it.toFile().isDirectory()) + .filter(it -> it.getFileName().toString().endsWith(".jar")) + .collect(Collectors.toList()); } catch (IOException e) { throw new RuntimeException(e); } + libPaths.addAll(transformPaths); + return libPaths; } /** return the jar package configured in env jars */ diff --git a/seatunnel-dist/src/main/assembly/assembly-bin-ci.xml b/seatunnel-dist/src/main/assembly/assembly-bin-ci.xml index cc48ac86a2cd..d970e0d0ba3d 100644 --- a/seatunnel-dist/src/main/assembly/assembly-bin-ci.xml +++ b/seatunnel-dist/src/main/assembly/assembly-bin-ci.xml @@ -167,25 +167,8 @@ false org.apache.seatunnel:seatunnel-transforms-v2:jar - org.apache.hadoop:hadoop-aws:jar - com.amazonaws:aws-java-sdk-bundle:jar - org.apache.seatunnel:seatunnel-hadoop3-3.1.4-uber:jar:*:optional - - org.apache.hadoop:hadoop-aliyun:jar - com.aliyun.oss:aliyun-sdk-oss:jar - org.jdom:jdom:jar - - - io.netty:netty-buffer:jar - io.netty:netty-common:jar - - - org.apache.hive:hive-exec:jar - org.apache.hive:hive-service:jar - org.apache.thrift:libfb303:jar - ${artifact.file.name} - /lib + /transforms provided @@ -209,6 +192,20 @@ com.amazon.redshift:redshift-jdbc42:jar net.snowflake.snowflake-jdbc:jar com.xugudb:xugu-jdbc:jar + org.apache.hadoop:hadoop-aws:jar + com.amazonaws:aws-java-sdk-bundle:jar + org.apache.seatunnel:seatunnel-hadoop3-3.1.4-uber:jar:*:optional + + org.apache.hadoop:hadoop-aliyun:jar + com.aliyun.oss:aliyun-sdk-oss:jar + org.jdom:jdom:jar + + io.netty:netty-buffer:jar + io.netty:netty-common:jar + + org.apache.hive:hive-exec:jar + org.apache.hive:hive-service:jar + org.apache.thrift:libfb303:jar ${artifact.file.name} /lib diff --git a/seatunnel-dist/src/main/assembly/assembly-bin.xml b/seatunnel-dist/src/main/assembly/assembly-bin.xml index 30fc5a6336a0..15ffc4f05252 100644 --- a/seatunnel-dist/src/main/assembly/assembly-bin.xml +++ b/seatunnel-dist/src/main/assembly/assembly-bin.xml @@ -161,13 +161,24 @@ provided - + false true false org.apache.seatunnel:seatunnel-transforms-v2:jar + + /transforms + provided + + + + + false + true + false + org.apache.seatunnel:seatunnel-hadoop3-3.1.4-uber:jar:*:optional ${artifact.file.name} diff --git a/seatunnel-plugin-discovery/src/main/java/org/apache/seatunnel/plugin/discovery/seatunnel/SeaTunnelTransformPluginDiscovery.java b/seatunnel-plugin-discovery/src/main/java/org/apache/seatunnel/plugin/discovery/seatunnel/SeaTunnelTransformPluginDiscovery.java index 445bf14628d1..8438717f8948 100644 --- a/seatunnel-plugin-discovery/src/main/java/org/apache/seatunnel/plugin/discovery/seatunnel/SeaTunnelTransformPluginDiscovery.java +++ b/seatunnel-plugin-discovery/src/main/java/org/apache/seatunnel/plugin/discovery/seatunnel/SeaTunnelTransformPluginDiscovery.java @@ -34,7 +34,7 @@ public class SeaTunnelTransformPluginDiscovery extends AbstractPluginDiscovery { public SeaTunnelTransformPluginDiscovery() { - super(Common.libDir()); + super(Common.transformsDir()); } @Override