3

I found the following JIRA, where it is described, that it is possible to use different filter files for normal execution and for testing.

The problem is I don't get how this has to be configured.

<build>
<filters><filter>myfilters.properties</filter></filters>
...
<resources>...</resources>
<testResources>...</testResources>
<build>

This way the filter is applied to all resources, but I like to have is separate filters definitions for resources and testResources.

I am using maven 3.0.5.

messivanio
  • 2,263
  • 18
  • 24
dag
  • 1,133
  • 12
  • 25
  • Would using maven profiles be helpful? – vikingsteve Jul 04 '13 at 10:17
  • 1
    Not really, i need profiles for other tasks (switching between different customers base configurations) and they are targeting the whole build process not just the testing. – dag Jul 04 '13 at 11:12

1 Answers1

2

You should combine some profiles

A small example (pom.xml) :

...
<build>
  <resources>
    <directory>src/main/resources</directory>
    <filtering>true</filtering>
  </resources>
  <testResources>
    <testResource>
      <directory>src/test/resources</directory>
      <filtering>true</filtering>
    </testResource>
  </testResources>
</build>
<profiles>
  <profile>
   <id>development</id>
   <activation>
     <activeByDefault>true</activeByDefault>
     <property>
       <name>env</name>
       <value>dev</value>
     </property>
   </activation>
   <build>
     <filters>
       <filter>src/test/filters/dev.properties</filter>
     </filters>
   </build>
  </profile>
  <profile>
    <id>test</id>
    <activation>
     <property>
       <name>env</name>
       <value>test</value>
     </property>
    </activation>
    <build>
      <filters>
        <filter>src/test/filters/test.properties</filter>
      </filters>
   </build>
  </profile>
</profiles>
...
willome
  • 3,062
  • 19
  • 32
  • 1
    While this might look like an option it's not the way i want to go, if there s already a build in resource mechanism to do it (as i think the last JIRA comment implies). – dag Jul 04 '13 at 11:13