Maven组装插件和配置文件。

4
我有一个Maven(3.0.4)项目,其中处理一些外部资源,并使用在配置文件中定义的一些属性进行过滤。
当我启动程序插件时(无论是手动还是挂钩到某个阶段),似乎maven-resource-plugin没有考虑命令行指定的活动配置文件。因此,与指定配置文件中定义的属性相关的标记没有被替换。
如果我定义了一个activeByDefault配置文件,则即使通过命令行指定另一个配置文件,也会将其视为活动配置文件...
以下是示例:
<plugin>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.5</version>
    <executions>
      <execution>
        <id>copy-script</id>
        <phase>process-resources</phase>
        <goals>
           <goal>copy-resources</goal>
        </goals>
        <configuration>
          <outputDirectory>${basedir}/target</outputDirectory>
          <resources>
            <resource>
              <directory>${basedir}/src/main/bash</directory>
              <filtering>true</filtering>
            </resource>
          </resources>
        </configuration>
      </execution>
    </executions>
</plugin>
...
<profiles>
  <profile>
    <id>staging</id>
    <properties>
      <remote.url>some_stag_value</remote.url>
    </properties>
  </profile>
  <profile>
    <id>prod</id>
    <properties>
      <remote.url>some_prod_value</remote.url>
    </properties>
  </profile>
</profiles>

我解决了在汇编描述符中进行资源复制/过滤的问题。如果由汇编插件而不是资源插件来完成工作,结果就如预期一样。我怀疑这是一个错误... - Marco
1个回答

2

尝试使用!来停用该配置文件:

mvn groupId:artifactId:goal -P profile_you_want !default_profile 

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接