Dependency upgrades

Upgrades:
* Maven Enforcer Plugin to 3.0.0-M3
* Maven Surefire Plugin to 3.0.0-M5
* Maven Checkstyle Plugin to 3.1.1
* Maven Bundle Plugin to 5.1.1
* Jacoco Maven Plugin to 0.8.6
* Checkstyle to 8.36.1
* JUnit Jipiter to 5.7.0
* AssertJ to 3.17.2
* Guava to 29.0-jre

Fix AssertJ breaking changes
Use Java 8 or Apache Commons IO instead of Guava where possible
Update GitHub Actions to use JDK 14 and JDK 15-ea
This commit is contained in:
Filip Hrisafov 2020-09-20 11:06:33 +02:00
parent 52ab22bbd8
commit e17e744b20
11 changed files with 31 additions and 39 deletions

View File

@ -7,7 +7,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
java: [15-ea] java: [16-ea]
name: 'Linux JDK ${{ matrix.java }}' name: 'Linux JDK ${{ matrix.java }}'
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:

View File

@ -11,7 +11,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
java: [11, 13, 14] java: [11, 13, 15]
name: 'Linux JDK ${{ matrix.java }}' name: 'Linux JDK ${{ matrix.java }}'
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:

View File

@ -22,17 +22,16 @@
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<org.mapstruct.gem.version>1.0.0.Alpha2</org.mapstruct.gem.version> <org.mapstruct.gem.version>1.0.0.Alpha2</org.mapstruct.gem.version>
<!-- We can't go to 3.0.0-M2 as it has a regression. See https://issues.apache.org/jira/browse/MENFORCER-306 --> <org.apache.maven.plugins.enforcer.version>3.0.0-M3</org.apache.maven.plugins.enforcer.version>
<org.apache.maven.plugins.enforcer.version>3.0.0-M1</org.apache.maven.plugins.enforcer.version> <org.apache.maven.plugins.surefire.version>3.0.0-M5</org.apache.maven.plugins.surefire.version>
<org.apache.maven.plugins.surefire.version>3.0.0-M3</org.apache.maven.plugins.surefire.version>
<org.apache.maven.plugins.javadoc.version>3.1.0</org.apache.maven.plugins.javadoc.version> <org.apache.maven.plugins.javadoc.version>3.1.0</org.apache.maven.plugins.javadoc.version>
<org.springframework.version>4.0.3.RELEASE</org.springframework.version> <org.springframework.version>4.0.3.RELEASE</org.springframework.version>
<org.eclipse.tycho.compiler-jdt.version>1.6.0</org.eclipse.tycho.compiler-jdt.version> <org.eclipse.tycho.compiler-jdt.version>1.6.0</org.eclipse.tycho.compiler-jdt.version>
<com.puppycrawl.tools.checkstyle.version>8.29</com.puppycrawl.tools.checkstyle.version> <com.puppycrawl.tools.checkstyle.version>8.36.1</com.puppycrawl.tools.checkstyle.version>
<org.junit.jupiter.version>5.6.0</org.junit.jupiter.version> <org.junit.jupiter.version>5.7.0</org.junit.jupiter.version>
<add.release.arguments /> <add.release.arguments />
<forkCount>1</forkCount> <forkCount>1</forkCount>
<assertj.version>3.11.1</assertj.version> <assertj.version>3.17.2</assertj.version>
<!-- automatically run annotation processors within the incremental compilation --> <!-- automatically run annotation processors within the incremental compilation -->
<!-- Needed for the hickory processor--> <!-- Needed for the hickory processor-->
<m2e.apt.activation>jdt_apt</m2e.apt.activation> <m2e.apt.activation>jdt_apt</m2e.apt.activation>
@ -112,7 +111,7 @@
<dependency> <dependency>
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
<version>19.0</version> <version>29.0-jre</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mapstruct.tools.gem</groupId> <groupId>org.mapstruct.tools.gem</groupId>
@ -307,7 +306,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId> <artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.0</version> <version>3.1.1</version>
<configuration> <configuration>
<configLocation>build-config/checkstyle.xml</configLocation> <configLocation>build-config/checkstyle.xml</configLocation>
<consoleOutput>true</consoleOutput> <consoleOutput>true</consoleOutput>
@ -383,7 +382,7 @@
<plugin> <plugin>
<groupId>org.apache.felix</groupId> <groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId> <artifactId>maven-bundle-plugin</artifactId>
<version>4.0.0</version> <version>5.1.1</version>
<executions> <executions>
<execution> <execution>
<id>bundle-manifest</id> <id>bundle-manifest</id>
@ -529,7 +528,7 @@
<plugin> <plugin>
<groupId>org.jacoco</groupId> <groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId> <artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.5</version> <version>0.8.6</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId> <groupId>org.jvnet.jaxb2.maven2</groupId>

View File

@ -14,7 +14,6 @@ import org.mapstruct.ap.testutil.WithClasses;
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner; import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.atIndex;
/** /**
* @author Filip Hrisafov * @author Filip Hrisafov
@ -34,9 +33,8 @@ public class Issue1338Test {
source.setProperties( Arrays.asList( "first", "second" ) ); source.setProperties( Arrays.asList( "first", "second" ) );
Target target = Issue1338Mapper.INSTANCE.map( source ); Target target = Issue1338Mapper.INSTANCE.map( source );
assertThat( target ) assertThat( target.getProperties() )
.extracting( "properties" ) .containsExactly( "first", "second" );
.contains( Arrays.asList( "first", "second" ), atIndex( 0 ) );
Source mapped = Issue1338Mapper.INSTANCE.map( target ); Source mapped = Issue1338Mapper.INSTANCE.map( target );

View File

@ -15,7 +15,7 @@ import org.mapstruct.ap.testutil.WithClasses;
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner; import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.atIndex; import static org.assertj.core.api.InstanceOfAssertFactories.ITERABLE;
/** /**
* @author Filip Hrisafov * @author Filip Hrisafov
@ -33,14 +33,14 @@ public class Issue1359Test {
public void shouldCompile() { public void shouldCompile() {
Target target = new Target(); Target target = new Target();
assertThat( target ).extracting( "properties" ).contains( null, atIndex( 0 ) ); assertThat( target ).extracting( "properties" ).isNull();
Set<String> properties = new HashSet<>(); Set<String> properties = new HashSet<>();
properties.add( "first" ); properties.add( "first" );
Source source = new Source( properties ); Source source = new Source( properties );
Issue1359Mapper.INSTANCE.map( target, source ); Issue1359Mapper.INSTANCE.map( target, source );
assertThat( target ).extracting( "properties" ).contains( properties, atIndex( 0 ) ); assertThat( target ).extracting( "properties", ITERABLE ).containsExactly( "first" );
} }
} }

View File

@ -32,6 +32,6 @@ public class Issue895Test {
assertThat( listOfByteArray.getBytes() ).containsExactly( new byte[] { 0, 1 }, new byte[] { 1, 2 } ); assertThat( listOfByteArray.getBytes() ).containsExactly( new byte[] { 0, 1 }, new byte[] { 1, 2 } );
arrayOfByteArray = Mappers.getMapper( MultiArrayMapper.class ).convert( listOfByteArray ); arrayOfByteArray = Mappers.getMapper( MultiArrayMapper.class ).convert( listOfByteArray );
assertThat( arrayOfByteArray.getBytes() ).containsExactly( new byte[] { 0, 1 }, new byte[] { 1, 2 } ); assertThat( arrayOfByteArray.getBytes() ).isDeepEqualTo( new byte[][] { { 0, 1 }, { 1, 2 } } );
} }
} }

View File

@ -5,7 +5,7 @@
*/ */
package org.mapstruct.ap.test.builder.nestedprop.expanding; package org.mapstruct.ap.test.builder.nestedprop.expanding;
import static com.google.common.base.Preconditions.checkNotNull; import static java.util.Objects.requireNonNull;
public class FlattenedStock { public class FlattenedStock {
private String article1; private String article1;
@ -16,8 +16,8 @@ public class FlattenedStock {
} }
public FlattenedStock(String article1, String article2, int count) { public FlattenedStock(String article1, String article2, int count) {
this.article1 = checkNotNull( article1 ); this.article1 = requireNonNull( article1 );
this.article2 = checkNotNull( article2 ); this.article2 = requireNonNull( article2 );
this.count = count; this.count = count;
} }

View File

@ -8,14 +8,12 @@ package org.mapstruct.ap.test.collection;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
public class Target { public class Target {
//CHECKSTYLE:OFF //CHECKSTYLE:OFF
@ -54,10 +52,11 @@ public class Target {
private StringHolderToLongMap nonGenericMapStringtoLong; private StringHolderToLongMap nonGenericMapStringtoLong;
public Target() { public Target() {
otherStringLongMap = Maps.newHashMap(); otherStringLongMap = new HashMap<>();
otherStringLongMap.put( "not-present-after-mapping", 42L ); otherStringLongMap.put( "not-present-after-mapping", 42L );
otherStringList = Lists.newArrayList( "not-present-after-mapping" ); otherStringList = new ArrayList<>();
otherStringList.add( "not-present-after-mapping" );
} }
public List<String> getStringList() { public List<String> getStringList() {

View File

@ -8,12 +8,10 @@ package org.mapstruct.ap.test.collection.iterabletononiterable;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import com.google.common.base.Joiner;
public class StringListMapper { public class StringListMapper {
public String stringListToString(List<String> strings) { public String stringListToString(List<String> strings) {
return strings == null ? null : Joiner.on( "-" ).join( strings ); return strings == null ? null : String.join( "-", strings );
} }
public List<String> stringToStringList(String string) { public List<String> stringToStringList(String string) {

View File

@ -15,6 +15,7 @@ import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.io.FileUtils;
import org.assertj.core.api.AbstractCharSequenceAssert; import org.assertj.core.api.AbstractCharSequenceAssert;
import org.assertj.core.api.Assertions; import org.assertj.core.api.Assertions;
import org.assertj.core.api.FileAssert; import org.assertj.core.api.FileAssert;
@ -23,9 +24,6 @@ import org.assertj.core.internal.Diff;
import org.assertj.core.internal.Failures; import org.assertj.core.internal.Failures;
import org.assertj.core.util.diff.Delta; import org.assertj.core.util.diff.Delta;
import com.google.common.base.Charsets;
import com.google.common.io.Files;
/** /**
* Allows to perform assertions on .java source files. * Allows to perform assertions on .java source files.
* *
@ -58,7 +56,7 @@ public class JavaFileAssert extends FileAssert {
isFile(); isFile();
try { try {
return Assertions.assertThat( Files.toString( actual, Charsets.UTF_8 ) ); return Assertions.assertThat( FileUtils.readFileToString( actual, StandardCharsets.UTF_8 ) );
} }
catch ( IOException e ) { catch ( IOException e ) {
failWithMessage( "Unable to read" + actual.toString() + ". Exception: " + e.getMessage() ); failWithMessage( "Unable to read" + actual.toString() + ". Exception: " + e.getMessage() );

View File

@ -19,6 +19,7 @@ import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
@ -26,6 +27,7 @@ import java.util.Set;
import java.util.stream.Stream; import java.util.stream.Stream;
import com.puppycrawl.tools.checkstyle.api.AutomaticBean; import com.puppycrawl.tools.checkstyle.api.AutomaticBean;
import org.apache.commons.io.output.NullOutputStream;
import org.junit.runners.model.FrameworkMethod; import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.Statement; import org.junit.runners.model.Statement;
import org.mapstruct.ap.testutil.WithClasses; import org.mapstruct.ap.testutil.WithClasses;
@ -41,8 +43,6 @@ import org.mapstruct.ap.testutil.compilation.model.CompilationOutcomeDescriptor;
import org.mapstruct.ap.testutil.compilation.model.DiagnosticDescriptor; import org.mapstruct.ap.testutil.compilation.model.DiagnosticDescriptor;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
import com.google.common.collect.Lists;
import com.google.common.io.ByteStreams;
import com.puppycrawl.tools.checkstyle.Checker; import com.puppycrawl.tools.checkstyle.Checker;
import com.puppycrawl.tools.checkstyle.ConfigurationLoader; import com.puppycrawl.tools.checkstyle.ConfigurationLoader;
import com.puppycrawl.tools.checkstyle.DefaultLogger; import com.puppycrawl.tools.checkstyle.DefaultLogger;
@ -217,7 +217,7 @@ abstract class CompilingStatement extends Statement {
ByteArrayOutputStream errorStream = new ByteArrayOutputStream(); ByteArrayOutputStream errorStream = new ByteArrayOutputStream();
checker.addListener( checker.addListener(
new DefaultLogger( new DefaultLogger(
ByteStreams.nullOutputStream(), NullOutputStream.NULL_OUTPUT_STREAM,
AutomaticBean.OutputStreamOptions.CLOSE, AutomaticBean.OutputStreamOptions.CLOSE,
errorStream, errorStream,
AutomaticBean.OutputStreamOptions.CLOSE AutomaticBean.OutputStreamOptions.CLOSE
@ -234,7 +234,7 @@ abstract class CompilingStatement extends Statement {
} }
private static List<File> findGeneratedFiles(File file) { private static List<File> findGeneratedFiles(File file) {
final List<File> files = Lists.newLinkedList(); final List<File> files = new LinkedList<>();
if ( file.canRead() ) { if ( file.canRead() ) {
if ( file.isDirectory() ) { if ( file.isDirectory() ) {