我需要在tar-by-environment包中創建多個tar文件。帶有maven-assembly-plugin的多個文件 - >「已添加,跳過」
每個不同的環境都有一個只有文件「environment.properties」的文件夾,所以我必須將項目內容與我的每個環境的environment.properties文件合併:RC,BC,PROD。
我使用maven組件,插件,要做到這一點,所以有3所組裝描述類似這樣的組件,不同的「身份證」:
<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個導致文件H相同的environment.properties文件,第一個文件是確切的,所以我最終有3個文件是完全相同的包。
我假設裝配過程使用的目錄組成的焦油,所以它複製第一個文件,第二個描述符文件已經存在...
是否有避免這種情況的方法發生?在運行每個描述符之前像乾淨的東西? 我應該使用maven-ant-run插件還是類似的東西?
謝謝!
如果描述符除了id之外是相同的,那麼您在哪裏指定要添加的屬性文件? – Corubba 2012-01-13 14:01:27
在每個描述符的最後一個fileSet中,我有一個不同的「target/escape/{environment}」(示例中是RC)。 – 2012-01-13 14:03:19
當註釋掉前兩個描述符時會發生什麼,所以只有最後一個正在運行(產品一)。在tar中有沒有正確的屬性文件? – Corubba 2012-01-13 14:10:26