Why does Maven warn me about encoding?
Solution 1:
You haven't set the encoding default property like this:
<project>
...
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
...
</project>
This approach is better than defining encoding manually for every plugin, cause all plugins having default values for encoding for example the maven-resources-plugin:
encoding:
The character encoding scheme to be applied when filtering resources.
Type: java.lang.String
Required: No
User Property: encoding
Default: ${project.build.sourceEncoding}
So this means you only need to define this property and the plugin will automatically use this encoding.
Solution 2:
I was annoyed to see that maven kept on complaining after the above entry
Then I realized that its the failsafe plugin and it needs its own property
So here it goes
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
Solution 3:
When you run the goal archetype:create-from-project
, Maven generates a POM file for building the archetype at target/generated-sources/archetype/pom.xml
and then runs the package
goal (by default) on this POM.
The generated POM file doesn't have project.build.sourceEncoding
or any other property defining encoding, and that's why you get the warning.
The POM is generated from this prototype by org.apache.maven.archetype.creator.FilesetArchetypeCreator#createArchetypeProjectPom
, and from that code there doesn't seem to be a way to add properties to the resulting POM file.