5

I need to customize a number of XML files which are not under resources (in particular, they are under an EAR's project src/main/application).

The filtering mechanism would be perfect for this, but my understanding (correct?) is that it works for resources only.

Is there a way to use filtering for files in other directories than src/main/resources?

Thanks in advance.

Jean-Rémy Revy
  • 5,607
  • 3
  • 39
  • 65
wishihadabettername
  • 14,231
  • 21
  • 68
  • 85

1 Answers1

5

The Maven EAR Plugin can filter the content of src/main/application. As documented in Filtering EAR Resources:

Filtering the sources

Filtering the content of the src/main/application directory or the one defined by the earSourcesDirectory parameter is as easy as:

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-ear-plugin</artifactId>
        <version>2.4.2</version>
        <configuration>
           <filtering>true</filtering>
           [...]
        </configuration>
      </plugin>
    </plugins>
  </build>

Note that the standard properties are available for filtering. It is also possible to specify a set of property files to add extra values if necessary. The configuration below uses also the properties defined in src/main/filters/config.properties

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-ear-plugin</artifactId>
        <version>2.4.2</version>
        <configuration>
           <filtering>true</filtering>
           <filters>
             <filter>src/main/filters/config.properties</filter>
           </filters>
           [...]
        </configuration>
      </plugin>
    </plugins>
  </build>
Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124