shipmaster
shipmaster

Reputation: 3974

Passing Maven Compiler Options From The Command-line

I am setting up several projects on a continuous integration server, some of which I don't have access to change the source code to, The server is a linux box, I am running into a problem where maven encoding needs to be changed to UTF8 to be able to compile on the box. Since I don't have access to modify the pom file, I was wondering if I can pass the compiler options as a command-line param? The project uses maven compiler 2.0 and I tried passing -Denconding=UTF8 without success.

Upvotes: 3

Views: 4965

Answers (1)

apiri
apiri

Reputation: 1633

You can use the Maven property "project.build.sourceEncoding".

So something along the lines of mvn clean install -Dproject.build.sourceEncoding=UTF-8 should accomplish what you need.

This is equivalent of

<properties>
   <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

in your pom.xml.

Edit: As a point of reference, there is the following link available POM Element for Source File Encoding showing the nuances between these properties for both Maven 2.0 and 3.0

Upvotes: 4

Related Questions