背景
有一个项目不是web项目,不能使用 war
插件. 需要把所有依赖的 jar
包下载到lib目录,然后通过 cli
的方式启动执行 . 类试于 arthas
的启动方式.
详情
Maven添加 plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<descriptors>
<descriptor>src/assembly/distribution.xml</descriptor>
</descriptors>
<outputDirectory>
${project.build.directory}
</outputDirectory>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>create-distribution</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
指定打包方式
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>test-agent-assembly</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${basedir}/src/main/resources</directory>
<outputDirectory>./</outputDirectory>
</fileSet>
</fileSets>
<dependencySets>
<!--核心依赖jar包,打包到core目录下-->
<dependencySet>
<includes>
<include>top.mybatis.code:generator</include>
</includes>
<outputDirectory>lib</outputDirectory>
<useProjectArtifact>false</useProjectArtifact>
<useTransitiveFiltering>true</useTransitiveFiltering>
</dependencySet>
<!--公共lib目录-->
</dependencySets>
</assembly>
实际结果
Maven Deploy 命令行
Deploy jar包
mvn deploy:deploy-file -DgroupId=com.qumoon -DartifactId=qumoon-job-queue -Dversion=1.0-SNAPSHOT -Dpackaging=jar -Dfile=qumoon-job-queue-1.0-SNAPSHOT.jar -Durl=http://xxx.xxx.xxx:8082/repository/maven-snapshots/ -DrepositoryId=xxxxxx
Deploy jar包带pom文件
mvn deploy:deploy-file -DgroupId=com.qumoon -DartifactId=qumoon-job-queue -Dversion=1.0-SNAPSHOT -Dpackaging=jar -Dfile=qumoon-job-queue-1.0-SNAPSHOT.jar -Durl=http://xxx.xxx.xxx:8082/repository/maven-snapshots/ -DrepositoryId=xxxxxx -DpomFile=qumoon-job-queue-1.0-SNAPSHOT.pom
Deploy pom文件
mvn deploy:deploy-file -DgroupId=com.xxxx.express -DartifactId=quicloud-express-taobao-api-gateway-parent -Dversion=1.0-SNAPSHOT -Dpackaging=pom -Durl=http://xxxx.xxx.xxxx:8082/repository/maven-snapshots/ -DrepositoryId=xxxxx -Dfile=quicloud-express-taobao-api-gateway-parent-1.0-SNAPSHOT.pom