I had similar issue when using copy-resources goal of maven properties plugin. The resources were copied but placeholders were not replaced. For me this was because of silly mistake - I copied the resources in eariler maven phase (validate
) and I included placeholders properties file in later phase (initialize
)... so the properties were not yet available.
I changed the phase of including the properties to validate
and inclusion of placeholders to initialize
and all works fine.
My working config is following:
Inclusion of properties file in validate:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${project.basedir}/path/to/placeholders.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
Copying resources in initialize
:
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<!-- here the phase you need -->
<phase>initialize</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<encoding>UTF-8</encoding>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
<resources>
<resource>
<directory>${basedir}/path/to/directory/with/resources/to/copy</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
p1=bbbbbb
in your properties file? You should havep1=${prop1}
.<resources>
, but since those are test resources, you need to use<testResources>
instead. Something like:<testResources><testResource><directory>src/test/resources</directory><filtering>true</filtering></testResource></testResources>