Page MenuHomePhabricator

Jenkins: Enforce utf-8 for maven builds
Closed, DeclinedPublic

Description

Right now, we're not explicitly building things with an explicit encoding, and relying on the system's encoding. This ends up with warnings such as:

[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!

This is probably fine as long as we stick with utf-8, but it'd probably be nice to be explicit. This can be solved by creating ~/.m2/settings.xml for the jenkins user with the following:

<settings>
<profiles>

		<profile>
			<id>profile-utf</id>
			<properties>
				<project.build.sourceEncoding>
					UTF-8
				</project.build.sourceEncoding>
				<project.reporting.outputEncoding>
					UTF-8
				</project.reporting.outputEncoding>
			</properties>
		</profile>

</profiles>

<activeProfiles>

		<activeProfile>profile-utf</activeProfile>

</activeProfiles>
</settings>


Version: wmf-deployment
Severity: enhancement

Details

Reference
bz45042

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 1:30 AM
bzimport set Reference to bz45042.
bzimport added a subscriber: Unknown Object (MLST).

I guess that should be set explicitly in the project being build.

If there is any maven command line option to set the encoding, the option can be configured in Jenkins general config https://integration.mediawiki.org/ci/configure

(In reply to comment #1)

I guess that should be set explicitly in the project being build.

In theory. In practice, nobody specifies encoding in their poms.

If there is any maven command line option to set the encoding, the option can
be configured in Jenkins general config
https://integration.mediawiki.org/ci/configure

Good to know. May just set it globally.

I'm not familiar with Maven, how do we configure it globally? I'd be happy to do it.

Chad can you look up the global setting that need to be passed to maven to override the encoding? Then we can set it globally in Jenkins system configuration and the warning will disappear for all Maven based jobs :-]

From http://stackoverflow.com/questions/3160547/passing-maven-compiler-options-from-the-command-line it seems we can pass:

-Dproject.build.sourceEncoding=UTF-8 -Dproject.reporting.outputEncoding=UTF-8

I have setup the parameters in Jenkins global configuration MAVEN_OPTS but that did not work while triggering a maven job https://integration.wikimedia.org/ci/job/Android-Commons%20(mobile)%20-%20Nightly%20builds/172/console

Chad is that still needed ? or should we just close the bug? :-D

Closing bug as I don't think it is worth the effort right now. If you find out a way to enforce encoding in maven job, go ahead.