开发者

Maven: Use the filtering mechanism for text files not under 'resources'?

I need to customize a number of XML files which are not under resources (in particular, they are under an EAR's project sr开发者_StackOverflow社区c/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.


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜