Несколько файлов с помощью maven-assembly-plugin -> "уже добавлено, пропущено" - PullRequest
1 голос
/ 13 января 2012

Мне нужно создать несколько файлов 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 или что-то подобное?

Спасибо!

Ответы [ 2 ]

1 голос
/ 16 января 2012

Плагин already added, skipping появился первым в версии 2.2 плагина, вы можете попробовать v2.1.

0 голосов
/ 13 января 2012

Обычно один артефакт maven означает ровно один выходной файл. Возможно, имеет смысл сделать 3 отдельных модуля maven для каждого tar. Более того, это дает больше гибкости.

...