[英]how to create a zipped artifact of a maven javascript project
我有一個Maven JavaScript NodeJS項目。 以下是項目結構
-- Project
-- dist
-- node_modules
-- src
-- target
Gruntfile.js
gulpfile.js
package.json
pom.xml
有沒有一種方法可以配置pom,以便它構建dist
文件夾的壓縮文件並將其保存在輸出目標目錄中?
使用maven-assembly-plugin
可以做到這一點。 這是一個非常通用的插件,可用於創建項目的自定義程序集。
它是通過assembly.xml
文件配置的。 對於您的情況,配置為:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<id>dist</id>
<formats>
<format>zip</format> <!-- create a zip archive -->
</formats>
<fileSets>
<fileSet>
<directory>dist</directory> <!-- source is the "dist" folder -->
<outputDirectory>/</outputDirectory> <!-- target is the root of the archive -->
</fileSet>
</fileSets>
</assembly>
該文件的典型位置是src/main/assembly/assembly.xml
。 然后,POM將包含:
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.5</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>assembly-dist</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
調用mvn clean package
, target
文件夾將包含此插件生成的zip文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.