简体   繁体   中英

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?

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM