You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2022/12/18 03:54:03 UTC

[maven-compiler-plugin] branch MCOMPILER-516 created (now 333cbce)

This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a change to branch MCOMPILER-516
in repository https://gitbox.apache.org/repos/asf/maven-compiler-plugin.git


      at 333cbce  [MCOMPILER-516] upgrade plexus-compiler to improve compiling message

This branch includes the following new commits:

     new 333cbce  [MCOMPILER-516] upgrade plexus-compiler to improve compiling message

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven-compiler-plugin] 01/01: [MCOMPILER-516] upgrade plexus-compiler to improve compiling message

Posted by hb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to branch MCOMPILER-516
in repository https://gitbox.apache.org/repos/asf/maven-compiler-plugin.git

commit 333cbceb26777b43abbc469d952a32c02117e16e
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Sun Dec 18 04:53:54 2022 +0100

    [MCOMPILER-516] upgrade plexus-compiler to improve compiling message
---
 pom.xml                                            |  2 +-
 src/it/MCOMPILER-192/verify.groovy                 |  2 +-
 .../plugin/compiler/AbstractCompilerMojo.java      | 35 +---------------------
 .../maven/plugin/compiler/stubs/CompilerStub.java  | 25 ----------------
 4 files changed, 3 insertions(+), 61 deletions(-)

diff --git a/pom.xml b/pom.xml
index 467a251..6b90046 100644
--- a/pom.xml
+++ b/pom.xml
@@ -68,7 +68,7 @@ under the License.
       ! The following property is used in the integration tests MCOMPILER-157
     -->
     <mavenPluginPluginVersion>3.5</mavenPluginPluginVersion>
-    <plexusCompilerVersion>2.12.1</plexusCompilerVersion>
+    <plexusCompilerVersion>2.13.0</plexusCompilerVersion>
 
     <groovyVersion>2.4.21</groovyVersion>
     <groovyEclipseCompilerVersion>3.7.0</groovyEclipseCompilerVersion>
diff --git a/src/it/MCOMPILER-192/verify.groovy b/src/it/MCOMPILER-192/verify.groovy
index 0bdd307..4e6e3b0 100644
--- a/src/it/MCOMPILER-192/verify.groovy
+++ b/src/it/MCOMPILER-192/verify.groovy
@@ -23,7 +23,7 @@ assert logFile.exists()
 def content = logFile.getText('UTF-8')
 
 def causedByExpected = content.contains ( 'Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure' )
-def twoFilesBeingCompiled = content.contains ( '[INFO] Compiling 2 source files to ' )
+def twoFilesBeingCompiled = content.contains ( '[INFO] Compiling 2 source files with javac ' )
 def checkResult = content.contains ( '[INFO] BUILD FAILURE' )
 def compilationFailure1 = content.contains( '[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:')
 
diff --git a/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java b/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
index ea37a4d..8da9213 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
@@ -70,10 +70,8 @@ import org.apache.maven.toolchain.Toolchain;
 import org.apache.maven.toolchain.ToolchainManager;
 import org.codehaus.plexus.compiler.Compiler;
 import org.codehaus.plexus.compiler.CompilerConfiguration;
-import org.codehaus.plexus.compiler.CompilerError;
 import org.codehaus.plexus.compiler.CompilerException;
 import org.codehaus.plexus.compiler.CompilerMessage;
-import org.codehaus.plexus.compiler.CompilerNotImplementedException;
 import org.codehaus.plexus.compiler.CompilerOutputStyle;
 import org.codehaus.plexus.compiler.CompilerResult;
 import org.codehaus.plexus.compiler.manager.CompilerManager;
@@ -1255,15 +1253,7 @@ public abstract class AbstractCompilerMojo
 
         try
         {
-            try
-            {
-                compilerResult = compiler.performCompile( compilerConfiguration );
-            }
-            catch ( CompilerNotImplementedException cnie )
-            {
-                List<CompilerError> messages = compiler.compile( compilerConfiguration );
-                compilerResult = convertToCompilerResult( messages );
-            }
+            compilerResult = compiler.performCompile( compilerConfiguration );
         }
         catch ( Exception e )
         {
@@ -1472,29 +1462,6 @@ public abstract class AbstractCompilerMojo
         return false;
     }
 
-    protected CompilerResult convertToCompilerResult( List<CompilerError> compilerErrors )
-    {
-        if ( compilerErrors == null )
-        {
-            return new CompilerResult();
-        }
-        List<CompilerMessage> messages = new ArrayList<>( compilerErrors.size() );
-        boolean success = true;
-        for ( CompilerError compilerError : compilerErrors )
-        {
-            messages.add(
-                new CompilerMessage( compilerError.getFile(), compilerError.getKind(), compilerError.getStartLine(),
-                                     compilerError.getStartColumn(), compilerError.getEndLine(),
-                                     compilerError.getEndColumn(), compilerError.getMessage() ) );
-            if ( compilerError.isError() )
-            {
-                success = false;
-            }
-        }
-
-        return new CompilerResult( success, messages );
-    }
-
     /**
      * @return all source files for the compiler
      */
diff --git a/src/test/java/org/apache/maven/plugin/compiler/stubs/CompilerStub.java b/src/test/java/org/apache/maven/plugin/compiler/stubs/CompilerStub.java
index fd94cc2..23eb392 100644
--- a/src/test/java/org/apache/maven/plugin/compiler/stubs/CompilerStub.java
+++ b/src/test/java/org/apache/maven/plugin/compiler/stubs/CompilerStub.java
@@ -20,7 +20,6 @@ package org.apache.maven.plugin.compiler.stubs;
  */
 
 import org.codehaus.plexus.compiler.CompilerConfiguration;
-import org.codehaus.plexus.compiler.CompilerError;
 import org.codehaus.plexus.compiler.CompilerException;
 import org.codehaus.plexus.compiler.CompilerMessage;
 import org.codehaus.plexus.compiler.CompilerOutputStyle;
@@ -29,7 +28,6 @@ import org.codehaus.plexus.compiler.CompilerResult;
 import java.io.File;
 import java.io.IOException;
 import java.util.Collections;
-import java.util.List;
 
 /**
  * @author Edwin Punzalan
@@ -74,29 +72,6 @@ public class CompilerStub
         return false;
     }
 
-    public List<CompilerError> compile( CompilerConfiguration compilerConfiguration )
-        throws CompilerException
-    {
-        File outputDir = new File( compilerConfiguration.getOutputLocation() );
-
-        try
-        {
-            outputDir.mkdirs();
-
-            File outputFile = new File( outputDir, "compiled.class" );
-            if ( !outputFile.exists() && !outputFile.createNewFile() )
-            {
-                throw new CompilerException( "could not create output file: " + outputFile.getAbsolutePath() );
-            }
-        }
-        catch ( IOException e )
-        {
-            throw new CompilerException( "An exception occurred while creating output file", e );
-        }
-
-        return Collections.singletonList( new CompilerError( "message 1", shouldFail ) );
-    }
-
     public CompilerResult performCompile( CompilerConfiguration compilerConfiguration )
         throws CompilerException
     {