Thomas Sundberg

February 22, 2011

Build is platform dependent

Filed under: Java, Maven — Tags: , , , , — Thomas Sundberg @ 22:44

Chasing the warning:

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

happens too often when you use Maven as a build tool. It is so frequent that it has made it to Maven Official FAQ how you fix it. The simple solution is to add the property project.build.sourceEncoding and set it to the file encoding you want. This often tends to be UTF-8 for me.

It is very annoying when you have set the file encoding using the property project.build.sourceEncoding and run the build again and notice the warning below:

    [WARNING] File encoding has not been set, using platform encoding MacRoman, i.e. build is platform dependent!

Didn’t I just fix that warning? It turns out that this is another warning about the same thing. It is generated by some plugins, in this case by the maven-failsafe-plugin. How can this warning be removed? Simple, just set the file encoding you want for the reports by using the property project.reporting.outputEncoding.

A working pom could look like this:

<?xml version="1.0" encoding="UTF-8"?>
<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>se.sigma.educational.maven</groupId>
    <artifactId>platform-dependant</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.7.2</version>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.7.2</version>
                <configuration>
                    <includes>
                        <include>**</include>
                    </includes>
                </configuration>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.2</version>
        </dependency>
    </dependencies>
</project>

Resources

About these ads

4 Comments »

  1. Thanks, good tip

    Comment by Steve — July 20, 2011 @ 01:58

  2. Worked for me, Thanks

    Comment by Eccentric.Ash — July 21, 2011 @ 00:19

  3. Using it now… thanks a lot!

    Comment by Cristian — January 6, 2012 @ 04:03


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Customized Silver is the New Black Theme Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 49 other followers

%d bloggers like this: