简单项目
1. maven  netty  lomback 
 
包含项目依赖
  1. <dependencies>
  2. <dependency>
  3. <groupId>io.netty</groupId>
  4. <artifactId>netty-all</artifactId>
  5. <version>4.1.9.Final</version>
  6. </dependency>
  7. <dependency>
  8. <groupId>org.projectlombok</groupId>
  9. <artifactId>lombok</artifactId>
  10. <version>1.16.18</version>
  11. <scope>provided</scope>
  12. </dependency>
  13. </dependencies>
 
2. 几个打包插件使用
 
依赖管理、依赖剔除处理、启动函数处理
  1. <build>
  2. <plugins>
  3. <plugin>
  4. <artifactId>maven-compiler-plugin</artifactId>
  5. <configuration>
  6. <source>1.6</source>
  7. <target>1.6</target>
  8. <encoding>UTF-8</encoding>
  9. <compilerArguments>
  10. <extdirs>lib/</extdirs>
  11. </compilerArguments>
  12. </configuration>
  13. </plugin>
  14. <plugin>
  15. <artifactId>maven-assembly-plugin</artifactId>
  16. <executions>
  17. <execution>
  18. <id>make-assembly</id>
  19. <phase>package</phase>
  20. <goals>
  21. <goal>single</goal>
  22. </goals>
  23. </execution>
  24. </executions>
  25. <configuration>
  26. <archive>
  27. <manifest>
  28. <mainClass>com.dalong.netty.MyMain</mainClass>
  29. </manifest>
  30. </archive>
  31. <!--<descriptorRefs><descriptorRef>jar-with-dependencies</descriptorRef>
  32. </descriptorRefs>-->
  33. <descriptors><!--描述文件路径-->
  34. <descriptor>src/main/assembly/assembly.xml</descriptor>
  35. </descriptors>
  36. </configuration>
  37. </plugin>
  38. <plugin>
  39. <groupId>org.apache.maven.plugins</groupId>
  40. <artifactId>maven-jar-plugin</artifactId>
  41. <configuration>
  42. <archive>
  43. <manifest>
  44. <addClasspath>true</addClasspath>
  45. <classpathPrefix>lib/</classpathPrefix>
  46. <mainClass>com.dalong.netty.MyMain</mainClass>
  47. </manifest>
  48. </archive>
  49. <excludes>
  50. <exclude>**/*.conf</exclude>
  51. </excludes>
  52. </configuration>
  53. </plugin>
  54. <plugin>
  55. <groupId>org.apache.maven.plugins</groupId>
  56. <artifactId>maven-dependency-plugin</artifactId>
  57. <executions>
  58. <execution>
  59. <id>copy-dependencies</id>
  60. <phase>prepare-package</phase>
  61. <goals>
  62. <goal>copy-dependencies</goal>
  63. </goals>
  64. <configuration>
  65. <outputDirectory>${project.build.directory}/lib</outputDirectory>
  66. <overWriteReleases>false</overWriteReleases>
  67. <overWriteSnapshots>false</overWriteSnapshots>
  68. <overWriteIfNewer>true</overWriteIfNewer>
  69. <excludeScope>provided</excludeScope>
  70. </configuration>
  71. </execution>
  72. </executions>
  73. </plugin>
  74. <plugin>
  75. <groupId>org.projectlombok</groupId>
  76. <artifactId>lombok-maven-plugin</artifactId>
  77. <version>1.16.18.0</version>
  78. <executions>
  79. <execution>
  80. <phase>generate-sources</phase>
  81. <goals>
  82. <goal>delombok</goal>
  83. </goals>
  84. </execution>
  85. </executions>
  86. </plugin>
  87. </plugins>
  88. </build>

  

3.  assembly.xml 文件定义
 
文件别名、配置拷贝
  1. <assembly
  2. xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
  5. <id>mydemo</id>
  6. <includeBaseDirectory>true</includeBaseDirectory>
  7. <formats>
  8. <format>zip</format>
  9. </formats>
  10. <fileSets>
  11. <fileSet>
  12. <directory>${project.basedir}\src\main\resources</directory>
  13. <outputDirectory>conf/</outputDirectory>
  14. </fileSet>
  15. <fileSet>
  16. <directory>${project.basedir}\target\lib</directory>
  17. <outputDirectory>lib/</outputDirectory>
  18. </fileSet>
  19. </fileSets>
  20. <files>
  21. <file>
  22. <outputDirectory>/</outputDirectory>
  23. <source>${project.basedir}\target\websocket-server-0.0.1-SNAPSHOT.jar</source>
  24. <destName>websocket-server.jar</destName>
  25. </file>
  26. </files>
  27. </assembly>
4. 打包构建

  1. 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. LR----实现WebService测试

    测试WebService时,需要导入WSDL:同SoapUI WSDL:http://ws.webxml.com.cn/webservices/DomesticAirline.asmx?wsdl 场景 ...

  2. hdu 1211 逆元

    RSA Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...

  3. 由浅入深了解EventBus:(二)

    概念 深入学习EventBus框架,就必须理解EventBus的相关原理和一些概念: Subscribe 在EventBus框架中,消息的处理接收方法必须要“@Subscribe”注解来进行标注: p ...

  4. 使用aidl的项目结构以及小的注意事项

    在app的build.gradle里面添加: sourceSets{ main{ java.srcDirs = ['src/main/java','src/main/aidl'] } }

  5. ElementTree之Xml文档处理

    ElementTree: 表示整个XML层级结构 Element: 表示树形结构中所有的父节点 SubElement: 表示树形结构中所有的子节点 有些节点既是父节点,又是子节点 下面来看下这两个类的 ...

  6. operator[],识别读操作和写操作

    body, table{font-family: 微软雅黑; font-size: 10pt} table{border-collapse: collapse; border: solid gray; ...

  7. Git添加远程库

    body, table{font-family: 微软雅黑; font-size: 10pt} table{border-collapse: collapse; border: solid gray; ...

  8. 通过Fegin远程调用 ,返回JPA Page 对象报错

    Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of org.sp ...

  9. Android组件化开发实践

    转载请注明出处:http://blog.csdn.net/crazy1235/article/details/76533115 http://mdsa.51cto.com/art/201707/544 ...

  10. css 添加伪元素 消除浮动 对父元素高度产生的影响