简体   繁体   中英

maven assembly plugin and profiles

I have a Maven (3.0.4) project in which process some external resources, and filtering them using some properties defined in a profile.

When I launch the assembly plugin (either manually or hooked to a phase) it seems that maven-resource-plugin does not consider active the profile specified by command line. In this way the tokens which relate to the properties defined in the specified profile are not replaced.

If I define a profile activeByDefault this is considered to be active even if another is specified by command line...

This is the example:

<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>

Try deactivating the profile using ! :

mvn groupId:artifactId:goal -P profile_you_want !default_profile 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM