Evgeny Makarov
Evgeny Makarov

Reputation: 1448

Maven replacer plugin cannot find file

I want to use maven replacer plugin in order to change content of one of the files in target directory. Here is my plugin definition:

<plugin>
    <groupId>com.google.code.maven-replacer-plugin</groupId>
    <artifactId>replacer</artifactId>
    <version>1.5.1</version>
    <executions>
        <execution>
            <phase>prepare-package</phase>
            <goals>
                <goal>replace</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <file>target\${project.`enter code here`artifactId}-${project.version}\WEB-INF\classes\config\config-core.properties</file>
        <replacements>
            <replacement>
                <token>oneVal</token>
                <value>replaceWith</value>
            </replacement>
        </replacements>
    </configuration>
</plugin>

When I run maven command mvn clean package I got an error that says:

[ERROR] Failed to execute goal com.google.code.maven-replacer-plugin:replacer:1.5.1:replace (default) on project : File 'C:\dev\somePath\target\-\WEB-INF\classes\config\config-core.properties' does not exist -> [Help 1]

I guess it happens because I try to replace file before it gets to target folder. How can I fix it?

Upvotes: 2

Views: 7442

Answers (1)

saurav
saurav

Reputation: 3462

It seems like that your replacer plugin is running between the clean and package phase. Ideally it should run after once the package phase is completed , as in after clean phase target folder is not available , hence it is complaining for missing file.

Change the phase to package and then try it should work.

 <phase>package</phase>

Upvotes: 1

Related Questions