From c410379f837d2cd45ebfaec58754e6f040b4ff2f Mon Sep 17 00:00:00 2001 From: Filip Hrisafov Date: Sun, 5 Apr 2020 16:46:20 +0200 Subject: [PATCH] #1553: Update tycho-compiler-jdt to latest 1.6.0 version Disable one test in GenericsHierarchyTest for Eclipse on Java 8 due to a bug in the Tycho compiler. Disable freeBuilder integration test for Eclipse since there are some problems in the second round of annotation processing (no ModelElementProcessor(s) are found) --- .../itest/tests/MavenIntegrationTest.java | 3 +- parent/pom.xml | 19 ++++++- .../generics/GenericsHierarchyTest.java | 9 +++ .../conversion/date/DateConversionTest.java | 20 +++++-- .../jodatime/JodaConversionTest.java | 10 +++- .../ap/test/verbose/VerboseTest.java | 55 +++++++++++++++---- .../runner/AnnotationProcessorTestRunner.java | 5 +- .../ap/testutil/runner/Compiler.java | 2 +- .../testutil/runner/DisabledOnCompiler.java | 2 +- .../runner/EclipseCompilingStatement.java | 18 +++++- .../ap/testutil/runner/EnabledOnCompiler.java | 2 +- .../InnerAnnotationProcessorRunner.java | 12 +++- 12 files changed, 127 insertions(+), 30 deletions(-) diff --git a/integrationtest/src/test/java/org/mapstruct/itest/tests/MavenIntegrationTest.java b/integrationtest/src/test/java/org/mapstruct/itest/tests/MavenIntegrationTest.java index e7e26d9e1..97da699cb 100644 --- a/integrationtest/src/test/java/org/mapstruct/itest/tests/MavenIntegrationTest.java +++ b/integrationtest/src/test/java/org/mapstruct/itest/tests/MavenIntegrationTest.java @@ -36,8 +36,7 @@ public class MavenIntegrationTest { } @ProcessorTest(baseDir = "freeBuilderBuilderTest", processorTypes = { - ProcessorTest.ProcessorType.JAVAC, - ProcessorTest.ProcessorType.ECLIPSE_JDT + ProcessorTest.ProcessorType.JAVAC }) void freeBuilderBuilderTest() { } diff --git a/parent/pom.xml b/parent/pom.xml index 9bc07c5cd..37551e2ed 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -27,7 +27,7 @@ 3.0.0-M3 3.1.0 4.0.3.RELEASE - 0.26.0 + 1.6.0 8.29 5.6.0 @@ -237,13 +237,28 @@ org.codehaus.plexus plexus-container-default - 1.6 + 1.7.1 + + + org.codehaus.plexus + plexus-component-annotations + 1.7.1 + + + org.codehaus.plexus + plexus-classworlds + 2.5.1 org.codehaus.plexus plexus-utils 3.0.20 + + commons-io + commons-io + 2.5 + diff --git a/processor/src/test/java/org/mapstruct/ap/test/abstractclass/generics/GenericsHierarchyTest.java b/processor/src/test/java/org/mapstruct/ap/test/abstractclass/generics/GenericsHierarchyTest.java index d79f54454..282a8e8ef 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/abstractclass/generics/GenericsHierarchyTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/abstractclass/generics/GenericsHierarchyTest.java @@ -12,6 +12,8 @@ import org.junit.runner.RunWith; import org.mapstruct.ap.testutil.IssueKey; import org.mapstruct.ap.testutil.WithClasses; import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner; +import org.mapstruct.ap.testutil.runner.Compiler; +import org.mapstruct.ap.testutil.runner.DisabledOnCompiler; /** * @author Andreas Gudian @@ -34,6 +36,13 @@ import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner; public class GenericsHierarchyTest { @Test + // Disabled due to a bug in the Eclipse compiler (https://bugs.eclipse.org/bugs/show_bug.cgi?id=540101) + // See https://github.com/mapstruct/mapstruct/issues/1553 and https://github.com/mapstruct/mapstruct/pull/1587 + // for more information + @DisabledOnCompiler( { + Compiler.ECLIPSE, + Compiler.ECLIPSE11 + } ) public void determinesAnimalKeyGetter() { AbstractAnimal source = new Elephant(); diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/date/DateConversionTest.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/date/DateConversionTest.java index 43ed5b330..2d98b73bc 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/conversion/date/DateConversionTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/date/DateConversionTest.java @@ -55,7 +55,10 @@ public class DateConversionTest { } @Test - @DisabledOnCompiler(Compiler.JDK11) + @DisabledOnCompiler({ + Compiler.JDK11, + Compiler.ECLIPSE11 + }) // See https://bugs.openjdk.java.net/browse/JDK-8211262, there is a difference in the default formats on Java 9+ public void shouldApplyDateFormatForConversions() { Source source = new Source(); @@ -70,7 +73,10 @@ public class DateConversionTest { } @Test - @EnabledOnCompiler(Compiler.JDK11) + @EnabledOnCompiler({ + Compiler.JDK11, + Compiler.ECLIPSE11 + }) // See https://bugs.openjdk.java.net/browse/JDK-8211262, there is a difference in the default formats on Java 9+ public void shouldApplyDateFormatForConversionsJdk11() { Source source = new Source(); @@ -85,7 +91,10 @@ public class DateConversionTest { } @Test - @DisabledOnCompiler(Compiler.JDK11) + @DisabledOnCompiler({ + Compiler.JDK11, + Compiler.ECLIPSE11 + }) // See https://bugs.openjdk.java.net/browse/JDK-8211262, there is a difference in the default formats on Java 9+ public void shouldApplyDateFormatForConversionInReverseMapping() { Target target = new Target(); @@ -102,7 +111,10 @@ public class DateConversionTest { } @Test - @EnabledOnCompiler(Compiler.JDK11) + @EnabledOnCompiler({ + Compiler.JDK11, + Compiler.ECLIPSE11 + }) // See https://bugs.openjdk.java.net/browse/JDK-8211262, there is a difference in the default formats on Java 9+ public void shouldApplyDateFormatForConversionInReverseMappingJdk11() { Target target = new Target(); diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/jodatime/JodaConversionTest.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/jodatime/JodaConversionTest.java index db61b85bc..9f61c222d 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/conversion/jodatime/JodaConversionTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/jodatime/JodaConversionTest.java @@ -87,7 +87,10 @@ public class JodaConversionTest { } @Test - @DisabledOnCompiler(Compiler.JDK11) + @DisabledOnCompiler({ + Compiler.JDK11, + Compiler.ECLIPSE11 + }) // See https://bugs.openjdk.java.net/browse/JDK-8211262, there is a difference in the default formats on Java 9+ public void testSourceToTargetMappingForStrings() { Source src = new Source(); @@ -115,7 +118,10 @@ public class JodaConversionTest { } @Test - @EnabledOnCompiler(Compiler.JDK11) + @EnabledOnCompiler({ + Compiler.JDK11, + Compiler.ECLIPSE11 + }) // See https://bugs.openjdk.java.net/browse/JDK-8211262, there is a difference in the default formats on Java 9+ public void testSourceToTargetMappingForStringsJdk11() { Source src = new Source(); diff --git a/processor/src/test/java/org/mapstruct/ap/test/verbose/VerboseTest.java b/processor/src/test/java/org/mapstruct/ap/test/verbose/VerboseTest.java index 0d8003f91..c042e3d07 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/verbose/VerboseTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/verbose/VerboseTest.java @@ -30,7 +30,10 @@ import org.mapstruct.ap.testutil.runner.DisabledOnCompiler; public class VerboseTest { @Test - @DisabledOnCompiler( Compiler.ECLIPSE ) + @DisabledOnCompiler( { + Compiler.ECLIPSE, + Compiler.ECLIPSE11 + } ) @ProcessorOption(name = "mapstruct.verbose", value = "true") @WithClasses({ CreateBeanMapping.class, CreateBeanMappingConfig.class }) @ExpectedNote("^MapStruct: Using accessor naming strategy:.*DefaultAccessorNamingStrategy.*$") @@ -41,7 +44,10 @@ public class VerboseTest { } @Test - @DisabledOnCompiler( Compiler.ECLIPSE ) + @DisabledOnCompiler( { + Compiler.ECLIPSE, + Compiler.ECLIPSE11 + } ) @WithServiceImplementation(provides = BuilderProvider.class, value = ImmutablesBuilderProvider.class) @WithServiceImplementation(provides = AccessorNamingStrategy.class, value = ImmutablesAccessorNamingStrategy.class) @ProcessorOption(name = "mapstruct.verbose", value = "true") @@ -54,7 +60,10 @@ public class VerboseTest { } @Test - @DisabledOnCompiler( Compiler.ECLIPSE ) + @DisabledOnCompiler( { + Compiler.ECLIPSE, + Compiler.ECLIPSE11 + } ) @WithServiceImplementation(provides = AstModifyingAnnotationProcessor.class, value = AstModifyingAnnotationProcessorSaysNo.class) @ProcessorOption(name = "mapstruct.verbose", value = "true") @@ -73,7 +82,10 @@ public class VerboseTest { } @Test - @DisabledOnCompiler( Compiler.ECLIPSE ) + @DisabledOnCompiler( { + Compiler.ECLIPSE, + Compiler.ECLIPSE11 + } ) @ProcessorOption(name = "mapstruct.verbose", value = "true") @WithClasses({ CreateBeanMapping.class, CreateBeanMappingConfig.class }) @ExpectedNote("^- MapStruct: creating bean mapping method implementation for.*$") @@ -82,7 +94,10 @@ public class VerboseTest { } @Test - @DisabledOnCompiler( Compiler.ECLIPSE ) + @DisabledOnCompiler( { + Compiler.ECLIPSE, + Compiler.ECLIPSE11 + } ) @ProcessorOption(name = "mapstruct.verbose", value = "true") @WithClasses(SelectBeanMapping.class) @ExpectedNote("^- MapStruct: creating bean mapping method implementation for.*$") @@ -91,7 +106,10 @@ public class VerboseTest { } @Test - @DisabledOnCompiler( Compiler.ECLIPSE ) + @DisabledOnCompiler( { + Compiler.ECLIPSE, + Compiler.ECLIPSE11 + } ) @ProcessorOption(name = "mapstruct.verbose", value = "true") @WithClasses(ValueMapping.class) @ExpectedNote("^- MapStruct: creating value mapping method implementation for.*$") @@ -99,7 +117,10 @@ public class VerboseTest { } @Test - @DisabledOnCompiler( Compiler.ECLIPSE ) + @DisabledOnCompiler( { + Compiler.ECLIPSE, + Compiler.ECLIPSE11 + } ) @ProcessorOption(name = "mapstruct.verbose", value = "true") @WithClasses(CreateIterableMapping.class) @ExpectedNote("^- MapStruct: creating iterable mapping method implementation for.*$") @@ -108,7 +129,10 @@ public class VerboseTest { } @Test - @DisabledOnCompiler( Compiler.ECLIPSE ) + @DisabledOnCompiler( { + Compiler.ECLIPSE, + Compiler.ECLIPSE11 + } ) @ProcessorOption(name = "mapstruct.verbose", value = "true") @WithClasses(SelectIterableMapping.class) @ExpectedNote("^- MapStruct: creating iterable mapping method implementation for.*$") @@ -117,7 +141,10 @@ public class VerboseTest { } @Test - @DisabledOnCompiler( Compiler.ECLIPSE ) + @DisabledOnCompiler( { + Compiler.ECLIPSE, + Compiler.ECLIPSE11 + } ) @ProcessorOption(name = "mapstruct.verbose", value = "true") @WithClasses(SelectStreamMapping.class) @ExpectedNote("^- MapStruct: creating stream mapping method implementation for.*$") @@ -125,7 +152,10 @@ public class VerboseTest { } @Test - @DisabledOnCompiler( Compiler.ECLIPSE ) + @DisabledOnCompiler( { + Compiler.ECLIPSE, + Compiler.ECLIPSE11 + } ) @ProcessorOption(name = "mapstruct.verbose", value = "true") @WithClasses(CreateMapMapping.class) @ExpectedNote("^- MapStruct: creating map mapping method implementation for.*$") @@ -135,7 +165,10 @@ public class VerboseTest { } @Test - @DisabledOnCompiler( Compiler.ECLIPSE ) + @DisabledOnCompiler( { + Compiler.ECLIPSE, + Compiler.ECLIPSE11 + } ) @ProcessorOption(name = "mapstruct.verbose", value = "true") @WithClasses(SelectMapMapping.class) @ExpectedNote("^- MapStruct: creating map mapping method implementation for.*$") diff --git a/processor/src/test/java/org/mapstruct/ap/testutil/runner/AnnotationProcessorTestRunner.java b/processor/src/test/java/org/mapstruct/ap/testutil/runner/AnnotationProcessorTestRunner.java index 6ddccf0eb..2891121af 100644 --- a/processor/src/test/java/org/mapstruct/ap/testutil/runner/AnnotationProcessorTestRunner.java +++ b/processor/src/test/java/org/mapstruct/ap/testutil/runner/AnnotationProcessorTestRunner.java @@ -74,7 +74,10 @@ public class AnnotationProcessorTestRunner extends ParentRunner { // Current tycho-compiler-jdt (0.26.0) is not compatible with Java 11 // Updating to latest version 1.3.0 fails some tests // Once https://github.com/mapstruct/mapstruct/pull/1587 is resolved we can remove this line - return Arrays.asList( new InnerAnnotationProcessorRunner( klass, Compiler.JDK11 ) ); + return Arrays.asList( + new InnerAnnotationProcessorRunner( klass, Compiler.JDK11 ), + new InnerAnnotationProcessorRunner( klass, Compiler.ECLIPSE11 ) + ); } return Arrays.asList( diff --git a/processor/src/test/java/org/mapstruct/ap/testutil/runner/Compiler.java b/processor/src/test/java/org/mapstruct/ap/testutil/runner/Compiler.java index d59a7ed0d..4b24bb091 100644 --- a/processor/src/test/java/org/mapstruct/ap/testutil/runner/Compiler.java +++ b/processor/src/test/java/org/mapstruct/ap/testutil/runner/Compiler.java @@ -10,5 +10,5 @@ package org.mapstruct.ap.testutil.runner; * */ public enum Compiler { - JDK, JDK11, ECLIPSE; + JDK, JDK11, ECLIPSE, ECLIPSE11; } diff --git a/processor/src/test/java/org/mapstruct/ap/testutil/runner/DisabledOnCompiler.java b/processor/src/test/java/org/mapstruct/ap/testutil/runner/DisabledOnCompiler.java index 41bcdb100..6fdfa3726 100644 --- a/processor/src/test/java/org/mapstruct/ap/testutil/runner/DisabledOnCompiler.java +++ b/processor/src/test/java/org/mapstruct/ap/testutil/runner/DisabledOnCompiler.java @@ -22,5 +22,5 @@ public @interface DisabledOnCompiler { /** * @return The compiler to use. */ - Compiler value(); + Compiler[] value(); } diff --git a/processor/src/test/java/org/mapstruct/ap/testutil/runner/EclipseCompilingStatement.java b/processor/src/test/java/org/mapstruct/ap/testutil/runner/EclipseCompilingStatement.java index a0617322e..4dac53538 100644 --- a/processor/src/test/java/org/mapstruct/ap/testutil/runner/EclipseCompilingStatement.java +++ b/processor/src/test/java/org/mapstruct/ap/testutil/runner/EclipseCompilingStatement.java @@ -9,6 +9,8 @@ import java.io.File; import java.util.List; import java.util.Set; +import javax.lang.model.SourceVersion; + import org.codehaus.plexus.compiler.CompilerConfiguration; import org.codehaus.plexus.compiler.CompilerException; import org.codehaus.plexus.compiler.CompilerResult; @@ -108,9 +110,10 @@ class EclipseCompilingStatement extends CompilingStatement { config.setGeneratedSourcesDirectory( new File( sourceOutputDir ) ); config.setAnnotationProcessors( new String[] { MappingProcessor.class.getName() } ); config.setSourceFiles( sourceFiles ); + String version = getSourceVersion(); config.setShowWarnings( false ); - config.setSourceVersion( "1.8" ); - config.setTargetVersion( "1.8" ); + config.setSourceVersion( version ); + config.setTargetVersion( version ); for ( String option : compilationRequest.getProcessorOptions() ) { config.addCompilerCustomArgument( option, null ); @@ -128,13 +131,22 @@ class EclipseCompilingStatement extends CompilingStatement { sourceDir, compilerResult ); } + + private static String getSourceVersion() { + SourceVersion latest = SourceVersion.latest(); + if ( latest == SourceVersion.RELEASE_8 ) { + return "1.8"; + } + return "11"; + } + } private static List buildEclipseCompilerClasspath() { String[] whitelist = new String[] { "tycho-compiler", - "org.eclipse.jdt.", + "ecj", "plexus-compiler-api", "plexus-component-annotations" }; diff --git a/processor/src/test/java/org/mapstruct/ap/testutil/runner/EnabledOnCompiler.java b/processor/src/test/java/org/mapstruct/ap/testutil/runner/EnabledOnCompiler.java index e297bd2c6..7c6d79e0f 100644 --- a/processor/src/test/java/org/mapstruct/ap/testutil/runner/EnabledOnCompiler.java +++ b/processor/src/test/java/org/mapstruct/ap/testutil/runner/EnabledOnCompiler.java @@ -22,5 +22,5 @@ public @interface EnabledOnCompiler { /** * @return The compiler to use. */ - Compiler value(); + Compiler[] value(); } diff --git a/processor/src/test/java/org/mapstruct/ap/testutil/runner/InnerAnnotationProcessorRunner.java b/processor/src/test/java/org/mapstruct/ap/testutil/runner/InnerAnnotationProcessorRunner.java index 4850a4870..50ab9c6eb 100644 --- a/processor/src/test/java/org/mapstruct/ap/testutil/runner/InnerAnnotationProcessorRunner.java +++ b/processor/src/test/java/org/mapstruct/ap/testutil/runner/InnerAnnotationProcessorRunner.java @@ -68,12 +68,20 @@ class InnerAnnotationProcessorRunner extends BlockJUnit4ClassRunner { protected boolean isIgnoredForCompiler(FrameworkMethod child) { EnabledOnCompiler enabledOnCompiler = child.getAnnotation( EnabledOnCompiler.class ); if ( enabledOnCompiler != null ) { - return enabledOnCompiler.value() != compiler; + for ( Compiler value : enabledOnCompiler.value() ) { + if ( value != compiler ) { + return true; + } + } } DisabledOnCompiler disabledOnCompiler = child.getAnnotation( DisabledOnCompiler.class ); if ( disabledOnCompiler != null ) { - return disabledOnCompiler.value() == compiler; + for ( Compiler value : disabledOnCompiler.value() ) { + if ( value == compiler ) { + return true; + } + } } return false;