I'm working on a Maven project in Eclipse 2019-06 (4.12.0). I added a keystore file to src/main/resources
. When the project is built by Eclipse, the keystore file is copied to target/classes
.
Interestingly, the copied file is larger than the original, and it's not a valid keystore file anymore. I tested this with both Java code and the KeyStore Explorer application. If I delete the copied file, change the name of the original, and rebuild the project, then the copied file will have the new name, so Eclipse definitely copies the keystore file from src/main/resources
, but changes its structure for some reason.
I looked into the copied file, and while the original file starts with FE ED FE ED ...
, the copied one starts with four EF BF BD
sequences. The latter is the UTF-8 encoding of the Unicode replacement character. It's possible that Eclipse treats the keystore file as a text file and changes its encoding (the workspace default is UTF-8), but why?
How can I make Eclipse stop changing the keystore file when copying it to target
?
In the POM file, the keystore file must be excluded from resource filtering:
<build>
...
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<nonFilteredFileExtensions>
<nonFilteredFileExtension>keystore</nonFilteredFileExtension>
</nonFilteredFileExtensions>
</configuration>
</plugin>
</plugins>
</build>