使用assembly plugin實現自定義打包
1. 修改pom.xml
pom.xml中設定如下:
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<!-- not append assembly id in release file name
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/assemble/package.xml</descriptor>
</descriptors>
</configuration>
<
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
其中<artifactId>maven-assembly-plugin</artifactId>的maven-assembly-plugin是這個外掛的標準命名,在maven2.0.*中帶的預設版本是
appendAssemblyId屬性控制是否在生成的打包檔案的檔名中包含assembly id。
descriptor屬性指定maven-assembly-plugin的配置檔案,當然我設定的是src/main/assemble/package.xml.容許使用多個,功能強大當然用法也複雜,對於簡單情況一個足矣。
execution的設定是為了將maven-assembly-plugin繼承到標準的maven打包過程中,這樣在執行maven-package時就會執行maven-assembly-plugin的操作,從而實現我們需要的自定義打包。
2. assemble descriptor file
我的src/main/assemble/package.xml內容如下:
<assembly xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/assembly-1.0.0.xsd">
<id>package</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>src/main/bin</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
<fileSet>
<directory>src/main/config</directory>
<outputDirectory>config</outputDirectory>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
<scope>runtime</scope>
</dependencySet>
</dependencySets>
</assembly>
詳細的語法不介紹了,請參考官方指南,有非常詳盡的說明:Assembly Descriptor Format reference
簡單解釋一下:
1) format
format=zip設定打包的最終檔案格式為zip.
支援的其他格式還有gz,tar,tar.gz,tar.bz2。
2) fileset
<fileSet>
<directory>src/main/bin</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
將src/main/bin目錄下的檔案打包到根目錄(/)下.
<fileSet>
<directory>src/main/config</directory>
<outputDirectory>config</outputDirectory>
</fileSet>
將src/main/config目錄下的檔案打包到config下.
3) dependencySets
<dependencySet>
<outputDirectory>lib</outputDirectory>
<scope>runtime</scope>
</dependencySet>
將scope為runtime的依賴包打包到lib目錄下。
總結一下,pom.xml中引入maven-assembly-plugin,然後assemble descriptor file按需設定,最後在eclipse中執行Run As -> Maven package,在target目錄下就會出現***.zip檔案,裡面的格式和要求的完全一致。
相關推薦
使用assembly plugin實現自定義打包
assembly plugin的使用方式比較簡單,主要有:1. 修改pom.xml pom.xml中設定如下: <build> <plugins> <plugin>
使用Maven的assembly外掛實現自定義打包
一、背景 最近我們專案越來越多了,然後我就在想如何才能把基礎服務的打包方式統一起來,並且可以實現按照我們的要求來生成,通過研究,我們通過使用maven的assembly外掛完美的實現了該需求,爽爆了有木有。本文分享該外掛的配置以及微服務的統一打包方式。 二、配置步驟及
Maven的assembly外掛實現自定義打包部署(包含依賴jar包)
微服務必備 優點: 1、可以直接匯入依賴jar包 2、可以新增外掛啟動 .sh 檔案 3、外掛的配置以及微服務的統一打包方式 1.首先我們需要在pom.xml中配置maven的assembly外掛 <build> <plugins
Maven assembly實現自定義打包
maven-assembly-plugin : 是maven中針對打包任務而提供的標準外掛 (1)、在pom.xml 檔案裡面的配置說明 <plugin> <artifactId>maven-assembly-plugin</artifactId>
Maven學習總結(27)——Maven自定義打包外掛maven-assembly-plugin詳解
Assembly外掛會生成 “assemblies”, 此特性等同於的Maven 1 distribution plug-in.。該外掛不僅支援建立二進位制歸檔檔案,也支援建立原始碼歸檔檔案。這些as
如何實現自定義同步組件
nds 允許 oid try unlock all 同步 while name package com.chen;import java.util.concurrent.TimeUnit;import java.util.concurrent.locks.AbstractQ
JS簡單實現自定義右鍵菜單
ans idt 右鍵 動畫 忘記 span spa round 部分 RT,一個簡單的例子,僅僅講述原理 <div id="menu" style="width: 0;height: 0;background: cadetblue;position: absolu
Notification的基本用法以及使用RemoteView實現自定義布局
解決 edi ngs 取消 ets lsp 過程 net tde Notification的作用 Notification是一種全局效果的通知,在系統的通知欄中顯示。既然作為通知,其基本作用有: 顯示接收到短消息、即時信息等 顯示客戶端的推送(廣告、優惠、新聞等)
匿名類型與Select方法實現自定義對象插入局部表結構中
aso 直接 菜單 ember new order ber 構建 als 在提取局部表結構數據時,通過Select選取需要的字段,如下句,此時其實產生了一個不用於_menuMan的原新數據類型new { c.SYS_COMMANDS_ID,c.TXT_COMMANDTITL
java中實現Comparable接口實現自定義排序
static -1 return rabl generated args logs ava sca 1 class Student implements Comparable{ 2 String name; 3 int gpa; 4 @Ov
freemarker實現自定義指令和自定義函數
數據 dir variables macro 內置 引擎 eem fig turn 自定義指令: 1.指令在前臺實現 <#macro name param1,param2,param3...paramN> </#macro> 2.指令在後臺實
Android studio 自定義打包apk名
roi fault targe test 包名 如果 nts time css Android Studio打包應用默認生成的apk名稱是:app-release.apk 、如果我們要讓生成的apk名跟我們版本包名有聯系的話,那我們就要自定義生成的apk名了 需要在bui
實現自定義查詢的數據庫設計及實現(一)
bre 名稱 審批流程 work 數據庫名 需要 自定義查詢 perm 枚舉 需求 先說一下需求:實現用戶自定義的查詢,用戶可以自定義要查詢的列、自定義條件條件、自定義排序。除了查詢使用外,還可以使用於各個需要根據條件進行約束的業務,如權限; 本設計和實現,很大部分是通過數
實現自定義查詢的數據庫設計及實現(二)
表名 table abr bigint sts 處理 update 關聯表 creat 上部分大概講了一下表設計,這部分講一下處理。 處理的結構 處理結構的內容比較多,分為幾個部分分別講解一下。首先講解一下尋找關系表。 尋找關系表 尋找關系表根據“表間關系登記表”進行處
spring mvc實現自定義註解
poi org param 運行時 onf dha ogg logs exec 實現方式:使用@Aspect實現: 1. 新建註解接口:CheckSign package com.soeasy.web.utils; import org.springframework.
ApiController實現自定義身份認證
del api color span () log list() etc serialize 1 /// <summary> 2 /// 身份認證 3 /// </summary> 4 public class Au
利用echarts highcharts 實現自定義地圖 關系圖效果 側邊3D柱形圖餅圖散點圖
技術 ges 散點圖 chart blog 餅圖 git 分享 charts github 地址: https://https://github.com/Gengshaoxuan/medataMap github 地址: https://https://github.c
關於Unity實現自定義多邊形圖片效果
image 物體 length inspector 設置 this err eve mes 關於Unity實現自定義多邊形圖片效果 1.創建RawImageEditor編輯器拓展腳本(放在工程中Editor文件夾下,沒有則創建) 1 /*****************
python---redis實現自定義session
ssm clas ges enc set hash blog dig 註意 SESSION_EXPIRE = 60 SESSION_TYPE = ‘Redis‘ pool = redis.ConnectionPool(host="localhost",port=6379)
thinkphp 5.0如何實現自定義404(異常處理)頁面
錯誤頁 自定義異常 異常錯誤 錯誤 load php 錯誤信息 art 正常 404頁面是客戶端在瀏覽網頁時,由於服務器無法正常提供信息,或是服務器無法回應,且不知道原因所返回的頁面。404承載著用戶體驗與SEO優化的重任。404頁面通常為用戶訪問了網站上不存在或已刪除的