【发布时间】:2019-02-27 21:39:09
【问题描述】:
我正在使用maven-assembly-plugin 来组装不同的工件,如下所示:
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>configuration-staging</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
<execution>
<id>configuration-production</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
在assembly.xml,我启用了模板过滤:
<fileSets>
<fileSet>
<filtered>true</filtered>
这很好用。例如,如果我在要组装的资源之一中输入${name},则将其替换为项目名称。我还可以在pom.xml 中定义属性,将被插件替换。
现在,我想为maven-assembly-plugin 的每次执行设置不同的属性。例如,我想介绍一个${url},它包含要在目标环境中使用的URL(上例中的staging 和production)。
这可能吗?怎么样?
【问题讨论】:
-
您是否尝试将
<configuration>放入<execution>? -
这与
assembly.xml无关。这是在不同的执行之间共享的;因此我决定在<configuration> 之外定义它。这是关于为不同的执行设置不同的属性集。对于执行configuration-staging,我想解析与configuration-production不同的{$url}值。
标签: maven maven-3 maven-assembly-plugin