فهرست منبع

fix: 修改打包文件

baihe 1 سال پیش
والد
کامیت
746123ec45

+ 2 - 2
component-sso/src/assembly/boot.sh → assembly/boot.sh

@@ -1,6 +1,6 @@
 #!/bin/sh
-PROCESS_NAME=gihon-sso
-MAIN_CLASS=com.gihon.component.sso.SingleSignOnApp
+PROCESS_NAME=${serviceName}
+MAIN_CLASS=${mainClass}
 cd `dirname $0`
 BIN_DIR=`pwd`
 #set -x

+ 34 - 0
assembly/component.xml

@@ -0,0 +1,34 @@
+<component>
+	<dependencySets>
+		<dependencySet>
+			<!-- 使用项目的artifact -->
+			<useProjectArtifact>true</useProjectArtifact>
+			<outputDirectory>lib</outputDirectory>
+			<unpack>false</unpack>
+			<!-- groupId:artifactId:type:classifier/groupId:artifactId -->
+			<includes>
+				<include>gihon.component:component-springboot</include>
+			</includes>
+		</dependencySet>
+	</dependencySets>
+	<fileSets>
+		<fileSet>
+			<directory>src/main/resources</directory>
+			<outputDirectory>prjConf</outputDirectory>
+			<includes>
+				<include>mapper/**</include>
+				<include>*.xml</include>
+				<include>application*.yml</include>
+			</includes>
+		</fileSet>
+		<fileSet>
+			<directory>${project.basedir}/../assembly</directory>
+			<includes>
+				<include>*.sh</include>
+			</includes>
+			<outputDirectory>bin</outputDirectory>
+			<fileMode>0777</fileMode>
+			<filtered>true</filtered><!-- 使用fileter.properties变量替换 -->
+		</fileSet>
+	</fileSets>
+</component>

+ 22 - 0
assembly/package-lib.xml

@@ -0,0 +1,22 @@
+<assembly xmlns="https://maven.apache.org/POM/4.0.0" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/assembly-1.0.0.xsd">
+	<id>package</id>
+	<formats>
+		<format>zip</format>
+	</formats>
+	<baseDirectory>${project.name}</baseDirectory>
+	<includeBaseDirectory>false</includeBaseDirectory>
+	<dependencySets>
+		<dependencySet>
+			<outputDirectory>lib</outputDirectory>
+			<unpack>false</unpack>
+			<!-- default scope runtime -->
+			<excludes>
+				<exclude>org.springframework.boot:spring-boot-devtools</exclude>
+				<exclude>org.springframework.boot:spring-boot-starter-test</exclude>
+                <!-- <exclude>io.springfox:*</exclude>
+                <exclude>com.github.xiaoymin:*</exclude> -->
+			</excludes>
+		</dependencySet>
+	</dependencySets>
+</assembly>

+ 24 - 0
assembly/package.xml

@@ -0,0 +1,24 @@
+<assembly xmlns="https://maven.apache.org/POM/4.0.0"
+	xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/assembly-1.0.0.xsd">
+	<id>package</id>
+	<formats>
+		<format>zip</format>
+	</formats>
+	<baseDirectory>${project.name}</baseDirectory>
+	<!-- ${project.build.directory} -->
+	<!-- 生成的压缩包里面有一个根目录 -->
+	<includeBaseDirectory>true</includeBaseDirectory>
+	<componentDescriptors>
+		<componentDescriptor>${project.basedir}/../assembly/component.xml</componentDescriptor>
+	</componentDescriptors>
+	<containerDescriptorHandlers>
+	   <containerDescriptorHandler>
+	       <handlerName>metaInf-services</handlerName>  
+	   </containerDescriptorHandler>
+	   <containerDescriptorHandler>
+	        <handlerName>metaInf-spring</handlerName>
+	   </containerDescriptorHandler>
+	</containerDescriptorHandlers>
+	
+</assembly>

+ 3 - 0
assembly/start.sh

@@ -0,0 +1,3 @@
+#!/bin/sh
+cd `dirname $0`
+sh boot.sh start ${serviceName} ${mainClass} &

+ 3 - 0
assembly/stop.sh

@@ -0,0 +1,3 @@
+#!/bin/sh
+cd `dirname $0`
+sh boot.sh stop ${serviceName} &

+ 6 - 1
component-springboot/pom.xml

@@ -72,6 +72,11 @@
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-assembly-plugin</artifactId>
                 <version>3.4.2</version>
+                <configuration>
+                    <filters>
+                        <filter>${assembly.filter.path}</filter>
+                    </filters>
+                </configuration>
                 <executions>
                     <execution>
                         <id>make-assembly</id>
@@ -84,7 +89,7 @@
                             <skipAssembly>false</skipAssembly>
                             <appendAssemblyId>false</appendAssemblyId>
                             <descriptors>
-                                <descriptor>src/assembly/package.xml</descriptor>
+                                <descriptor>${assembly.path}/package.xml</descriptor>
                             </descriptors>
                         </configuration>
                     </execution>

+ 0 - 141
component-springboot/src/assembly/boot.sh

@@ -1,141 +0,0 @@
-#!/bin/sh
-PROCESS_NAME=gihon-rbac
-MAIN_CLASS=com.gihon.component.GihonRbacApplication
-cd `dirname $0`
-BIN_DIR=`pwd`
-#set -x
-#set -e
-PROCESS_HOME=`dirname $BIN_DIR`
-LOG_PATH=$PROCESS_HOME/log
-
-if [ -n "$2" ];then
-  PROCESS_NAME=$2;
-fi
-if [ -n "$3" ];then
-  MAIN_CLASS=$3;
-fi
-if [ -z "$JAVA_HOME" ];then
-  echo "JAVA_HOME NOT SET"
-  exit -1
-fi
-
-LIB_DIR=`dirname $PROCESS_HOME`/lib
-JARS="$PROCESS_HOME/prjConf:$PROCESS_HOME/lib/*:"
-
-JARS="$JARS$LIB_DIR/*"
-# only *; *.jar is not support
-#if [ -d $LIB ]; then
-#  for i in $LIB/*.jar; do
-#    JARS="$JARS":$i
-#  done
-#fi
-
-export JARS
-
-if [ ! -d "$BIN_DIR/process/" ];then
-  mkdir $BIN_DIR/process
-fi
-if [ ! -d "$PROCESS_HOME/log/" ];then
-  mkdir $PROCESS_HOME/log
-  touch $PROCESS_HOME/log/console.log
-fi
-
-JAVA_OPTS="-Dprogram.name=$PROCESS_NAME -DPROCESS_HOME=$PROCESS_HOME -Dlog.path=$LOG_PATH -Xms256M -Xmx1G -Duser.timezone=GMT+8 -Dfile.encoding=UTF-8"
-JAVA_OPTS="$JAVA_OPTS -Xloggc:$BIN_DIR/process/gc.vgc -XX:+PrintGCDateStamps"
-
-#进程ID
-jpsid=0
-
-#检测进程
-checkpid(){
-  javaps=`jps -lmv|grep $PROCESS_NAME|awk '{print $1}'`
-  if [ -n "$javaps" ];then
-    jpsid=$javaps
-  else
-    jpsid=0
-  fi
-}
-#启动
-start(){
-  checkpid
-  if [ $jpsid -ne 0 ]; then
-    echo "================================"
-    echo "warn: $PROCESS_NAME already started! (pid=$psid)"
-    echo "================================"
-  else
-    echo -n "Starting $PROCESS_NAME ..."
-    nohup java -server $JAVA_OPTS  -cp $JARS $MAIN_CLASS > $PROCESS_HOME/log/console.log 2>&1 &
-    sleep 2
-    checkpid
-    if [ $jpsid -ne 0 ]; then
-  	  echo "(pid=$jpsid) [OK]"
-    else
-  	  echo "[Failed]"
-    fi
-  fi
-}
-#停止
-stop() {
-  checkpid
-  if [ $jpsid -ne 0 ]; then
-    echo -n "Stopping $PROCESS_NAME ...(pid=$jpsid) "
-    kill $1 $jpsid
-    if [ $? -eq 0 ]; then
-  	  echo "[OK]"
-    else
-  	  echo "[Failed]"
-    fi 
-    sleep 2
-    checkpid
-    if [ $jpsid -ne 0 ]; then
-  	  stop -9
-    fi
-  else
-    echo "================================"
-    echo "warn: $PROCESS_NAME is not running"
-    echo "================================"
-  fi
-}
-#状态
-status() {
-  checkpid
- 
-  if [ $jpsid -ne 0 ];  then
-    echo "$PROCESS_NAME is running! (pid=$jpsid)"
-    tail $PROCESS_HOME/log/gihon.log
-  else
-    echo "$PROCESS_NAME is not running"
-  fi
-}
-#帮助信息
-info() {
-  echo "************************************************************************"
-  echo "JAVA_HOME=$JAVA_HOME"
-  echo `java -version`
-  echo "gihon service v1.0.0"
-  echo "usage: ./boot.sh <command>"
-  echo "command = < start|stop|info|restart|status|help >"
-  echo "start: start service '$2' and MainClass '$3' in current shell, and in background if succeded with &."
-  echo "the program should be execute with root privelage."
-  echo "***************************************************************************"
-}
-
-
-case "$1" in
-  'start')
-    start
-  ;;
-  'stop')
-    stop
-  ;;
-  'status')
-    status
-  ;;
-  'restart')
-    stop
-    start
-  ;;				
-  *)
-    info
-  ;;
-esac

+ 2 - 0
component-springboot/src/assembly/filter.properties

@@ -0,0 +1,2 @@
+mainClass=com.gihon.component.GihonRbacApplication
+serviceName=gihon-rbac

+ 0 - 39
component-springboot/src/assembly/package.xml

@@ -1,39 +0,0 @@
-<assembly xmlns="https://maven.apache.org/POM/4.0.0" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
-	xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/assembly-1.0.0.xsd">
-	<id>package</id>
-	<formats>
-		<format>zip</format>
-	</formats>
-	<baseDirectory>${project.name}</baseDirectory>
-	<includeBaseDirectory>true</includeBaseDirectory>
-	<dependencySets>
-		<dependencySet>
-			<outputDirectory>lib</outputDirectory>
-			<unpack>false</unpack>
-			<includes>
-				<include>gihon.component:component-springboot</include>
-			</includes>
-		</dependencySet>
-	</dependencySets>
-	
-	<fileSets>
-		<fileSet>
-            <directory>src/main/resources</directory>
-            <outputDirectory>prjConf</outputDirectory>
-            <includes>
-                <include>mapper/**</include>
-                <include>*.xml</include>
-                <include>application*.yml</include>
-            </includes>
-        </fileSet>
-        <fileSet>
-            <directory>src/assembly</directory>
-            <includes>
-                <include>*.sh</include>
-            </includes>
-            <outputDirectory>bin</outputDirectory>
-            <fileMode>0777</fileMode>
-        </fileSet>
-	</fileSets>
-	
-</assembly>

+ 0 - 3
component-springboot/src/assembly/start.sh

@@ -1,3 +0,0 @@
-#!/bin/sh
-cd `dirname $0`
-sh boot.sh start gihon-rbac com.gihon.component.GihonRbacApplication &

+ 0 - 3
component-springboot/src/assembly/stop.sh

@@ -1,3 +0,0 @@
-#!/bin/sh
-cd `dirname $0`
-sh boot.sh stop gihon-rbac &

+ 6 - 1
component-sso/pom.xml

@@ -35,6 +35,11 @@
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-assembly-plugin</artifactId>
                 <version>3.4.2</version>
+                <configuration>
+                    <filters>
+                        <filter>${assembly.filter.path}</filter>
+                    </filters>
+                </configuration>
                 <executions>
                     <execution>
                         <id>make-assembly</id>
@@ -47,7 +52,7 @@
                             <skipAssembly>false</skipAssembly>
                             <appendAssemblyId>false</appendAssemblyId>
                             <descriptors>
-                                <descriptor>src/assembly/package.xml</descriptor>
+                                <descriptor>${assembly.path}/package.xml</descriptor>
                             </descriptors>
                         </configuration>
                     </execution>

+ 2 - 0
component-sso/src/assembly/filter.properties

@@ -0,0 +1,2 @@
+mainClass=com.gihon.component.sso.SingleSignOnApp
+serviceName=gihon-sso

+ 0 - 39
component-sso/src/assembly/package.xml

@@ -1,39 +0,0 @@
-<assembly xmlns="https://maven.apache.org/POM/4.0.0" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
-	xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/assembly-1.0.0.xsd">
-	<id>package</id>
-	<formats>
-		<format>zip</format>
-	</formats>
-	<baseDirectory>${project.name}</baseDirectory>
-	<includeBaseDirectory>true</includeBaseDirectory>
-	<dependencySets>
-		<dependencySet>
-			<outputDirectory>lib</outputDirectory>
-			<unpack>false</unpack>
-			<includes>
-				<include>gihon.component:component-springboot</include>
-			</includes>
-		</dependencySet>
-	</dependencySets>
-	
-	<fileSets>
-		<fileSet>
-            <directory>src/main/resources</directory>
-            <outputDirectory>prjConf</outputDirectory>
-            <includes>
-                <include>mapper/**</include>
-                <include>*.xml</include>
-                <include>application*.yml</include>
-            </includes>
-        </fileSet>
-        <fileSet>
-            <directory>src/assembly</directory>
-            <includes>
-                <include>*.sh</include>
-            </includes>
-            <outputDirectory>bin</outputDirectory>
-            <fileMode>0777</fileMode>
-        </fileSet>
-	</fileSets>
-	
-</assembly>

+ 0 - 3
component-sso/src/assembly/start.sh

@@ -1,3 +0,0 @@
-#!/bin/sh
-cd `dirname $0`
-sh boot.sh start gihon-sso com.gihon.component.sso.SingleSignOnApp &

+ 0 - 3
component-sso/src/assembly/stop.sh

@@ -1,3 +0,0 @@
-#!/bin/sh
-cd `dirname $0`
-sh boot.sh stop gihon-sso &

+ 1 - 1
component-websecurity/pom.xml

@@ -51,7 +51,7 @@
                             <skipAssembly>false</skipAssembly>
                             <appendAssemblyId>false</appendAssemblyId>
                             <descriptors>
-                                <descriptor>src/assembly/package-lib.xml</descriptor>
+                                <descriptor>${assembly.path}package-lib.xml</descriptor>
                             </descriptors>
                         </configuration>
                     </execution>

+ 1 - 3
component-websecurity/src/assembly/package-lib.xml

@@ -10,12 +10,10 @@
 		<dependencySet>
 			<outputDirectory>lib</outputDirectory>
 			<unpack>false</unpack>
+			<!-- default scope runtime -->
 			<excludes>
 				<exclude>org.springframework.boot:spring-boot-devtools</exclude>
 				<exclude>org.springframework.boot:spring-boot-starter-test</exclude>
-                <exclude>org.junit.jupiter:*</exclude>
-                <exclude>org.junit.platform:*</exclude>
-                <exclude>org.mockito:*</exclude>
                 <!-- <exclude>io.springfox:*</exclude>
                 <exclude>com.github.xiaoymin:*</exclude> -->
 			</excludes>

+ 1 - 0
component-websecurity/src/main/java/com/gihon/component/web/config/CommonWebConfig.java

@@ -26,6 +26,7 @@ import org.apache.http.ssl.TrustStrategy;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
 import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
+import org.springframework.boot.jackson.JsonComponent;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Primary;

+ 2 - 0
pom.xml

@@ -18,6 +18,8 @@
 	</modules>
 	
 	<properties>
+	    <assembly.path>${project.basedir}/../assembly/</assembly.path>
+	    <assembly.filter.path>src/assembly/filter.properties</assembly.filter.path>
         <gihon.version>0.2.0-SNAPSHOT</gihon.version>
 		<java.version>1.8</java.version>
 		<maven.compiler.source>8</maven.compiler.source>