我想复制某些工件中的文件。但它总是添加一个带有该工件名称的目录。
要复制的工件的pom:
<groupId>some.group</groupId>
<artifactId>scheduler-common-test-resources</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>Scheduler common test resources</name>
<description>A scheduler test resources</description>
<packaging>pom</packaging>
.
.
.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.1</version>
<configuration>
<descriptors>
<descriptor>lib/assembly.xml</descriptor>
</descriptors>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
汇编文件:
<assembly>
<id>json</id>
<formats>
<format>tar.gz</format>
</formats>
<fileSets>
<fileSet>
<directory>resources/db</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>alterTables.sql</include>
<include>createTables.sql</include>
<include>insertsIntoReminders.sql</include>
</includes>
<excludes>
<exclude>pom.xml</exclude>
</excludes>
</fileSet>
</fileSets>
要在工件pom中复制的项目:
<artifactItem>
<groupId>some.group</groupId>
<artifactId>scheduler-common-test-resources</artifactId>
<version>1.0.0-SNAPSHOT</version>
<outputDirectory>${project.build.directory}/test-classes/db/</outputDirectory>
<type>tar.gz</type>
<overWrite>false</overWrite>
</artifactItem>
结果:
将其复制到test-classes/db/scheduler-common-test-resources-1.0.0-SNAPSHOT/
如何删除包含工件名称的目录?
答案 0 :(得分:1)
assembly-plugin 默认会添加 baseDirectory ,默认情况下也会${project.build.finalName}
。
在您的情况下,您只需通过添加以下内容来指明您不需要该目录的插件:
<includeBaseDirectory>false</includeBaseDirectory>
汇编描述符中的(assembly.xml
为你)。请参阅assembly descriptor documentation。