我需要在逐个环境的包中创建多个tar文件。
每个不同的环境都有一个只有文件“environment.properties”的文件夹,所以我必须将项目内容与我的每个环境的环境.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插件还是类似的东西?
谢谢!
答案 0 :(得分:1)
already added, skipping
内容首先出现在插件的2.2版本中,您可以尝试使用v2.1。
答案 1 :(得分:0)
通常,一个maven工件意味着一个输出文件。也许为每个焦油制作3个独立的maven模块更有意义。此外,它提供了更大的灵活性。