优化Script
This commit is contained in:
@@ -22,6 +22,8 @@
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- 保留:把依赖 jar 复制到 classes/lib -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
@@ -29,9 +31,7 @@
|
||||
<execution>
|
||||
<id>copy-dependencies</id>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<goals><goal>copy-dependencies</goal></goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/classes/lib</outputDirectory>
|
||||
<overWriteReleases>false</overWriteReleases>
|
||||
@@ -41,8 +41,37 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- 新增:打 fat jar,classes + lib + groovy 全部打入 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals><goal>shade</goal></goals>
|
||||
<configuration>
|
||||
<shadedArtifactAttached>false</shadedArtifactAttached>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<!-- 排除签名文件,避免 jar 校验失败 -->
|
||||
<exclude>META-INF/*.SF</exclude>
|
||||
<exclude>META-INF/*.DSA</exclude>
|
||||
<exclude>META-INF/*.RSA</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
<resources>
|
||||
<!-- 保留:Groovy 源文件和脚本打入 classes -->
|
||||
<resource>
|
||||
<filtering>false</filtering>
|
||||
<directory>${basedir}/src/main/groovy</directory>
|
||||
@@ -60,10 +89,10 @@
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<!-- 保留:m2e Eclipse 配置 -->
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<!--This plugin's configuration is used to store Eclipse m2e settings
|
||||
only. It has no influence on the Maven build itself. -->
|
||||
<plugin>
|
||||
<groupId>org.eclipse.m2e</groupId>
|
||||
<artifactId>lifecycle-mapping</artifactId>
|
||||
@@ -73,24 +102,12 @@
|
||||
<pluginExecutions>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>
|
||||
org.apache.maven.plugins
|
||||
</groupId>
|
||||
<artifactId>
|
||||
maven-dependency-plugin
|
||||
</artifactId>
|
||||
<versionRange>
|
||||
[2.1,)
|
||||
</versionRange>
|
||||
<goals>
|
||||
<goal>
|
||||
copy-dependencies
|
||||
</goal>
|
||||
</goals>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<versionRange>[2.1,)</versionRange>
|
||||
<goals><goal>copy-dependencies</goal></goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore></ignore>
|
||||
</action>
|
||||
<action><ignore></ignore></action>
|
||||
</pluginExecution>
|
||||
</pluginExecutions>
|
||||
</lifecycleMappingMetadata>
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
#!/bin/bash
|
||||
CLASSPATH=./
|
||||
for jar in lib/*.jar; do
|
||||
CLASSPATH="$CLASSPATH:$jar"
|
||||
done
|
||||
# lib/*.jar 换成单个 fat jar,其余不动
|
||||
CLASSPATH="./:fangjia-script.jar"
|
||||
|
||||
# 把 -Dxxx 分离出来作为 JVM 参数,其余作为 Groovy 脚本路径/参数
|
||||
JVM_OPTS=()
|
||||
GROOVY_ARGS=()
|
||||
for arg in "$@"; do
|
||||
@@ -14,4 +11,4 @@ for arg in "$@"; do
|
||||
esac
|
||||
done
|
||||
|
||||
exec java "${JVM_OPTS[@]}" -cp "$CLASSPATH" groovy.ui.GroovyMain -c GBK "${GROOVY_ARGS[@]}"
|
||||
exec java "${JVM_OPTS[@]}" -cp "$CLASSPATH" groovy.ui.GroovyMain -c GBK "${GROOVY_ARGS[@]}"
|
||||
Reference in New Issue
Block a user