我正在尝试使用程序集maven插件来使用我的项目.jars和一些配置文件.zip我的项目。
我希望模块admin
batch_base_to_base
batch_engine
batch_generic
中的JAR和一些文件misc
我的问题是我的程序集不接受我的配置文件,它确实占用了我的所有jar包括依赖项jar。在我的项目结构和我的POM&汇编描述符。
这是我的项目结构:
assembly-dr3.xml:
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>bin</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<moduleSets>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<includes>
<include>com.mycompany.dr3:batch_engine</include>
<!-- for test but it still includes below modules
<include>com.mycompany.dr3:admin</include>
<include>com.mycompany.dr3:batch_generic</include>
<include>com.mycompany.dr3:batch_base_to_base</include>
-->
</includes>
<sources>
<fileSets>
<fileSet>
<directory>${project.basedir}/misc</directory>
<includes>
<include>configuration.json</include>
<include>environment_placeholders.json</include>
</includes>
</fileSet>
</fileSets>
</sources>
<binaries>
<outputDirectory>modules/maven-assembly-plugin</outputDirectory>
<unpack>false</unpack>
</binaries>
</moduleSet>
</moduleSets>
</assembly>
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project 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/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mycompany.dr3</groupId>
<artifactId>dr3</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>dr3-package</artifactId>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<descriptor>assembly-dr3.xml</descriptor>
</configuration>
<executions>
<execution>
<id>create-archive</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
答案 0 :(得分:0)
当我只想压缩文件夹子集时,我遇到了类似的问题。我的解决方案是直接使用maven-antrun-plugin
来完成您想要的操作。类似的东西:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>${maven-antrun-plugin.version}</version>
<executions>
<execution>
<phase>install</phase>
<configuration>
<target>
<!-- delete previous old tmp folder -->
<delete dir="${temporal-folder}" failonerror="false" includeemptydirs="true" />
<!-- create tmp folder -->
<mkdir dir="${temporal-folder}" />
<!-- copy some stuff -->
<copy todir="${temporal-folder}/somestuff/" overwrite="true">
<fileset dir="./folder-i-want-to-copy" includes="**/*" />
</copy>
<!-- copy more stuff -->
<copy todir="${temporal-folder}/otherstuff/" overwrite="true">
<fileset dir="./other-source" includes="**/*" />
</copy>
<!-- create the final file -->
<zip basedir="${temporal-folder}/" destfile="../${destination-file}-${project.version}.zip" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
我通常将此插件放在maven配置文件中,仅在需要时启动它。