<plugin>
<groupid>org.apache.maven.pluginsgroupid>
<artifactid>maven-shade-pluginartifactid>
<version>2.4.2version>
<configuration>
<createdependencyreducedpom>falsecreatedependencyreducedpom>
configuration>
<executions>
<execution>
<phase>packagephase>
<goals>
<goal>shadegoal>
goals>
<configuration>
<artifactset>
<includes>
<include>org.apache.activemq:activemq-mqttinclude>
includes>
artifactset>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.manifestresourcetransformer">
<mainclass>com.duxiu.demo.app.applicationktmainclass>
transformer>
transformers>
configuration>
execution>
executions>
plugin>
此配置方式将所有的依赖包的源码都解压打包进去.
如果是war包,会将整个站点解压打包进去.
同时打包过程中如果有classpath和依赖的jar包有相同的类,会将classpath里的类替换掉依赖包里的类
<plugin>
<groupid>org.apache.maven.pluginsgroupid>
<artifactid>maven-assembly-pluginartifactid>
<configuration>
<descriptorrefs>
<descriptorref>jar-with-dependenciesdescriptorref>
descriptorrefs>
<archive>
<manifest>
<mainclass>com.duxiu.demo.app.applicationktmainclass>
manifest>
archive>
configuration>
<executions>
<execution>
<phase>packagephase>
<goals>
<goal>singlegoal>
goals>
execution>
executions>
plugin>
只将依赖的jar包解压打包,对于静态文件等是不会打包的
<plugin>
<groupid>org.codehaus.mojogroupid>
<artifactid>appassembler-maven-pluginartifactid>
<version>1.10version>
<configuration>
<platforms>
<platform>windowsplatform>
<platform>unixplatform>
platforms>
<assembledirectory>${project.build.directory}/mallassembledirectory>
<repositoryname>librepositoryname>
<binfolder>binbinfolder>
<configurationdirectory>confconfigurationdirectory>
<copyconfigurationdirectory>truecopyconfigurationdirectory>
<configurationsourcedirectory>src/main/resourcesconfigurationsourcedirectory>
<repositorylayout>flatrepositorylayout>
<encoding>utf-8encoding>
<logsdirectory>logslogsdirectory>
<tempdirectory>tmptempdirectory>
<programs>
<program>
<id>mallid>
<mainclass>com.duxiu.demo.app.applicationktmainclass>
<jvmsettings>
<extraarguments>
<extraargument>-serverextraargument>
<extraargument>-xmx2gextraargument>
<extraargument>-xms2gextraargument>
extraarguments>
jvmsettings>
program>
programs>
configuration>
plugin>
打包应用程序,并会生成bat或sh可执行文件
<plugin>
<artifactid>maven-antrun-pluginartifactid>
<executions>
<execution>
<id>move-main-classid>
<phase>compilephase>
<configuration>
<tasks>
<move todir="${project.build.directory}/${project.artifactid}-${version}/com/duxiu/demo/app">
<fileset dir="${project.build.directory}/classes/com/duxiu/demo/app">
<include name="*.class" />
fileset>
move>
tasks>
configuration>
<goals>
<goal>rungoal>
goals>
execution>
executions>
plugin>
打包的时候将包里的某个文件移动到指定的位置
posted on 2016-07-20 09:42
simone 阅读(1257)
评论(0) 编辑 收藏