o Fix test on Windows

This commit is contained in:
Andreas Gudian 2013-05-13 20:05:16 +02:00
parent 50d916c370
commit c247bfbe5b
2 changed files with 18 additions and 8 deletions

View File

@ -131,7 +131,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<version>2.14.1</version>
</plugin>
<plugin>
<groupId>com.mycila.maven-license-plugin</groupId>

View File

@ -16,6 +16,8 @@
package org.mapstruct.ap.testutil.compilation.model;
import java.io.File;
import java.io.IOException;
import javax.tools.Diagnostic.Kind;
import javax.tools.JavaFileObject;
@ -41,18 +43,26 @@ public class DiagnosticDescriptor {
}
public static DiagnosticDescriptor forDiagnostic(Diagnostic diagnostic) {
String soureFileName = diagnostic.type().getName().replaceAll( "\\.", File.separator ) + ".java";
String soureFileName = diagnostic.type().getName().replace( ".", File.separator ) + ".java";
return new DiagnosticDescriptor( soureFileName, diagnostic.kind(), diagnostic.line(), "" );
}
public static DiagnosticDescriptor forDiagnostic(String sourceDir, javax.tools.Diagnostic<? extends JavaFileObject> diagnostic) {
try
{
String sourceName = new File(diagnostic.getSource().toUri()).getCanonicalPath();
return new DiagnosticDescriptor(
diagnostic.getSource().getName().substring( sourceDir.length() + 1 ),
(sourceName.length() > sourceDir.length() ? sourceName.substring( sourceDir.length() + 1 ) : sourceName),
diagnostic.getKind(),
diagnostic.getLineNumber(),
""
);
}
catch ( IOException e )
{
throw new RuntimeException( e );
}
}
public String getSourceFileName() {
return sourceFileName;