diff --git a/pom.xml b/pom.xml index 4e1aee00..7256fb4a 100644 --- a/pom.xml +++ b/pom.xml @@ -148,7 +148,7 @@ junit junit - 4.11 + 4.13 test diff --git a/src/main/java/org/apache/maven/plugins/war/overlay/OverlayManager.java b/src/main/java/org/apache/maven/plugins/war/overlay/OverlayManager.java index 318ec686..cf83d5e2 100644 --- a/src/main/java/org/apache/maven/plugins/war/overlay/OverlayManager.java +++ b/src/main/java/org/apache/maven/plugins/war/overlay/OverlayManager.java @@ -23,13 +23,13 @@ import java.util.Arrays; import java.util.List; import java.util.ListIterator; +import java.util.Objects; import java.util.Set; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; import org.apache.maven.plugins.war.Overlay; import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.util.StringUtils; /** * Manages the overlays. @@ -222,12 +222,12 @@ Artifact getAssociatedArtifact( final Overlay overlay ) */ private boolean compareOverlayWithArtifact( Overlay overlay, Artifact artifact ) { - return ( StringUtils.equals( overlay.getGroupId(), artifact.getGroupId() ) - && StringUtils.equals( overlay.getArtifactId(), artifact.getArtifactId() ) - && StringUtils.equals( overlay.getType(), artifact.getType() ) + return ( Objects.equals( overlay.getGroupId(), artifact.getGroupId() ) + && Objects.equals( overlay.getArtifactId(), artifact.getArtifactId() ) + && Objects.equals( overlay.getType(), artifact.getType() ) // MWAR-241 Make sure to treat null and "" as equal when comparing the classifier - && StringUtils.equals( StringUtils.defaultString( overlay.getClassifier() ), - StringUtils.defaultString( artifact.getClassifier() ) ) ); + && Objects.equals( Objects.toString( overlay.getClassifier() ), + Objects.toString( artifact.getClassifier() ) ) ); } /** diff --git a/src/main/java/org/apache/maven/plugins/war/packaging/WarProjectPackagingTask.java b/src/main/java/org/apache/maven/plugins/war/packaging/WarProjectPackagingTask.java index cd7ff46b..59937062 100644 --- a/src/main/java/org/apache/maven/plugins/war/packaging/WarProjectPackagingTask.java +++ b/src/main/java/org/apache/maven/plugins/war/packaging/WarProjectPackagingTask.java @@ -21,6 +21,7 @@ import java.io.File; import java.io.IOException; +import java.util.Objects; import org.apache.maven.model.Resource; import org.apache.maven.plugin.MojoExecutionException; @@ -329,8 +330,8 @@ public void copyResources( WarPackagingContext context, Resource resource ) // MWAR-129 if targetPath is only a dot . or ./ // and the Resource is in a part of the warSourceDirectory the file from sources will override this // that's we don't have to add the targetPath yep not nice but works - if ( !StringUtils.equals( ".", resource.getTargetPath() ) - && !StringUtils.equals( "./", resource.getTargetPath() ) ) + if ( !Objects.equals( ".", resource.getTargetPath() ) + && !Objects.equals( "./", resource.getTargetPath() ) ) { targetFileName = resource.getTargetPath() + File.separator + targetFileName; } diff --git a/src/test/java/org/apache/maven/plugins/war/AbstractWarMojoTest.java b/src/test/java/org/apache/maven/plugins/war/AbstractWarMojoTest.java index 31116965..87344ad2 100644 --- a/src/test/java/org/apache/maven/plugins/war/AbstractWarMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/war/AbstractWarMojoTest.java @@ -308,8 +308,6 @@ protected void createArchive( final File directory, final File destinationFile ) Archiver archiver = new JarArchiver(); - archiver.setUseJvmChmod( true ); - archiver.setDestFile( destinationFile ); archiver.addDirectory( directory ); diff --git a/src/test/java/org/apache/maven/plugins/war/WarMojoTest.java b/src/test/java/org/apache/maven/plugins/war/WarMojoTest.java index 5696965b..7a313ec2 100644 --- a/src/test/java/org/apache/maven/plugins/war/WarMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/war/WarMojoTest.java @@ -500,37 +500,36 @@ protected Map assertJarContent( final File expectedJarFile, fi assertTrue( "war file not created: " + expectedJarFile.toString(), expectedJarFile.exists() ); final Map jarContent = new HashMap<>(); - final JarFile jarFile = new JarFile( expectedJarFile ); - - JarEntry entry; - Enumeration enumeration = jarFile.entries(); - while ( enumeration.hasMoreElements() ) - { - entry = enumeration.nextElement(); - Object previousValue = jarContent.put( entry.getName(), entry ); - assertNull( "Duplicate Entry in Jar File: " + entry.getName(), previousValue ); - } - - for ( int i = 0; i < files.length; i++ ) - { - String file = files[i]; - - assertTrue( "File[" + file + "] not found in archive", jarContent.containsKey( file ) ); - if ( filesContent[i] != null ) + try ( JarFile jarFile = new JarFile( expectedJarFile ) ) { + Enumeration enumeration = jarFile.entries(); + while ( enumeration.hasMoreElements() ) { - assertEquals( "Content of file[" + file + "] does not match", filesContent[i], - IOUtil.toString( jarFile.getInputStream( jarContent.get( file ) ) ) ); + JarEntry entry = enumeration.nextElement(); + Object previousValue = jarContent.put( entry.getName(), entry ); + assertNull( "Duplicate Entry in Jar File: " + entry.getName(), previousValue ); } - } - if ( mustNotBeInJar != null ) - { - for ( String file : mustNotBeInJar ) + + for ( int i = 0; i < files.length; i++ ) { - assertFalse( "File[" + file + "] found in archive", jarContent.containsKey( file ) ); - + String file = files[i]; + + assertTrue( "File[" + file + "] not found in archive", jarContent.containsKey( file ) ); + if ( filesContent[i] != null ) + { + assertEquals( "Content of file[" + file + "] does not match", filesContent[i], + IOUtil.toString( jarFile.getInputStream( jarContent.get( file ) ) ) ); + } + } + if ( mustNotBeInJar != null ) + { + for ( String file : mustNotBeInJar ) + { + assertFalse( "File[" + file + "] found in archive", jarContent.containsKey( file ) ); + + } } + return jarContent; } - return jarContent; } } diff --git a/src/test/java/org/apache/maven/plugins/war/util/PathSetTest.java b/src/test/java/org/apache/maven/plugins/war/util/PathSetTest.java index 2ccfc6bd..6375109e 100644 --- a/src/test/java/org/apache/maven/plugins/war/util/PathSetTest.java +++ b/src/test/java/org/apache/maven/plugins/war/util/PathSetTest.java @@ -26,7 +26,6 @@ import java.io.File; import java.io.IOException; -import java.nio.file.Path; import java.util.HashSet; import java.util.Iterator; import java.util.Set;