Мне нужно создать несколько файлов tar в пакете tar-by-environment.
В каждой среде есть папка с единственным файлом «environment.properties», поэтому мне нужно объединить содержимое проекта с файлом environment.properties для каждой из моих сред: RC, BC, PROD.
Для этого я использую плагин maven-assembly-plugin, поэтому есть 3 дескриптора сборки, похожих на эту сборку, с разными «id»:
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>pack-content-rc</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>tar</format>
</formats>
<fileSets>
<fileSet>
<outputDirectory>/definitions</outputDirectory>
<directory>definitions</directory>
<includes>
<include>*.*</include>
</includes>
<excludes>
<exclude>.*</exclude>
</excludes>
</fileSet>
<fileSet>
<outputDirectory>/library</outputDirectory>
<directory>library</directory>
<includes>
<include>*.*</include>
</includes>
<excludes>
<exclude>.*</exclude>
</excludes>
</fileSet>
<fileSet>
<outputDirectory>/messages</outputDirectory>
<directory>messages</directory>
<includes>
<include>*.*</include>
</includes>
<excludes>
<exclude>.*</exclude>
</excludes>
</fileSet>
<fileSet>
<outputDirectory>/templates</outputDirectory>
<directory>templates</directory>
<includes>
<include>**/*</include>
</includes>
<excludes>
<exclude>.*</exclude>
</excludes>
</fileSet>
<fileSet>
<outputDirectory>/variables</outputDirectory>
<directory>variables</directory>
<includes>
<include>*.*</include>
</includes>
<excludes>
<exclude>.*</exclude>
</excludes>
</fileSet>
<fileSet>
<outputDirectory>/variables</outputDirectory>
<directory>target/escape/rc</directory>
<includes>
<include>*.*</include>
</includes>
</fileSet>
</fileSets>
</assembly>
И maven конфигурация плагина:
...
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.2</version>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>pack-content-rc.xml</descriptor>
<descriptor>pack-content-bc.xml</descriptor>
<descriptor>pack-content-prod.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
...
И выходной журнал:
[INFO] --- maven-assembly-plugin:2.2.2:single (make-assembly) @ nibbler-content ---
[INFO] Reading assembly descriptor: pack-content-rc.xml
[INFO] Reading assembly descriptor: pack-content-bc.xml
[INFO] Reading assembly descriptor: pack-content-prod.xml
[INFO] nibbler-content-19.0.1-SNAPSHOT-rc/variables/environment.properties already added, skipping
[INFO] Building tar : /Users/ger/Documents/Work/nibbler-content/target/nibbler-content-19.0.1-SNAPSHOT-pack-content-rc.tar
[INFO] nibbler-content-19.0.1-SNAPSHOT-rc/variables/environment.properties already added, skipping
[INFO] nibbler-content-19.0.1-SNAPSHOT-bc/variables/environment.properties already added, skipping
[INFO] Building tar : /Users/ger/Documents/Work/nibbler-content/target/nibbler-content-19.0.1-SNAPSHOT-pack-content-bc.tar
[INFO] nibbler-content-19.0.1-SNAPSHOT-bc/variables/environment.properties already added, skipping
[INFO] nibbler-content-19.0.1-SNAPSHOT-prod/variables/environment.properties already added, skipping
[INFO] Building tar : /Users/ger/Documents/Work/nibbler-content/target/nibbler-content-19.0.1-SNAPSHOT-pack-content-prod.tar
[INFO] nibbler-content-19.0.1-SNAPSHOT-prod/variables/environment.properties already added, skipping
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
Проблема заключается в том, что 3 результирующих файла имеют один и тот же файл environment.properties, первый файл будет точным, поэтому я в итоге получаю 3 файла, которые в точности совпадают.
Я предполагаю, что процесс сборки использует каталог для создания tar, поэтому он копирует первый файл, а для второго дескриптора файл уже существует ...
Есть ли способ избежать этого? Что-то вроде очистки перед запуском каждого дескриптора?
Должен ли я использовать плагин Maven-Ant-Run или что-то подобное?
Спасибо!