From e052462a33c7dc31cf2d05c265af41887f6c95c2 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Tue, 1 Jun 2021 15:12:01 +0700 Subject: [PATCH 1/4] Centrally version-manage JUnit 4.13.2, also for tests ITs now use the same version as the project itself, no longer 3.8.2. --- plexus-compiler-its/src/main/it/error-prone-compiler/pom.xml | 3 ++- plexus-compiler-its/src/main/it/simple-javac/pom.xml | 3 ++- pom.xml | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/plexus-compiler-its/src/main/it/error-prone-compiler/pom.xml b/plexus-compiler-its/src/main/it/error-prone-compiler/pom.xml index d3b0b37b..2722f0a9 100644 --- a/plexus-compiler-its/src/main/it/error-prone-compiler/pom.xml +++ b/plexus-compiler-its/src/main/it/error-prone-compiler/pom.xml @@ -38,7 +38,8 @@ junit junit - 3.8.2 + @junit.version@ + test diff --git a/plexus-compiler-its/src/main/it/simple-javac/pom.xml b/plexus-compiler-its/src/main/it/simple-javac/pom.xml index 6bb02053..331d5b7d 100644 --- a/plexus-compiler-its/src/main/it/simple-javac/pom.xml +++ b/plexus-compiler-its/src/main/it/simple-javac/pom.xml @@ -37,7 +37,8 @@ junit junit - 3.8.2 + @junit.version@ + test diff --git a/pom.xml b/pom.xml index 3605183c..cdd88c61 100644 --- a/pom.xml +++ b/pom.xml @@ -46,6 +46,7 @@ 7 true 2020-08-24T00:30:49Z + 4.13.2 2.6.0 @@ -80,7 +81,7 @@ junit junit test - 4.13.2 + ${junit.version} From 2ba3c75ed4c81554681c8e07fac6da329c201468 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Tue, 1 Jun 2021 15:15:22 +0700 Subject: [PATCH 2/4] Bump AspectJ to 1.9.7.M3, supporting Java 15+16 Also pull up the version property into the parent POM, in order to be able to use it in ITs, too, similarly to the ErrorProne version. --- plexus-compilers/plexus-compiler-aspectj/pom.xml | 4 ---- pom.xml | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/plexus-compilers/plexus-compiler-aspectj/pom.xml b/plexus-compilers/plexus-compiler-aspectj/pom.xml index f129dffc..74762538 100644 --- a/plexus-compilers/plexus-compiler-aspectj/pom.xml +++ b/plexus-compilers/plexus-compiler-aspectj/pom.xml @@ -13,10 +13,6 @@ Plexus AspectJ Compiler AspectJ Compiler support for Plexus Compiler component. - - 1.9.6 - - org.codehaus.plexus diff --git a/pom.xml b/pom.xml index cdd88c61..c35d8a2c 100644 --- a/pom.xml +++ b/pom.xml @@ -47,6 +47,7 @@ true 2020-08-24T00:30:49Z 4.13.2 + 1.9.7.M3 2.6.0 From cec197739369a16bbd1994e6577d6c05e864269a Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Tue, 1 Jun 2021 15:32:28 +0700 Subject: [PATCH 3/4] Fix basic AspectJ compiler functionality + add integration test This is a first, basic step into improving AspectJ support for Plexus Compiler. It looks like nobody ever noticed, that target and release parameters are not forwarded to AJC, resulting in all class files being compiled to Java 1.2 target. I.e. that annotation-based @AspectJ syntax was completely unsupported before. Since Plexus was introduced 15 years ago, nobody ever did anything to upgrade the functionality a bit, only AspectJ versions were bumped before. Furthermore, only *.java files were being considered for compilation, no *.aj files. This was also fixed, but at the cost of duplication with regard to redefining two static methods 'getSourceFiles' and 'getSourceFilesForSourceRoot'. Other compiler components did it similarly, so the necessary refactoring to make the methods non-static and break them down into smaller parts in order to be able to override only the parts of them dealing with source file extensions, is a TODO which involves refactoring the other compiler components, too. I did not do that in this first step. Another TODO: In contrast to the ECJ adapter, which uses the batch compiler, AJC (an ECJ fork!) is used via the internal AJDT interface, which is designed to be used by the Eclipse IDE. It would have been easier to actually also use the batch compiler right from the start, because then we can more easily map command line parameters and keep the adapter layer thin. Why the original author did that in 2005, remains a mystery. The new AspectJ integration test uses a mixture of - native and @AspectJ syntax variants, - *.java and *.aj aspect source files, - production (src/main) and test (src/test) aspects. This is all covered by a single IT. In the end, the test asserts on the complete JUnit console log, which has to look a certain way in order to reflect that - compilation and test were successful, - all 3 aspects did what they are supposed to do. --- .../it/aspectj-compiler/invoker.properties | 20 ++ .../src/main/it/aspectj-compiler/pom.xml | 73 +++++++ .../src/main/java/org/acme/Application.java | 12 ++ .../java/org/acme/MyAnnotationDrivenAspect.aj | 13 ++ .../src/main/java/org/acme/MyNativeAspect.aj | 7 + .../java/org/acme/do-not-try-to-compile.txt | 7 + .../test/java/org/acme/ApplicationTest.java | 19 ++ .../src/test/java/org/acme/TestAspect.java | 13 ++ .../main/it/aspectj-compiler/verify.groovy | 34 +++ .../plexus/compiler/ajc/AspectJCompiler.java | 195 +++++++++++++----- .../compiler/ajc/AspectJCompilerTest.java | 34 +-- 11 files changed, 342 insertions(+), 85 deletions(-) create mode 100644 plexus-compiler-its/src/main/it/aspectj-compiler/invoker.properties create mode 100644 plexus-compiler-its/src/main/it/aspectj-compiler/pom.xml create mode 100644 plexus-compiler-its/src/main/it/aspectj-compiler/src/main/java/org/acme/Application.java create mode 100644 plexus-compiler-its/src/main/it/aspectj-compiler/src/main/java/org/acme/MyAnnotationDrivenAspect.aj create mode 100644 plexus-compiler-its/src/main/it/aspectj-compiler/src/main/java/org/acme/MyNativeAspect.aj create mode 100644 plexus-compiler-its/src/main/it/aspectj-compiler/src/main/java/org/acme/do-not-try-to-compile.txt create mode 100644 plexus-compiler-its/src/main/it/aspectj-compiler/src/test/java/org/acme/ApplicationTest.java create mode 100644 plexus-compiler-its/src/main/it/aspectj-compiler/src/test/java/org/acme/TestAspect.java create mode 100644 plexus-compiler-its/src/main/it/aspectj-compiler/verify.groovy diff --git a/plexus-compiler-its/src/main/it/aspectj-compiler/invoker.properties b/plexus-compiler-its/src/main/it/aspectj-compiler/invoker.properties new file mode 100644 index 00000000..788d7f9f --- /dev/null +++ b/plexus-compiler-its/src/main/it/aspectj-compiler/invoker.properties @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +invoker.java.version = 1.8+ +invoker.goals = clean test +#invoker.buildResult = failure diff --git a/plexus-compiler-its/src/main/it/aspectj-compiler/pom.xml b/plexus-compiler-its/src/main/it/aspectj-compiler/pom.xml new file mode 100644 index 00000000..8c7ab602 --- /dev/null +++ b/plexus-compiler-its/src/main/it/aspectj-compiler/pom.xml @@ -0,0 +1,73 @@ + + + + + 4.0.0 + + org.apache.maven.plugins.compiler.it + aspectj-compiler + 1.0-SNAPSHOT + + + UTF-8 + UTF-8 + 1.8 + 1.8 + + + + + + maven-compiler-plugin + 3.8.1 + + aspectj + + + + org.codehaus.plexus + plexus-compiler-api + @pom.version@ + + + org.codehaus.plexus + plexus-compiler-aspectj + @pom.version@ + + + + + + + + + junit + junit + @junit.version@ + test + + + org.aspectj + aspectjrt + @aspectj.version@ + + + diff --git a/plexus-compiler-its/src/main/it/aspectj-compiler/src/main/java/org/acme/Application.java b/plexus-compiler-its/src/main/it/aspectj-compiler/src/main/java/org/acme/Application.java new file mode 100644 index 00000000..dbd86b18 --- /dev/null +++ b/plexus-compiler-its/src/main/it/aspectj-compiler/src/main/java/org/acme/Application.java @@ -0,0 +1,12 @@ +package org.acme; + +public class Application { + public static void main(String[] args) { + System.out.println("Running application"); + new Application().greet(args[0]); + } + + public String greet(String name) { + return "Hello " + name; + } +} diff --git a/plexus-compiler-its/src/main/it/aspectj-compiler/src/main/java/org/acme/MyAnnotationDrivenAspect.aj b/plexus-compiler-its/src/main/it/aspectj-compiler/src/main/java/org/acme/MyAnnotationDrivenAspect.aj new file mode 100644 index 00000000..1cebb9c7 --- /dev/null +++ b/plexus-compiler-its/src/main/it/aspectj-compiler/src/main/java/org/acme/MyAnnotationDrivenAspect.aj @@ -0,0 +1,13 @@ +package org.acme; + +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; + +@Aspect +public class MyAnnotationDrivenAspect { + @Before("execution(static * *(..)) && within(Application)") + public void myAdvice(JoinPoint joinPoint) { + System.out.println(joinPoint); + } +} diff --git a/plexus-compiler-its/src/main/it/aspectj-compiler/src/main/java/org/acme/MyNativeAspect.aj b/plexus-compiler-its/src/main/it/aspectj-compiler/src/main/java/org/acme/MyNativeAspect.aj new file mode 100644 index 00000000..b70efcf6 --- /dev/null +++ b/plexus-compiler-its/src/main/it/aspectj-compiler/src/main/java/org/acme/MyNativeAspect.aj @@ -0,0 +1,7 @@ +package org.acme; + +public aspect MyNativeAspect { + before() : execution(!static * *(..)) && within(Application) { + System.out.println(thisJoinPoint); + } +} diff --git a/plexus-compiler-its/src/main/it/aspectj-compiler/src/main/java/org/acme/do-not-try-to-compile.txt b/plexus-compiler-its/src/main/it/aspectj-compiler/src/main/java/org/acme/do-not-try-to-compile.txt new file mode 100644 index 00000000..7d0fddb6 --- /dev/null +++ b/plexus-compiler-its/src/main/it/aspectj-compiler/src/main/java/org/acme/do-not-try-to-compile.txt @@ -0,0 +1,7 @@ +The Apache Maven Compiler (MC) API only allows a single source file extension, such as '.java'. +The AspectJ Compiler (AJC) should consider two default extensions, though: '.java' and '.aj'. +In order to achieve that, the Plexus AJC component tells MC to give it all files, +subsequently filtering for those two extensions. + +The purpose of this file is to make sure that even though MC finds it in the source folder, +Plexus AJC filters it out and AJC does not try to compile it. diff --git a/plexus-compiler-its/src/main/it/aspectj-compiler/src/test/java/org/acme/ApplicationTest.java b/plexus-compiler-its/src/main/it/aspectj-compiler/src/test/java/org/acme/ApplicationTest.java new file mode 100644 index 00000000..9e2dec86 --- /dev/null +++ b/plexus-compiler-its/src/main/it/aspectj-compiler/src/test/java/org/acme/ApplicationTest.java @@ -0,0 +1,19 @@ +package org.acme; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +public class ApplicationTest { + @Test + public void testGreet() { + assertEquals("Hello Jane", new Application().greet("Jane")); + } + + @Test + public void testMain() { + Application.main(new String[] { "Joe" }); + assertTrue(true); + } +} diff --git a/plexus-compiler-its/src/main/it/aspectj-compiler/src/test/java/org/acme/TestAspect.java b/plexus-compiler-its/src/main/it/aspectj-compiler/src/test/java/org/acme/TestAspect.java new file mode 100644 index 00000000..da89cacb --- /dev/null +++ b/plexus-compiler-its/src/main/it/aspectj-compiler/src/test/java/org/acme/TestAspect.java @@ -0,0 +1,13 @@ +package org.acme; + +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; + +@Aspect +public class TestAspect { + @Before("call(* *(..)) && !within(TestAspect)") + public void beforeCall(JoinPoint joinPoint) { + System.out.println(joinPoint); + } +} diff --git a/plexus-compiler-its/src/main/it/aspectj-compiler/verify.groovy b/plexus-compiler-its/src/main/it/aspectj-compiler/verify.groovy new file mode 100644 index 00000000..d1c4410d --- /dev/null +++ b/plexus-compiler-its/src/main/it/aspectj-compiler/verify.groovy @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +def logFile = new File( basedir, 'build.log' ) +assert logFile.exists() +content = logFile.text.normalize() + +def junitLog = """Running org.acme.ApplicationTest +call(String org.acme.Application.greet(String)) +execution(String org.acme.Application.greet(String)) +call(void org.junit.Assert.assertEquals(Object, Object)) +call(void org.acme.Application.main(String[])) +execution(void org.acme.Application.main(String[])) +Running application +execution(String org.acme.Application.greet(String)) +call(void org.junit.Assert.assertTrue(boolean)) +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0""".normalize() + +assert content.contains( junitLog ) diff --git a/plexus-compilers/plexus-compiler-aspectj/src/main/java/org/codehaus/plexus/compiler/ajc/AspectJCompiler.java b/plexus-compilers/plexus-compiler-aspectj/src/main/java/org/codehaus/plexus/compiler/ajc/AspectJCompiler.java index 286407cd..0f70efca 100644 --- a/plexus-compilers/plexus-compiler-aspectj/src/main/java/org/codehaus/plexus/compiler/ajc/AspectJCompiler.java +++ b/plexus-compilers/plexus-compiler-aspectj/src/main/java/org/codehaus/plexus/compiler/ajc/AspectJCompiler.java @@ -17,6 +17,7 @@ import org.codehaus.plexus.compiler.CompilerOutputStyle; import org.codehaus.plexus.compiler.CompilerResult; import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.util.DirectoryScanner; import java.io.File; import java.io.IOException; @@ -25,9 +26,11 @@ import java.net.URLClassLoader; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Set; /** *

@@ -295,7 +298,9 @@ public class AspectJCompiler public AspectJCompiler() { - super( CompilerOutputStyle.ONE_OUTPUT_FILE_PER_INPUT_FILE, ".java", ".class", null ); + // Input file ending "" means: Give me all files, I am going to filter them myself later. We are doing this, + // because in method 'getSourceFiles' we need to search for both ".java" and ".aj" files. + super( CompilerOutputStyle.ONE_OUTPUT_FILE_PER_INPUT_FILE, "", ".class", null ); } public CompilerResult performCompile( CompilerConfiguration config ) @@ -344,15 +349,17 @@ private AjBuildConfig buildCompilerConfig( CompilerConfiguration config ) buildConfig.setFiles( buildFileList( Arrays.asList( files ) ) ); } - setSourceVersion( buildConfig, config.getSourceVersion() ); + String releaseVersion = config.getReleaseVersion(); + setSourceVersion( buildConfig, releaseVersion == null ? config.getSourceVersion() : releaseVersion ); + setTargetVersion( buildConfig, releaseVersion == null ? config.getTargetVersion() : releaseVersion ); if ( config.isDebug() ) { buildConfig.getOptions().produceDebugAttributes = - ClassFileConstants.ATTR_SOURCE + ClassFileConstants.ATTR_LINES + ClassFileConstants.ATTR_VARS; + ClassFileConstants.ATTR_SOURCE + ClassFileConstants.ATTR_LINES + ClassFileConstants.ATTR_VARS; } - Map javaOpts = config.getCustomCompilerArguments(); + Map javaOpts = config.getCustomCompilerArgumentsAsMap(); if ( javaOpts != null && !javaOpts.isEmpty() ) { // TODO support customCompilerArguments @@ -557,7 +564,7 @@ private List buildFileList( List locations ) } /** - * Set the source version in ajc compiler + * Set the source version in AspectJ compiler * * @param buildConfig * @param sourceVersion @@ -565,75 +572,149 @@ private List buildFileList( List locations ) private void setSourceVersion( AjBuildConfig buildConfig, String sourceVersion ) throws CompilerException { - if ( "11".equals( sourceVersion ) ) - { - buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK11; - } - else if ( "10".equals( sourceVersion ) ) - { - buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK10; - } - else if ( "9".equals( sourceVersion ) ) - { - buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK9; - } - else if ( "1.9".equals( sourceVersion ) ) - { - buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK9; - } - else if ( "1.8".equals( sourceVersion ) ) - { - buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK1_8; - } - else if ( "1.7".equals( sourceVersion ) ) - { - buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK1_7; - } - else if ( "1.6".equals( sourceVersion ) ) - { - buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK1_6; - } - else if ( "1.5".equals( sourceVersion ) ) + buildConfig.getOptions().sourceLevel = versionStringToMajorMinor( sourceVersion ); + } + + /** + * Set the target version in AspectJ compiler + * + * @param buildConfig + * @param targetVersion + */ + private void setTargetVersion( AjBuildConfig buildConfig, String targetVersion ) + throws CompilerException + { + buildConfig.getOptions().targetJDK = versionStringToMajorMinor( targetVersion ); + } + + private static long versionStringToMajorMinor(String version) throws CompilerException + { + if ( version == null ) + { + version = ""; + } + // Note: We avoid using org.codehaus.plexus:plexus-java here on purpose, because Maven Compiler might depend on + // a different (older) versionm, e.g. not having the 'asMajor' method yet. This can cause problems for users + // trying to compile their AspectJ code using Plexus. + + version = version.trim() + // Cut off leading "1.", focusing on the Java major + .replaceFirst( "^1[.]", "" ) + // Accept, but cut off trailing ".0", as ECJ/ACJ explicitly support versions like 5.0, 8.0, 11.0 + .replaceFirst("[.]0$", ""); + + switch ( version ) + { + // Java 1.6 as a default source/target seems to make sense. Maven Compiler should set its own default + // anyway, so this probably never needs to be used. But not having a default feels bad, too. + case "" : return ClassFileConstants.JDK1_6; + case "1" : return ClassFileConstants.JDK1_1; + case "2" : return ClassFileConstants.JDK1_2; + case "3" : return ClassFileConstants.JDK1_3; + case "4" : return ClassFileConstants.JDK1_4; + case "5" : return ClassFileConstants.JDK1_5; + case "6" : return ClassFileConstants.JDK1_6; + case "7" : return ClassFileConstants.JDK1_7; + case "8" : return ClassFileConstants.JDK1_8; + case "9" : return ClassFileConstants.JDK9; + case "10" : return ClassFileConstants.JDK10; + case "11" : return ClassFileConstants.JDK11; + case "12" : return ClassFileConstants.JDK12; + case "13" : return ClassFileConstants.JDK13; + case "14" : return ClassFileConstants.JDK14; + case "15" : return ClassFileConstants.JDK15; + case "16" : return ClassFileConstants.JDK16; + } + throw new CompilerException( "Unknown Java source/target version number: " + version ); + } + + /** + * @return null + */ + public String[] createCommandLine( CompilerConfiguration config ) + throws CompilerException + { + return null; + } + + protected static String[] getSourceFiles( CompilerConfiguration config ) + { + Set sources = new HashSet<>(); + + Set sourceFiles = config.getSourceFiles(); + + if ( sourceFiles != null && !sourceFiles.isEmpty() ) { - buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK1_5; + for ( File sourceFile : sourceFiles ) + { + if ( sourceFile.getName().endsWith( ".java" ) || sourceFile.getName().endsWith( ".aj" ) ) + { + sources.add( sourceFile.getAbsolutePath() ); + } + } } - else if ( "5.0".equals( sourceVersion ) ) + else { - buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK1_5; + for ( String sourceLocation : config.getSourceLocations() ) + { + sources.addAll( getSourceFilesForSourceRoot( config, sourceLocation ) ); + } } - else if ( "1.4".equals( sourceVersion ) ) + + String[] result; + + if ( sources.isEmpty() ) { - buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK1_4; + result = new String[0]; } - else if ( "1.3".equals( sourceVersion ) ) + else { - buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK1_3; + result = sources.toArray( new String[sources.size()] ); } - else if ( "1.2".equals( sourceVersion ) ) + + return result; + } + + protected static Set getSourceFilesForSourceRoot( CompilerConfiguration config, String sourceLocation ) + { + DirectoryScanner scanner = new DirectoryScanner(); + + scanner.setBasedir( sourceLocation ); + + Set includes = config.getIncludes(); + + if ( includes != null && !includes.isEmpty() ) { - buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK1_2; + String[] inclStrs = includes.toArray( new String[includes.size()] ); + scanner.setIncludes( inclStrs ); } - else if ( "1.1".equals( sourceVersion ) ) + else { - buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK1_1; + scanner.setIncludes( new String[] {"**/*.java", "**/*.aj"} ); } - else if ( sourceVersion == null || sourceVersion.length() <= 0 ) + + Set excludes = config.getExcludes(); + + if ( excludes != null && !excludes.isEmpty() ) { - buildConfig.getOptions().sourceLevel = ClassFileConstants.JDK1_3; + String[] exclStrs = excludes.toArray( new String[excludes.size()] ); + scanner.setExcludes( exclStrs ); } - else + + scanner.scan(); + + String[] sourceDirectorySources = scanner.getIncludedFiles(); + + Set sources = new HashSet<>(); + + for ( String sourceDirectorySource : sourceDirectorySources ) { - throw new CompilerException( "The source version was not recognized: " + sourceVersion ); + File f = new File( sourceLocation, sourceDirectorySource ); + + sources.add( f.getPath() ); } - } - /** - * @return null - */ - public String[] createCommandLine( CompilerConfiguration config ) - throws CompilerException - { - return null; + return sources; } } diff --git a/plexus-compilers/plexus-compiler-aspectj/src/test/java/org/codehaus/plexus/compiler/ajc/AspectJCompilerTest.java b/plexus-compilers/plexus-compiler-aspectj/src/test/java/org/codehaus/plexus/compiler/ajc/AspectJCompilerTest.java index e3c9835b..fceb9277 100644 --- a/plexus-compilers/plexus-compiler-aspectj/src/test/java/org/codehaus/plexus/compiler/ajc/AspectJCompilerTest.java +++ b/plexus-compilers/plexus-compiler-aspectj/src/test/java/org/codehaus/plexus/compiler/ajc/AspectJCompilerTest.java @@ -3,7 +3,6 @@ import java.io.File; import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.List; import org.codehaus.plexus.compiler.AbstractCompilerTest; @@ -24,40 +23,19 @@ protected String getRoleHint() return "aspectj"; } - protected int expectedErrors() - { - // olamy well I agree it's hackhish but I don't want to waste too much time with aspectj which is probably - // not used a lot anymore... - String javaVersion = getJavaVersion(); - if (javaVersion.equals( "11" )) - { - return 11; - } - return 1; - } - protected Collection expectedOutputFiles() { - String javaVersion = System.getProperty( "java.version" ); - // olamy well I agree it's hackhish but I don't want to waste too much time with aspectj which is probably - // not used a lot anymore... -// if (javaVersion.startsWith( "9" ) || javaVersion.startsWith( "10" )) -// { -// return Collections.emptyList(); -// } - return Arrays.asList( new String[]{ "org/codehaus/foo/ExternalDeps.class", "org/codehaus/foo/Person.class" } ); + return Arrays.asList( "org/codehaus/foo/ExternalDeps.class", "org/codehaus/foo/Person.class" ); } protected List getClasspath() throws Exception { - List cp = super.getClasspath(); - - File localArtifactPath = - getLocalArtifactPath( "org.aspectj", "aspectjrt", System.getProperty( "aspectj.version" ), "jar" ); - cp.add( localArtifactPath.getAbsolutePath() ); - - return cp; + List classpath = super.getClasspath(); + String aspectjVersion = System.getProperty( "aspectj.version" ); + File aspectjRuntime = getLocalArtifactPath( "org.aspectj", "aspectjrt", aspectjVersion, "jar" ); + classpath.add( aspectjRuntime.getAbsolutePath() ); + return classpath; } } From 3cbd1af632f78f437f2662868b3a1ae8a9caffe2 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Tue, 15 Jun 2021 09:17:49 +0700 Subject: [PATCH 4/4] Activate 'streamLogsOnFailures' for Maven Invoker This way, it is easier to debug failing integration tests on CI environments, where it is difficult or impossible to add the individual IT build logs. OTOH, the Maven debug statements in the test output are usually making it quite hard to find the actual error that occurred. While helpful in rare cases, most of the time the normal Maven build output should easily suffice in order to identify and fix integration test problems. Therefore, I deactivated 'debug' for Maven Invoker. This should strike a sensible balance between inlining IT error logs into the outer Maven build log in case of errors and not polluting it with too much information. --- plexus-compiler-its/pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plexus-compiler-its/pom.xml b/plexus-compiler-its/pom.xml index 2d9f97cf..c5979a64 100644 --- a/plexus-compiler-its/pom.xml +++ b/plexus-compiler-its/pom.xml @@ -39,7 +39,8 @@ verify - true + false + true src/main/it ${project.build.directory}/it verify