Browse files

fix 1.7 build

  • Loading branch information...
1 parent 95c73be commit 2cc86cc7598bfb7b5e2d42d93e7b7c4346fb706a @olamy olamy committed Apr 1, 2013
View
7 plexus-compiler-test/src/main/java/org/codehaus/plexus/compiler/AbstractCompilerTest.java
@@ -178,12 +178,17 @@ public void testCompilingSources()
compilerConfig.setOutputLocation( getBasedir() + "/target/" + getRoleHint() + "/classes-" + index );
+ FileUtils.deleteDirectory( compilerConfig.getOutputLocation() );
+
compilerConfig.addInclude( filename );
compilerConfig.setForceJavacCompilerUse( this.forceJavacCompilerUse );
- compilerConfigurations.add( compilerConfig );
+ //compilerConfig.setTargetVersion( "1.5" );
+ //compilerConfig.setSourceVersion( "1.5" );
+
+ compilerConfigurations.add( compilerConfig );
}
View
33 ...s-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/JavaxToolsCompiler.java
@@ -89,19 +89,17 @@ static void releaseJavaCompiler( JavaCompiler javaCompiler, CompilerConfiguratio
}
}
- static CompilerResult compileInProcess( String[] args, final CompilerConfiguration config,
- String[] sourceFiles )
+ static CompilerResult compileInProcess( String[] args, final CompilerConfiguration config, String[] sourceFiles )
throws CompilerException
{
JavaCompiler compiler = getJavaCompiler( config );
try
{
if ( compiler == null )
{
- CompilerMessage message =
- new CompilerMessage( "No compiler is provided in this environment. "
- + "Perhaps you are running on a JRE rather than a JDK?",
- CompilerMessage.Kind.ERROR );
+ CompilerMessage message = new CompilerMessage( "No compiler is provided in this environment. "
+ + "Perhaps you are running on a JRE rather than a JDK?",
+ CompilerMessage.Kind.ERROR );
return new CompilerResult( false, Collections.singletonList( message ) );
}
final String sourceEncoding = config.getSourceEncoding();
@@ -112,17 +110,18 @@ static CompilerResult compileInProcess( String[] args, final CompilerConfigurati
final Iterable<? extends JavaFileObject> fileObjects =
standardFileManager.getJavaFileObjectsFromStrings( Arrays.asList( sourceFiles ) );
- final JavaCompiler.CompilationTask task =
- /*(Writer out,
- JavaFileManager fileManager,
- DiagnosticListener<? super JavaFileObject> diagnosticListener,
- Iterable<String> options,
- Iterable<String> classes,
- Iterable<? extends JavaFileObject> compilationUnits)*/
+ /*(Writer out,
+ JavaFileManager fileManager,
+ DiagnosticListener<? super JavaFileObject> diagnosticListener,
+ Iterable<String> options,
+ Iterable<String> classes,
+ Iterable<? extends JavaFileObject> compilationUnits)*/
+ List<String> arguments = Arrays.asList( args );
- compiler.getTask( null, standardFileManager, collector, Arrays.asList( args ), null, fileObjects );
+ final JavaCompiler.CompilationTask task =
+ compiler.getTask( null, standardFileManager, collector, arguments, null, fileObjects );
final Boolean result = task.call();
final ArrayList<CompilerMessage> compilerMsgs = new ArrayList<CompilerMessage>();
for ( Diagnostic<? extends JavaFileObject> diagnostic : collector.getDiagnostics() )
@@ -176,15 +175,15 @@ static CompilerResult compileInProcess( String[] args, final CompilerConfigurati
}
compilerMsgs.add(
new CompilerMessage( longFileName, kind, lineNumber, columnNumber, lineNumber, columnNumber,
- formattedMessage ) );
+ formattedMessage ) );
}
if ( result != Boolean.TRUE && compilerMsgs.isEmpty() )
{
compilerMsgs.add(
new CompilerMessage( "An unknown compilation problem occurred", CompilerMessage.Kind.ERROR ) );
}
-
- return new CompilerResult( result, compilerMsgs);
+
+ return new CompilerResult( result, compilerMsgs );
}
catch ( Exception e )
{
View
25 ...ler-javac/src/test/java/org/codehaus/plexus/compiler/javac/AbstractJavacCompilerTest.java
@@ -60,6 +60,21 @@ protected String getRoleHint()
protected int expectedErrors()
{
+
+ // javac output changed for misspelled modifiers starting in 1.6...they now generate 2 errors per occurrence, not one.
+ if ( "1.5".compareTo( getJavaVersion() ) < 0 )
+ {
+ return 4;
+ }
+ else
+ {
+ return 3;
+ }
+ }
+
+ protected String getJavaVersion()
+ {
+
String javaVersion = System.getProperty( "java.version" );
String realJavaVersion = javaVersion;
@@ -80,15 +95,7 @@ protected int expectedErrors()
+ "\ncomparison: \"1.5\".compareTo( \"" + javaVersion + "\" ) == " + ( "1.5".compareTo(
javaVersion ) ) + "\n" );
- // javac output changed for misspelled modifiers starting in 1.6...they now generate 2 errors per occurrence, not one.
- if ( "1.5".compareTo( javaVersion ) < 0 )
- {
- return 4;
- }
- else
- {
- return 3;
- }
+ return javaVersion;
}
protected int expectedWarnings()
View
13 ...mpiler-javac/src/test/java/org/codehaus/plexus/compiler/javac/JavaxToolsCompilerTest.java
@@ -25,4 +25,17 @@
extends AbstractJavacCompilerTest
{
// no op default is to javax.tools if available
+
+ protected int expectedWarnings()
+ {
+ // with 1.7 some warning with bootstrap class path not set in conjunction with -source 1.3
+ if ( "1.6".compareTo( getJavaVersion() ) < 0 )
+ {
+ return 9;
+ }
+ else
+ {
+ return 2;
+ }
+ }
}

0 comments on commit 2cc86cc

Please sign in to comment.