120秒心动解锁非会员的专属试看

核心内容摘要

川蜀秘境:解锁“四川BBB操”的绝世武功与舌尖魔力
探寻“辶喿扌畐”的奥秘:一场跨越时空的文化对话

17c起草口:穿越时光的低语,品味百年风华

打包是一个比较头疼的事情默认maven打包的结果只包含项目本身的代码如果要执行代码还得带上依赖。

如果希望将所有依赖放到指定的文件夹下再在目录下写入shell脚本等之类的事情。

maven-shade-plugin插件不能满足需求而maven-assembly-plugin插件能够帮我们合理地归档文件。

简单的使用assembly提供了几种默认的打包方式使用 descriptorRefs descriptorRef 有 bin, jar-with-dependencies, src, project。

【不建议使用】代码语言javascriptAI代码解释plugins plugin !-- NOTE: We dont need a groupId specification because the group is org.apache.maven.plugins ...which is assumed by default. -- artifactIdmaven-assembly-plugin/artifactId version

3.

0/version configuration descriptorRefs descriptorRefjar-with-dependencies/descriptorRef /descriptorRefs /configuration /plugindescriptor使用原理assembly允许用户自定义归档文件格式位置结构等信息。

允许配置并执行多个自定义配置。

所以每一个配置都需要一个唯一id来做区分。

归档格式可以有tar.gz,dir,zip,war等等允许同时归档出多种格式文件。

对于打的jar包可以指定输出目录。

对于一组特定的文件可以指定存放的文件夹。

如果有单独需要存放的文件也可以单独处理。

assembly配置assembly配置分为两部分一部分是assembly的配置文件一部分是在pom.xml中的配置。

assembly配置文件首先我们通过以下配置文件了解一下配置文件是怎么工作的。

代码语言javascriptAI代码解释assembly xmlnshttp://maven.apache.org/ASSEMBLY/

2.

0 xmlns:xsihttp://www.w

org/2001/XMLSchema-instance xsi:schemaLocationhttp://maven.apache.org/ASSEMBLY/

2.

0 http://maven.apache.org/xsd/assembly-

2.

0.

xsd http://maven.apache.org/ASSEMBLY/

2.

0 !--唯一ID-- idassembly_test/id !--打包格式允许同时有多个-- formats formattar.gz/format formatdir/format formatzip/format /formats !--依赖jar包以及项目打包文件存储文件-- dependencySets dependencySet !--存储在projectName-assembly-version/lib下-- outputDirectorylib/outputDirectory /dependencySet /dependencySets fileSets fileSet !--目录路径如果不在这里指定而在include中指定那么其文件夹的也会被带进去-- directorysrc/main/bin//directory includes !--要哪些文件-- include*.*/include /includes excludes !--不要哪些文件-- exclude*.no_need/exclude /excludes !--文件的权限-- fileMode0755/fileMode !--输出目录 存储在projectName-assembly-version/bin下-- outputDirectorybin/outputDirectory directoryMode0755/directoryMode /fileSet /fileSets files !--针对单个文件-- file !--源文件地址相对于项目地址-- sourcepom.xml/source !--输出目录为projectName-assembly-version/-- outputDirectory./outputDirectory !--文件的权限-- fileMode0755/fileMode !--重命名为-- destNamepom.xml/destName /file /files /assemblypom中的配置assembly插件在pom中配置较为简单但需要配置maven自带的插件实现main方法添加和classpath依赖。

假设上边的assembly配置文件在src/main/assembly/assembly.xmlpom配置内容为代码语言javascriptAI代码解释build plugins plugin groupIdorg.apache.maven.plugins/groupId artifactIdmaven-jar-plugin/artifactId version

2.

1/version configuration archive manifest !--运行jar包时运行的主类要求类全名-- mainClasscom.gavinzh.learn.assembly.Main/mainClass !-- 是否指定项目classpath下的依赖 -- addClasspathtrue/addClasspath !-- 指定依赖的时候声明前缀 -- !--classpathPrefix.//classpathPrefix-- /manifest /archive /configuration /plugin plugin !-- NOTE: We dont need a groupId specification because the group is org.apache.maven.plugins ...which is assumed by default. -- artifactIdmaven-assembly-plugin/artifactId version

3.

0/version configuration descriptors descriptorsrc/main/assembly/assembly.xml/descriptor /descriptors /configuration executions execution idassembly_test/id phasepackage/phase goals goalsingle/goal /goals /execution /executions /plugin /plugins /build参考Apache Maven Assembly Pluginhttps://www.jianshu.com/p/14bcb17b99e0

http://www.crm.17.cn-http://www.crm.17.cn最新版N.12.91.54-2265安卓网应用

百度百家号客服电话人工服务

123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123