简单项目
1. maven  netty  lomback 
 
包含项目依赖
<dependencies>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.9.Final</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.18</version>
<scope>provided</scope>
</dependency>
</dependencies>
 
2. 几个打包插件使用
 
依赖管理、依赖剔除处理、启动函数处理
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
<compilerArguments>
<extdirs>lib/</extdirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<mainClass>com.dalong.netty.MyMain</mainClass>
</manifest>
</archive>
<!--<descriptorRefs><descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>-->
<descriptors><!--描述文件路径-->
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.dalong.netty.MyMain</mainClass>
</manifest>
</archive>
<excludes>
<exclude>**/*.conf</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<excludeScope>provided</excludeScope>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>1.16.18.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>delombok</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

  

3.  assembly.xml 文件定义
 
文件别名、配置拷贝
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>mydemo</id>
<includeBaseDirectory>true</includeBaseDirectory>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>${project.basedir}\src\main\resources</directory>
<outputDirectory>conf/</outputDirectory>
</fileSet>
<fileSet>
<directory>${project.basedir}\target\lib</directory>
<outputDirectory>lib/</outputDirectory>
</fileSet>
</fileSets>
<files>
<file>
<outputDirectory>/</outputDirectory>
<source>${project.basedir}\target\websocket-server-0.0.1-SNAPSHOT.jar</source>
<destName>websocket-server.jar</destName>
</file>
</files>
</assembly>
4. 打包构建

mvn clean compile package

  

5. 参考说明
 
 

maven-assembly-plugin 打包简单案例的更多相关文章

  1. 记录一次maven打包时将test目录下的类打包到jar中,Maven Assembly Plugin的使用

    今天有人问我打包后找不到主类,运行的类写在test中.按照常规,test目录下的文件不会打包到jar包中.(但是我测试一个springboot工程就可以,这里之后再研究) 具体解决如下 第一步:在po ...

  2. maven assembly plugin使用

    使用场景 在使用maven来管理项目时,项目除了web项目,还有可能为控制台程序,一般用于开发一些后台服务的程序.最近在工作中也遇到了这种场景,使用quartz开发一个任务调度程序.程序中依赖很多ja ...

  3. 使用Maven Assembly plugin将依赖打包进jar

    一个Eclipse的工程,在pom中配置了若干依赖,需要将pom中所有的依赖全部打包进一个jar包中,可以选择的方案有maven-assembly-plugin和fatjar.以前采用fatjar进行 ...

  4. java工程打成jar包 - 使用maven assembly插件打包及手动打包

    在java工程打包的过程中遇到过不少问题,现在总结一下.一种是典型的maven工程打包,依赖的jar包全都在pom.xml中指定,这种方式打包很方便:另一种是依赖了本机jar包(不能通过pom.xml ...

  5. Maven Assembly插件介绍

    转自:http://blueram.iteye.com/blog/1684070 已经写得挺好的,就不用重写了. 你是否想要创建一个包含脚本.配置文件以及所有运行时所依赖的元素(jar)Assembl ...

  6. maven assembly 配置详解

    Maven Assembly插件介绍 博客分类: 项目构建   你是否想要创建一个包含脚本.配置文件以及所有运行时所依赖的元素(jar)Assembly插件能帮你构建一个完整的发布包. Assembl ...

  7. Maven Assembly打包提示[WARNING] transitive dependencies if any will not be available

    maven assembly打包出现错误 [WARNING] The POM for com.flink.xxr:0.0.1-SNAPSHOT is invalid, transitive depen ...

  8. Maven項目打包報錯:Plugin execution not covered by lifecycle configuration

    Maven項目打包報錯:Plugin execution not covered by lifecycle configuration 使用Eclipse导入一个新的maven项目时不时的会遇到这个错 ...

  9. 使用maven的插件进行maven项目的打包

    1 maven项目打包的插件有3种 maven-jar-plugin maven-assembly-plugin maven-shade-plugin 2 maven-jar-plugin 现在要新增 ...

随机推荐

  1. 如何高效的使用 Git

    -- 代码昨天还是运行好好的今天就不行了. 代码被删了. 突然出现了一个奇怪的 bug,但是没人知道怎么回事. 如果你出现过上面的任何一种情况,那本篇文章就是为你准备的. 除了知道 git add, ...

  2. svn diff color

    大致有两种方式: 1,在bashrc中添加如下脚本 svndiff() { svn diff "${@}" | colordiff } 2,修改svn的配置文件 $ vim ~/. ...

  3. 整合Struts2与Spring

    一.需要的JAR文件为:Spring和Struts2框架本身需要的JAR文件以及他们所依赖的JAR文件

  4. MyCat入门指南

    入门篇 1.       安装 1.1从https://github.com/MyCATApache/Mycat-download下载压缩包 1.2解压缩后复制到相应目录下面,比如/usr/local ...

  5. 【zznu-2173】

    题目链接 题目描述 春天自幼学习人间大道,斩断情缘,现已修成正果,势必要斩尽巨魔.某朝末年,战乱四起,民不聊生,魔界与人间界的封印减弱,n只巨魔趁机降临人间,祸乱百姓.n只巨魔只知扰乱人间,会有天谴降 ...

  6. hdu 6113 度度熊的01世界(结构体的赋值问题)

    题目大意: 输入n*m的字符串矩形,判断里面的图形是1还是0,还是什么都不是 注意:结构体中放赋值函数,结构体仍旧能定义的写法 #include <iostream> #include&l ...

  7. 链表实现队列C语言写法

    #include<iostream> #include<cstdio> #include<cstdlib> using namespace std; typedef ...

  8. The program environment for cypress cy8ckit-002

    customer use cypress ic to make sure the  wireless products, we are prepare to establish the environ ...

  9. Android.mk编译的写法

    更多Android.mk的 用法见 :http://blog.csdn.net/fengbingchun/article/details/38705519 如何修改Android.mk 为Androi ...

  10. 《利用Python进行数据分析》笔记---第2章--来自bit.ly的1.usa.gov数据

    写在前面的话: 实例中的所有数据都是在GitHub上下载的,打包下载即可. 地址是:http://github.com/pydata/pydata-book 还有一定要说明的: 我使用的是Python ...