Skip to content

Commit

Permalink
feat: 增加插件通用lib目录,增加maven构建时移除jar文件的功能
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmXu committed Nov 3, 2023
1 parent 9e14994 commit 746c65a
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 31 deletions.
22 changes: 22 additions & 0 deletions script/clean_duplicated_jar.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

echo 'Remove duplicated jar files...'

# 获取第一个目录下的所有文件
dir1=$1
array1=($(find $dir1 -type f))

# 获取第二个目录下的所有文件
dir2=$2
array2=($(find $dir2 -type f))

# 遍历两个数组,检查是否存在重复的文件
for file in "${array1[@]}"; do
for otherfile in "${array2[@]}"; do
if [[ $(basename "$file") == $(basename "$otherfile") ]]; then
# 删除重复的文件
rm -f "$otherfile"
break;
fi
done
done
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ fi

LOG_FILES=${LOGS_DIR}/shenyu-bootstrap.log
EXT_LIB=${DEPLOY_DIR}/ext-lib
PLUGIN_LIB=${DEPLOY_DIR}/plugins/lib

CLASS_PATH=.:${DEPLOY_DIR}/conf:${DEPLOY_DIR}/lib/*:${EXT_LIB}/*
CLASS_PATH=.:${DEPLOY_DIR}/conf:${DEPLOY_DIR}/lib/*:${EXT_LIB}/*:${PLUGIN_LIB}/*
if [ -z "${BOOT_JVM}" ]; then
JAVA_OPTS=" -server -Xmx4g -Xms4g -Xmn1g -Xss512k -XX:+DisableExplicitGC -XX:LargePageSizeInBytes=128m"
version=`java -version 2>&1 | sed '1!d' | sed -e 's/"//g' | awk '{print $3}'`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,37 @@
<module>shenyu-spring-boot-starter-isolation-plugin-sofa</module>
<module>shenyu-spring-boot-starter-isolation-plugin-motan</module>
</modules>

<dependencies>
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-plugin-base</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${main.basedir}/plugins/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<copyPom>false</copyPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,6 @@
<goal>copy-dependencies</goal>
</goals>
<configuration>
<excludeArtifactIds>
shenyu-common,
shenyu-class-isolation,
shenyu-plugin-base,
shenyu-plugin-api,
shenyu-spi,
shenyu-sync-data-api,
commons-lang3,
gson
</excludeArtifactIds>
<excludeGroupIds>
org.slf4j,
org.springframework,
io.projectreactor
</excludeGroupIds>
<outputDirectory>${main.basedir}/plugins/motan</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
Expand All @@ -63,6 +48,26 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>sh</executable>
<arguments>
<argument>-c</argument>
<argument>${main.basedir}/script/clean_duplicated_jar.sh ${main.basedir}/plugins/lib ${main.basedir}/plugins/motan</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,6 @@
<goal>copy-dependencies</goal>
</goals>
<configuration>
<excludeArtifactIds>
shenyu-common,
shenyu-class-isolation,
shenyu-plugin-base,
shenyu-plugin-api,
shenyu-spi,
shenyu-sync-data-api,
gson
</excludeArtifactIds>
<excludeGroupIds>
org.slf4j,
org.springframework,
io.projectreactor,
</excludeGroupIds>
<outputDirectory>${main.basedir}/plugins/sofa</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
Expand All @@ -85,6 +71,26 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>sh</executable>
<arguments>
<argument>-c</argument>
<argument>${main.basedir}/script/clean_duplicated_jar.sh ${main.basedir}/plugins/lib ${main.basedir}/plugins/sofa</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
# limitations under the License.
#

provides: shenyu-spring-boot-starter-plugin-sofa
provides: shenyu-spring-boot-starter-isolation-plugin-sofa

0 comments on commit 746c65a

Please sign in to comment.