posts - 496,comments - 227,trackbacks - 0
<plugin>
                
<groupId>org.apache.maven.plugins</groupId>
                
<artifactId>maven-shade-plugin</artifactId>
                
<version>2.4.2</version>
                
<configuration>
                    
<createDependencyReducedPom>false</createDependencyReducedPom>
                
</configuration>
                
<executions>
                    
<execution>
                        
<phase>package</phase>
                        
<goals>
                            
<goal>shade</goal>
                        
</goals>
                        
<configuration>
                            
<artifactSet>
                                
<includes>
                                    
<include>org.apache.activemq:activemq-mqtt</include>
                                
</includes>
                            
</artifactSet>
                           
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.duxiu.demo.app.ApplicationKt</mainClass>
</transformer>
</transformers>

                        
</configuration>
                    
</execution>
                
</executions>
            
</plugin>


此配置方式将所有的依赖包的源码都解压打包进去.
如果是war包,会将整个站点解压打包进去.
同时打包过程中如果有classpath和依赖的jar包有相同的类,会将classpath里的类替换掉依赖包里的类


<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<!--<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>-->
<!--<finalName>employees-app-${project.version}</finalName>-->
<archive>
<manifest>
<mainClass>com.duxiu.demo.app.ApplicationKt</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
只将依赖的jar包解压打包,对于静态文件等是不会打包的


<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>1.10</version>
<configuration>
<!-- 生成linux, Windows两种平台的执行脚本 -->
<platforms>
<platform>windows</platform>
<platform>unix</platform>
</platforms>
<!-- 根目录 -->
<assembleDirectory>${project.build.directory}/mall</assembleDirectory>
<!-- 打包的jar,以及maven依赖的jar放到这个目录里面 -->
<repositoryName>lib</repositoryName>
<!-- 可执行脚本的目录 -->
<binFolder>bin</binFolder>
<!-- 配置文件的目标目录 -->
<configurationDirectory>conf</configurationDirectory>
<!-- 拷贝配置文件到上面的目录中 -->
<copyConfigurationDirectory>true</copyConfigurationDirectory>
<!-- 从哪里拷贝配置文件 (默认src/main/config) -->
<configurationSourceDirectory>src/main/resources</configurationSourceDirectory>
<!-- lib目录中jar的存放规则,默认是${groupId}/${artifactId}的目录格式,flat表示直接把jar放到lib目录 -->
<repositoryLayout>flat</repositoryLayout>
<encoding>UTF-8</encoding>
<logsDirectory>logs</logsDirectory>
<tempDirectory>tmp</tempDirectory>
<programs>
<program>
<id>mall</id>
<!-- 启动类 -->
<mainClass>com.duxiu.demo.app.ApplicationKt</mainClass>
<jvmSettings>
<extraArguments>
<extraArgument>-server</extraArgument>
<extraArgument>-Xmx2G</extraArgument>
<extraArgument>-Xms2G</extraArgument>
</extraArguments>
</jvmSettings>
</program>
</programs>
</configuration>
</plugin>

打包应用程序,并会生成bat或sh可执行文件



<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>move-main-class</id>
<phase>compile</phase>
<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>run</goal>
</goals>
</execution>
</executions>
</plugin>

打包的时候将包里的某个文件移动到指定的位置
posted on 2016-07-20 09:42 SIMONE 阅读(138) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: