Author: hboutemy
Date: Sun Jan 11 10:18:58 2015
New Revision: 1650886

URL: http://svn.apache.org/r1650886
Log:
more robust relative path calculations

Modified:
    
maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleViolationCheckMojo.java

Modified: 
maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleViolationCheckMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleViolationCheckMojo.java?rev=1650886&r1=1650885&r2=1650886&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleViolationCheckMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-checkstyle-plugin/src/main/java/org/apache/maven/plugin/checkstyle/CheckstyleViolationCheckMojo.java
 Sun Jan 11 10:18:58 2015
@@ -54,6 +54,7 @@ import org.apache.maven.project.MavenPro
 import org.codehaus.plexus.configuration.PlexusConfiguration;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.PathTool;
 import org.codehaus.plexus.util.ReaderFactory;
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.xml.pull.MXParser;
@@ -609,7 +610,7 @@ public class CheckstyleViolationCheckMoj
         RuleUtil.Matcher[] ignores =
             ( violationIgnore == null ) ? null : RuleUtil.parseMatchers( 
violationIgnore.split( "," ) );
 
-        int basedir = new File( "" ).getAbsolutePath().length() + 1;
+        String basedir = project.getBasedir().getAbsolutePath();
         String file = "";
         for ( int eventType = xpp.getEventType(); eventType != 
XmlPullParser.END_DOCUMENT; eventType = xpp.next() )
         {
@@ -619,9 +620,8 @@ public class CheckstyleViolationCheckMoj
             }
             else if ( "file".equals( xpp.getName() ) )
             {
-                file = xpp.getAttributeValue( "", "name" );
+                file = PathTool.getRelativeFilePath( basedir, 
xpp.getAttributeValue( "", "name" ) );
                 //file = file.substring( file.lastIndexOf( File.separatorChar 
) + 1 );
-                file = file.substring( basedir );
             }
             else if ( "error".equals( xpp.getName() ) )
             {


Reply via email to