views:

1218

answers:

2

I'm working with a maven (jar) Project in Netbeans(Windows), which creates Checkstyle Reports with the maven checkstyle Plugin.

No Matter what i do, i always get the message: File does not end with a newline. for Java Class Files.

What can i do/configure in either Netbeans (Formatter) or for the checkstyle plugin to get rid of the Message ?

Versions of used Software:

  • WinXP SP3
  • Netbeans 6.7 RC1 (happens with 6.5 too)
  • Maven 2.0.9
  • Maven Checkstyle Plugin 2.2
  • Java 1.6 (Update 14)
+3  A: 

Put a newline at the end of the file. or Configure CheckStyle to not care.

<module name="Checker">
<!-- stuff deleted -->
    <module name="NewlineAtEndOfFile">
        <property name="severity" value="ignore" />
</module>


You also have to tell the Maven Checkstyle plugin to use your checkstyle config file.

<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
 <configuration>
   <configLocation>${basedir}/yourCheckstyle.xml
    </configLocation>
 </configuration>
</plugin>
Jon Strayer
"Put a newline at the end of the file." that seems to be impossible with netbeans on windows
Michael Lange
A: 

There's a simpler way to do this. You can specify a suppressions file without overriding the sun checkstyle config file:

<plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-checkstyle-plugin</artifactId>
 <configuration>
  <suppressionsLocation>suppressions.xml</suppressionsLocation>
  <configLocation>config/sun_checks.xml</configLocation>
 </configuration>
</plugin>

Where your suppressions.xml is:

<?xml version="1.0"?>

<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd"&gt;

<suppressions>
 <suppress checks="NewlineAtEndOfFile"
           files=".java" />
</suppressions>
Stuart Jones