Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Maven warn me about encoding?

People also ask

Why Maven plugins are used?

"Maven" is really just a core framework for a collection of Maven Plugins. In other words, plugins are where much of the real action is performed, plugins are used to: create jar files, create war files, compile code, unit test code, create project documentation, and on and on.

How You Can Produce execution debug output or error messages?

How to produce execution debug output or error messages? You could call Maven with -X parameter or -e parameter. For more information, run: mvn --help.

What is Maven Resources plugin?

The Resources Plugin handles the copying of project resources to the output directory. There are two different kinds of resources: main resources and test resources.

What is org Apache Maven plugins?

org.apache.maven.plugins » maven-javadoc-pluginApache. The Apache Maven Javadoc Plugin is a plugin that uses the javadoc tool for generating javadocs for the specified project. Last Release on Aug 13, 2022.


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.


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>

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.