Skip to content

Commit 81de779

Browse files
committed
[MCOMPILER-516] upgrade plexus-compiler to improve compiling message
1 parent 9b5605c commit 81de779

File tree

4 files changed

+3
-61
lines changed

4 files changed

+3
-61
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ under the License.
6868
! The following property is used in the integration tests MCOMPILER-157
6969
-->
7070
<mavenPluginPluginVersion>3.5</mavenPluginPluginVersion>
71-
<plexusCompilerVersion>2.12.1</plexusCompilerVersion>
71+
<plexusCompilerVersion>2.13.0</plexusCompilerVersion>
7272

7373
<groovyVersion>2.4.21</groovyVersion>
7474
<groovyEclipseCompilerVersion>3.7.0</groovyEclipseCompilerVersion>

src/it/MCOMPILER-192/verify.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ assert logFile.exists()
2323
def content = logFile.getText('UTF-8')
2424

2525
def causedByExpected = content.contains ( 'Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure' )
26-
def twoFilesBeingCompiled = content.contains ( '[INFO] Compiling 2 source files to ' )
26+
def twoFilesBeingCompiled = content.contains ( '[INFO] Compiling 2 source files with javac ' )
2727
def checkResult = content.contains ( '[INFO] BUILD FAILURE' )
2828
def compilationFailure1 = content.contains( '[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:')
2929

src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,8 @@
7070
import org.apache.maven.toolchain.ToolchainManager;
7171
import org.codehaus.plexus.compiler.Compiler;
7272
import org.codehaus.plexus.compiler.CompilerConfiguration;
73-
import org.codehaus.plexus.compiler.CompilerError;
7473
import org.codehaus.plexus.compiler.CompilerException;
7574
import org.codehaus.plexus.compiler.CompilerMessage;
76-
import org.codehaus.plexus.compiler.CompilerNotImplementedException;
7775
import org.codehaus.plexus.compiler.CompilerOutputStyle;
7876
import org.codehaus.plexus.compiler.CompilerResult;
7977
import org.codehaus.plexus.compiler.manager.CompilerManager;
@@ -1255,15 +1253,7 @@ else if ( !values[0].equals( descriptor.name() ) )
12551253

12561254
try
12571255
{
1258-
try
1259-
{
1260-
compilerResult = compiler.performCompile( compilerConfiguration );
1261-
}
1262-
catch ( CompilerNotImplementedException cnie )
1263-
{
1264-
List<CompilerError> messages = compiler.compile( compilerConfiguration );
1265-
compilerResult = convertToCompilerResult( messages );
1266-
}
1256+
compilerResult = compiler.performCompile( compilerConfiguration );
12671257
}
12681258
catch ( Exception e )
12691259
{
@@ -1472,29 +1462,6 @@ protected boolean isTestCompile()
14721462
return false;
14731463
}
14741464

1475-
protected CompilerResult convertToCompilerResult( List<CompilerError> compilerErrors )
1476-
{
1477-
if ( compilerErrors == null )
1478-
{
1479-
return new CompilerResult();
1480-
}
1481-
List<CompilerMessage> messages = new ArrayList<>( compilerErrors.size() );
1482-
boolean success = true;
1483-
for ( CompilerError compilerError : compilerErrors )
1484-
{
1485-
messages.add(
1486-
new CompilerMessage( compilerError.getFile(), compilerError.getKind(), compilerError.getStartLine(),
1487-
compilerError.getStartColumn(), compilerError.getEndLine(),
1488-
compilerError.getEndColumn(), compilerError.getMessage() ) );
1489-
if ( compilerError.isError() )
1490-
{
1491-
success = false;
1492-
}
1493-
}
1494-
1495-
return new CompilerResult( success, messages );
1496-
}
1497-
14981465
/**
14991466
* @return all source files for the compiler
15001467
*/

src/test/java/org/apache/maven/plugin/compiler/stubs/CompilerStub.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
*/
2121

2222
import org.codehaus.plexus.compiler.CompilerConfiguration;
23-
import org.codehaus.plexus.compiler.CompilerError;
2423
import org.codehaus.plexus.compiler.CompilerException;
2524
import org.codehaus.plexus.compiler.CompilerMessage;
2625
import org.codehaus.plexus.compiler.CompilerOutputStyle;
@@ -29,7 +28,6 @@
2928
import java.io.File;
3029
import java.io.IOException;
3130
import java.util.Collections;
32-
import java.util.List;
3331

3432
/**
3533
* @author Edwin Punzalan
@@ -74,29 +72,6 @@ public boolean canUpdateTarget( CompilerConfiguration compilerConfiguration )
7472
return false;
7573
}
7674

77-
public List<CompilerError> compile( CompilerConfiguration compilerConfiguration )
78-
throws CompilerException
79-
{
80-
File outputDir = new File( compilerConfiguration.getOutputLocation() );
81-
82-
try
83-
{
84-
outputDir.mkdirs();
85-
86-
File outputFile = new File( outputDir, "compiled.class" );
87-
if ( !outputFile.exists() && !outputFile.createNewFile() )
88-
{
89-
throw new CompilerException( "could not create output file: " + outputFile.getAbsolutePath() );
90-
}
91-
}
92-
catch ( IOException e )
93-
{
94-
throw new CompilerException( "An exception occurred while creating output file", e );
95-
}
96-
97-
return Collections.singletonList( new CompilerError( "message 1", shouldFail ) );
98-
}
99-
10075
public CompilerResult performCompile( CompilerConfiguration compilerConfiguration )
10176
throws CompilerException
10277
{

0 commit comments

Comments
 (0)