【问题标题】:Maven Assembly : How to generate a zip file for each environment ?Maven 程序集:如何为每个环境生成一个 zip 文件?
【发布时间】:2018-08-21 08:27:39
【问题描述】:

我有一个包含 html、js、css 和 conf 文件的静态项目,如下所示:

project 
       - static
            - conf
                 conf-int.json
                 conf-rec.json
                 conf-prd.json
            -js 
            -html
            -images 
       - pom.xml 
       - assemblyDescriptor.xml

这是我的程序集描述符:

 <id>zip</id>
    <baseDirectory>/</baseDirectory>
    <formats>
        <format>zip</format>
    </formats>
    <fileSets>
        <fileSet>
            <directory>static/conf/</directory>
        </fileSet>
    </fileSets>
</assembly>

这是我在 pom.xml 中的构建配置文件

<build>
<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.6</version>
        <configuration>
            <appendAssemblyId>false</appendAssemblyId>
            <descriptors>
                <descriptor>zip.xml</descriptor>
            </descriptors>
        </configuration>
        <executions>
            <execution>
                <id>trigger-assembly</id>
                <phase>package</phase>
                <goals>
                    <goal>single</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

</plugins>
</build>

我想使用与我拥有的不同环境相对应的 conf-int.json 或 conf-rec.json 或 conf-prd.json 生成我的 zip。如果它是一个java项目,我会使用带有profil和/或分类器的profil maven。但我不知道如何使用 maven-assembly 为每个环境生成一个 zip 文件。你能给我一些建议吗?

【问题讨论】:

    标签: maven-3 development-environment production-environment maven-assembly-plugin


    【解决方案1】:

    您可以在程序集插件中定义多个执行(每个都有不同的执行 ID 和不同的程序集描述符文件)。在相应的描述符中定义要包含的文件。

    【讨论】:

      猜你喜欢
      • 2016-11-06
      • 1970-01-01
      • 2022-01-12
      • 2018-07-16
      • 2010-10-17
      • 2019-04-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多