使用assembly 分离依赖与配置文件
This commit is contained in:
parent
41e0508179
commit
d957021bd2
|
@ -222,37 +222,103 @@
|
|||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<excludes>
|
||||
<!-- <exclude>*.properties</exclude>-->
|
||||
</excludes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
<includes>
|
||||
<include>application.properties</include>
|
||||
<include>application-${profile.env}.properties</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<includeSystemScope>true</includeSystemScope>
|
||||
<classesDirectory>target/classes/</classesDirectory>
|
||||
<archive>
|
||||
<!--生成的jar包不包含maven描述相关文件-->
|
||||
<addMavenDescriptor>false</addMavenDescriptor>
|
||||
<manifest>
|
||||
<!--项目启动类-->
|
||||
<mainClass>io.renren.AdminApplication</mainClass>
|
||||
<useUniqueVersions>false</useUniqueVersions>
|
||||
<!--第三方JAR加入类构建的路径maven-dependency-plugin-->
|
||||
<addClasspath>true</addClasspath>
|
||||
<!--外部依赖jar包的位置-->
|
||||
<classpathPrefix>lib/</classpathPrefix>
|
||||
</manifest>
|
||||
<manifestEntries>
|
||||
<Class-Path>.</Class-Path>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!--关键插件,maven提供的assembly插件,需要放在最后-->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<skipTests>true</skipTests>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>${docker.plugin.version}</version>
|
||||
<configuration>
|
||||
<imageName>renren/${project.artifactId}</imageName>
|
||||
<dockerDirectory>${project.basedir}/</dockerDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>/</targetPath>
|
||||
<directory>${project.build.directory}</directory>
|
||||
<include>${project.build.finalName}.jar</include>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-tar.gz</id>
|
||||
<!--绑定的maven操作-->
|
||||
<phase>package</phase>
|
||||
<!--运行一次-->
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
|
||||
<!--如果不想在打包的后缀加上assembly.xml中设置的id,可以加上下面的配置-->
|
||||
<!--<appendAssemblyId>false</appendAssemblyId>-->
|
||||
|
||||
<!--指定assembly插件对应的assembly.xml配置文件-->
|
||||
<descriptors>
|
||||
<descriptor>src/main/resources/assembly/assembly.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- <plugin>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-maven-plugin</artifactId>-->
|
||||
<!-- <configuration>-->
|
||||
<!-- <includeSystemScope>true</includeSystemScope>-->
|
||||
<!-- </configuration>-->
|
||||
<!-- </plugin>-->
|
||||
<!-- <plugin>-->
|
||||
<!-- <groupId>org.apache.maven.plugins</groupId>-->
|
||||
<!-- <artifactId>maven-surefire-plugin</artifactId>-->
|
||||
<!-- <configuration>-->
|
||||
<!-- <skipTests>true</skipTests>-->
|
||||
<!-- </configuration>-->
|
||||
<!-- </plugin>-->
|
||||
<!-- <plugin>-->
|
||||
<!-- <groupId>com.spotify</groupId>-->
|
||||
<!-- <artifactId>docker-maven-plugin</artifactId>-->
|
||||
<!-- <version>${docker.plugin.version}</version>-->
|
||||
<!-- <configuration>-->
|
||||
<!-- <imageName>renren/${project.artifactId}</imageName>-->
|
||||
<!-- <dockerDirectory>${project.basedir}/</dockerDirectory>-->
|
||||
<!-- <resources>-->
|
||||
<!-- <resource>-->
|
||||
<!-- <targetPath>/</targetPath>-->
|
||||
<!-- <directory>${project.build.directory}</directory>-->
|
||||
<!-- <include>${project.build.finalName}.jar</include>-->
|
||||
<!-- </resource>-->
|
||||
<!-- </resources>-->
|
||||
<!-- </configuration>-->
|
||||
<!-- </plugin>-->
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,63 @@
|
|||
<assembly
|
||||
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
|
||||
<!--必填,会追加到打包文件名称的末尾-->
|
||||
<id>1.0</id>
|
||||
<!--打包类型,可以设置多种类型,打包的时候不同的类型都会打包打出来-->
|
||||
<formats>
|
||||
<format>tar.gz</format>
|
||||
<!--<format>zip</format>-->
|
||||
</formats>
|
||||
<!--第三方依赖设置-->
|
||||
<dependencySets>
|
||||
<dependencySet>
|
||||
<!--使用项目中的artifact,第三方包打包进tar.gz文件的lib目录下-->
|
||||
<useProjectArtifact>true</useProjectArtifact>
|
||||
<outputDirectory>lib</outputDirectory>
|
||||
</dependencySet>
|
||||
</dependencySets>
|
||||
|
||||
<!--文件相关设置-->
|
||||
<fileSets>
|
||||
<!--src/main/assembly/bin文件下的所有脚本文件输出到打包后的bin目录下-->
|
||||
<fileSet>
|
||||
<directory>src/main/resources/assembly/bin</directory>
|
||||
<outputDirectory></outputDirectory>
|
||||
<!--
|
||||
权限设置:
|
||||
0755->即用户具有读/写/执行权限,组用户和其它用户具有读写权限;
|
||||
0644->即用户具有读写权限,组用户和其它用户具有只读权限;
|
||||
-->
|
||||
<fileMode>0755</fileMode>
|
||||
<lineEnding>unix</lineEnding>
|
||||
<filtered>true</filtered>
|
||||
</fileSet>
|
||||
|
||||
<fileSet>
|
||||
<directory>${project.basedir}/lib</directory>
|
||||
<outputDirectory>lib/</outputDirectory>
|
||||
</fileSet>
|
||||
|
||||
<!-- src/main/resources/config目录下配置文件打包到config目录下 -->
|
||||
<fileSet>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>*.yml</include>
|
||||
<include>*.properties</include>
|
||||
<include>*.json</include>
|
||||
</includes>
|
||||
<filtered>true</filtered>
|
||||
<outputDirectory>${file.separator}config</outputDirectory>
|
||||
</fileSet>
|
||||
|
||||
<!-- 将target目录下的启动jar打包到目录下-->
|
||||
<fileSet>
|
||||
<directory>target</directory>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
<includes>
|
||||
<include>*.jar</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</assembly>
|
|
@ -0,0 +1,40 @@
|
|||
#! /bin/bash
|
||||
#chkconfig: 2345 85 15
|
||||
#description:auto_run
|
||||
#processname:zf
|
||||
#JAR根位置
|
||||
JAR_ROOT=`pwd`
|
||||
#JAR位置
|
||||
JAR_PATH="$JAR_ROOT"/renren-admin.jar
|
||||
|
||||
#LOG位置
|
||||
LOG_PATH=/dev/null
|
||||
|
||||
#开始方法
|
||||
start() {
|
||||
cd $JAR_ROOT
|
||||
nohup java -Dfile.encoding=utf-8 -server -Xms256m -Xmx1g -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./ -jar $JAR_PATH --server.port=8888 >$LOG_PATH 2>&1 &
|
||||
echo "$JAR_PATH start success."
|
||||
}
|
||||
|
||||
#结束方法
|
||||
stop() {
|
||||
kill -9 `ps -ef|grep $JAR_PATH|grep -v grep|grep -v stop|awk '{print $2}'`
|
||||
echo "$JAR_PATH stop success."
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
stop
|
||||
start
|
||||
;;
|
||||
*)
|
||||
echo "Userage: $0 {start|stop|restart}"
|
||||
exit 1
|
||||
esac
|
Loading…
Reference in New Issue