From df09a723d2b646dbe1ccb59993bafdd94bffc28c Mon Sep 17 00:00:00 2001 From: Plamen Totev Date: Tue, 9 May 2017 20:07:54 +0300 Subject: [PATCH 1/3] Upgrade the minimum required Java version to Java 7 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 00cd5d12a..d37a0286a 100644 --- a/pom.xml +++ b/pom.xml @@ -166,8 +166,8 @@ maven-compiler-plugin - 1.6 - 1.6 + 1.7 + 1.7 From 5554a485e363bbb0e49a87241d9d1446d3e007fc Mon Sep 17 00:00:00 2001 From: Plamen Totev Date: Tue, 9 May 2017 22:59:12 +0300 Subject: [PATCH 2/3] Upgrade Plexus IO to 3.0.0 and clean-up legacy code It may seem that there are lot of changes but actually most of them are: * Rename `Java7FileAttributes` to `FileAttributes`. In the new version of Plexus IO `FileAttributes` is replaced by `Java7FileAttributes` * Remove calls to `Java7Reflector.isAtLeastJava7()`. `Java7Reflector` is deleted from the new version of Plexus IO because now at least Java 7 is required The most significant change is made inside `ArchiveEntryUtils#chmod` - now the Java version is at least 7 so together with the removal of the call to `Java7Reflector.isAtLeastJava7()` the legacy code is removed as well. Remove the `commons-io` dependency. Plexus IO 3.0.0 was updated to use `commons-io` 2.5 so there is no longer a need to override the transitive dependency. --- pom.xml | 8 +- .../plexus/archiver/AbstractArchiver.java | 3 +- .../PlexusIoBzip2ResourceCollection.java | 4 +- .../gzip/PlexusIoGzipResourceCollection.java | 4 +- .../PlexusIoVirtualFileResource.java | 12 +- .../PlexusIoSnappyResourceCollection.java | 4 +- .../archiver/util/ArchiveEntryUtils.java | 120 +----------------- .../xz/PlexusIoXZResourceCollection.java | 4 +- .../archiver/tar/TarFileAttributesTest.java | 20 +-- .../archiver/util/ArchiveEntryUtilsTest.java | 11 +- .../plexus/archiver/zip/ZipArchiverTest.java | 6 +- 11 files changed, 26 insertions(+), 170 deletions(-) diff --git a/pom.xml b/pom.xml index d37a0286a..fba9d7bfc 100644 --- a/pom.xml +++ b/pom.xml @@ -56,13 +56,7 @@ org.codehaus.plexus plexus-io - 2.7.1 - - - - commons-io - commons-io - 2.5 + 3.0.0 org.apache.commons diff --git a/src/main/java/org/codehaus/plexus/archiver/AbstractArchiver.java b/src/main/java/org/codehaus/plexus/archiver/AbstractArchiver.java index 272692ab7..dbcf07ec5 100755 --- a/src/main/java/org/codehaus/plexus/archiver/AbstractArchiver.java +++ b/src/main/java/org/codehaus/plexus/archiver/AbstractArchiver.java @@ -35,7 +35,6 @@ import org.codehaus.plexus.archiver.manager.ArchiverManager; import org.codehaus.plexus.archiver.manager.NoSuchArchiverException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.components.io.attributes.Java7Reflector; import org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributes; import org.codehaus.plexus.components.io.functions.ResourceAttributeSupplier; import org.codehaus.plexus.components.io.resources.AbstractPlexusIoResourceCollection; @@ -363,7 +362,7 @@ public void addFileSet( @Nonnull final FileSet fileSet ) private boolean isSymlinkSupported() { - return Os.isFamily( Os.FAMILY_UNIX ) && Java7Reflector.isAtLeastJava7(); + return Os.isFamily( Os.FAMILY_UNIX ); } @Override diff --git a/src/main/java/org/codehaus/plexus/archiver/bzip2/PlexusIoBzip2ResourceCollection.java b/src/main/java/org/codehaus/plexus/archiver/bzip2/PlexusIoBzip2ResourceCollection.java index 5babc4d50..112bee7ab 100644 --- a/src/main/java/org/codehaus/plexus/archiver/bzip2/PlexusIoBzip2ResourceCollection.java +++ b/src/main/java/org/codehaus/plexus/archiver/bzip2/PlexusIoBzip2ResourceCollection.java @@ -7,7 +7,7 @@ import java.util.HashMap; import javax.annotation.Nonnull; import javax.annotation.WillNotClose; -import org.codehaus.plexus.components.io.attributes.Java7FileAttributes; +import org.codehaus.plexus.components.io.attributes.FileAttributes; import org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributes; import org.codehaus.plexus.components.io.resources.PlexusIoCompressedFileResourceCollection; import org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection; @@ -42,7 +42,7 @@ InputStream getInputStream( File file ) @Override protected PlexusIoResourceAttributes getAttributes( File file ) throws IOException { - return new Java7FileAttributes( file, new HashMap(), new HashMap() ); + return new FileAttributes( file, new HashMap(), new HashMap() ); } @Override diff --git a/src/main/java/org/codehaus/plexus/archiver/gzip/PlexusIoGzipResourceCollection.java b/src/main/java/org/codehaus/plexus/archiver/gzip/PlexusIoGzipResourceCollection.java index ed9d3c6b9..78f072d87 100644 --- a/src/main/java/org/codehaus/plexus/archiver/gzip/PlexusIoGzipResourceCollection.java +++ b/src/main/java/org/codehaus/plexus/archiver/gzip/PlexusIoGzipResourceCollection.java @@ -8,7 +8,7 @@ import java.util.zip.GZIPInputStream; import javax.annotation.Nonnull; import org.codehaus.plexus.archiver.util.Streams; -import org.codehaus.plexus.components.io.attributes.Java7FileAttributes; +import org.codehaus.plexus.components.io.attributes.FileAttributes; import org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributes; import org.codehaus.plexus.components.io.resources.PlexusIoCompressedFileResourceCollection; import org.codehaus.plexus.util.IOUtil; @@ -49,7 +49,7 @@ protected InputStream getInputStream( File file ) protected PlexusIoResourceAttributes getAttributes( File file ) throws IOException { - return new Java7FileAttributes( file, new HashMap(), new HashMap() ); + return new FileAttributes( file, new HashMap(), new HashMap() ); } } diff --git a/src/main/java/org/codehaus/plexus/archiver/resources/PlexusIoVirtualFileResource.java b/src/main/java/org/codehaus/plexus/archiver/resources/PlexusIoVirtualFileResource.java index 7c87fd4b0..8eb3484c4 100644 --- a/src/main/java/org/codehaus/plexus/archiver/resources/PlexusIoVirtualFileResource.java +++ b/src/main/java/org/codehaus/plexus/archiver/resources/PlexusIoVirtualFileResource.java @@ -20,8 +20,7 @@ import java.io.InputStream; import java.net.URL; import javax.annotation.Nonnull; -import org.codehaus.plexus.components.io.attributes.Java7AttributeUtils; -import org.codehaus.plexus.components.io.attributes.Java7Reflector; +import org.codehaus.plexus.components.io.attributes.AttributeUtils; import org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributes; import org.codehaus.plexus.components.io.functions.ResourceAttributeSupplier; import org.codehaus.plexus.components.io.resources.AbstractPlexusIoResource; @@ -106,14 +105,7 @@ public long getLastModified() { if ( file.exists() ) { - if ( Java7Reflector.isAtLeastJava7() ) - { - return Java7AttributeUtils.getLastModified( getFile() ); - } - else - { - return getFile().lastModified(); - } + return AttributeUtils.getLastModified( getFile() ); } else { diff --git a/src/main/java/org/codehaus/plexus/archiver/snappy/PlexusIoSnappyResourceCollection.java b/src/main/java/org/codehaus/plexus/archiver/snappy/PlexusIoSnappyResourceCollection.java index c57cbd423..d6a6299bd 100644 --- a/src/main/java/org/codehaus/plexus/archiver/snappy/PlexusIoSnappyResourceCollection.java +++ b/src/main/java/org/codehaus/plexus/archiver/snappy/PlexusIoSnappyResourceCollection.java @@ -7,7 +7,7 @@ import java.util.HashMap; import javax.annotation.Nonnull; import javax.annotation.WillNotClose; -import org.codehaus.plexus.components.io.attributes.Java7FileAttributes; +import org.codehaus.plexus.components.io.attributes.FileAttributes; import org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributes; import org.codehaus.plexus.components.io.resources.PlexusIoCompressedFileResourceCollection; import org.codehaus.plexus.util.IOUtil; @@ -41,7 +41,7 @@ InputStream getInputStream( File file ) @Override protected PlexusIoResourceAttributes getAttributes( File file ) throws IOException { - return new Java7FileAttributes( file, new HashMap(), new HashMap() ); + return new FileAttributes( file, new HashMap(), new HashMap() ); } @Override diff --git a/src/main/java/org/codehaus/plexus/archiver/util/ArchiveEntryUtils.java b/src/main/java/org/codehaus/plexus/archiver/util/ArchiveEntryUtils.java index ae5d6ecd8..63d1548c9 100644 --- a/src/main/java/org/codehaus/plexus/archiver/util/ArchiveEntryUtils.java +++ b/src/main/java/org/codehaus/plexus/archiver/util/ArchiveEntryUtils.java @@ -17,15 +17,10 @@ import java.io.File; import java.io.IOException; -import java.lang.reflect.Method; import org.codehaus.plexus.archiver.ArchiverException; -import org.codehaus.plexus.components.io.attributes.Java7AttributeUtils; -import org.codehaus.plexus.components.io.attributes.Java7Reflector; +import org.codehaus.plexus.components.io.attributes.AttributeUtils; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.Os; -import org.codehaus.plexus.util.cli.CommandLineException; -import org.codehaus.plexus.util.cli.CommandLineUtils; -import org.codehaus.plexus.util.cli.Commandline; @SuppressWarnings( "JavaDoc" ) public final class ArchiveEntryUtils @@ -68,80 +63,14 @@ public static void chmod( final File file, final int mode, final Logger logger, return; } - if ( Java7Reflector.isAtLeastJava7() ) - { - try - { - Java7AttributeUtils.chmod( file, mode ); - return; - } - catch ( IOException e ) - { - throw new ArchiverException( "Failed setting file attributes with java7+", e ); - } - } - - final String m = Integer.toOctalString( mode & 0xfff ); - - if ( useJvmChmod && !jvmFilePermAvailable ) - { - useJvmChmod = false; - } - - if ( useJvmChmod ) - { - applyPermissionsWithJvm( file, m, logger ); - return; - } - try { - final Commandline commandline = new Commandline(); - - commandline.setWorkingDirectory( file.getParentFile().getAbsolutePath() ); - - if ( logger.isDebugEnabled() ) - { - logger.debug( file + ": mode " + Integer.toOctalString( mode ) + ", chmod " + m ); - } - - commandline.setExecutable( "chmod" ); - - commandline.createArg().setValue( m ); - - final String path = file.getAbsolutePath(); - - commandline.createArg().setValue( path ); - - // commenting this debug statement, since it can produce VERY verbose output... - // this method is called often during archive creation. - // logger.debug( "Executing:\n\n" + commandline.toString() + "\n\n" ); - final CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); - - final CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer(); - - final int exitCode = CommandLineUtils.executeCommandLine( commandline, stderr, stdout ); - - if ( exitCode != 0 ) - { - logger.warn( "-------------------------------" ); - logger.warn( "Standard error:" ); - logger.warn( "-------------------------------" ); - logger.warn( stderr.getOutput() ); - logger.warn( "-------------------------------" ); - logger.warn( "Standard output:" ); - logger.warn( "-------------------------------" ); - logger.warn( stdout.getOutput() ); - logger.warn( "-------------------------------" ); - - throw new ArchiverException( "chmod exit code was: " + exitCode ); - } + AttributeUtils.chmod( file, mode ); } - catch ( final CommandLineException e ) + catch ( IOException e ) { - throw new ArchiverException( "Error while executing chmod.", e ); + throw new ArchiverException( "Failed setting file attributes", e ); } - } /** @@ -159,45 +88,4 @@ public static void chmod( final File file, final int mode, final Logger logger ) chmod( file, mode, logger, Boolean.getBoolean( "useJvmChmod" ) && jvmFilePermAvailable ); } - private static void applyPermissionsWithJvm( final File file, final String mode, final Logger logger ) - throws ArchiverException - { - final FilePermission filePermission; - try - { - filePermission = FilePermissionUtils.getFilePermissionFromMode( mode, logger ); - } - catch ( IllegalArgumentException e ) - { - throw new ArchiverException( "Problem getting permission from mode for " + file.getPath(), e ); - } - - Method method; - try - { - method = File.class.getMethod( "setReadable", Boolean.TYPE, Boolean.TYPE ); - - method.invoke( file, - filePermission.isReadable(), - filePermission.isOwnerOnlyReadable() ); - - method = File.class.getMethod( "setExecutable", Boolean.TYPE, Boolean.TYPE ); - - method.invoke( file, - filePermission.isExecutable(), - filePermission.isOwnerOnlyExecutable() ); - - method = File.class.getMethod( "setWritable", Boolean.TYPE, Boolean.TYPE ); - - method.invoke( file, - filePermission.isWritable(), - filePermission.isOwnerOnlyWritable() ); - } - catch ( final Exception e ) - { - logger.error( "error calling dynamically file permissons with jvm " + e.getMessage(), e ); - throw new ArchiverException( "error calling dynamically file permissons with jvm " + e.getMessage(), e ); - } - } - } diff --git a/src/main/java/org/codehaus/plexus/archiver/xz/PlexusIoXZResourceCollection.java b/src/main/java/org/codehaus/plexus/archiver/xz/PlexusIoXZResourceCollection.java index b98df5fe5..e9c508e5b 100644 --- a/src/main/java/org/codehaus/plexus/archiver/xz/PlexusIoXZResourceCollection.java +++ b/src/main/java/org/codehaus/plexus/archiver/xz/PlexusIoXZResourceCollection.java @@ -20,7 +20,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.HashMap; -import org.codehaus.plexus.components.io.attributes.Java7FileAttributes; +import org.codehaus.plexus.components.io.attributes.FileAttributes; import org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributes; import org.codehaus.plexus.components.io.resources.PlexusIoCompressedFileResourceCollection; import org.codehaus.plexus.util.IOUtil; @@ -35,7 +35,7 @@ public class PlexusIoXZResourceCollection extends PlexusIoCompressedFileResource @Override protected PlexusIoResourceAttributes getAttributes( File file ) throws IOException { - return new Java7FileAttributes( file, new HashMap(), new HashMap() ); + return new FileAttributes( file, new HashMap(), new HashMap() ); } @Override diff --git a/src/test/java/org/codehaus/plexus/archiver/tar/TarFileAttributesTest.java b/src/test/java/org/codehaus/plexus/archiver/tar/TarFileAttributesTest.java index 03e3c4d8e..1e7ddf03f 100644 --- a/src/test/java/org/codehaus/plexus/archiver/tar/TarFileAttributesTest.java +++ b/src/test/java/org/codehaus/plexus/archiver/tar/TarFileAttributesTest.java @@ -9,7 +9,6 @@ import org.codehaus.plexus.archiver.Archiver; import org.codehaus.plexus.archiver.UnArchiver; import org.codehaus.plexus.archiver.util.DefaultArchivedFileSet; -import org.codehaus.plexus.components.io.attributes.Java7Reflector; import org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributeUtils; import org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributes; import org.codehaus.plexus.util.FileUtils; @@ -141,10 +140,7 @@ public void testUseAttributesFromTarArchiveInputInTarArchiverOutput() PlexusIoResourceAttributes fileAttributes = PlexusIoResourceAttributeUtils.getFileAttributes( new File( tempTarDir, tempFile.getName() ) ); - final int expected = Java7Reflector.isAtLeastJava7() ? 0660 : 0644; - - assertEquals( "This test will fail if your umask is not X2X (or more)", - expected, fileAttributes.getOctalMode() ); + assertEquals( 0660, fileAttributes.getOctalMode() ); } @@ -207,10 +203,7 @@ public void testUseDetectedFileAttributes() fileAttributes = PlexusIoResourceAttributeUtils.getFileAttributes( new File( tempTarDir, tempFile.getName() ) ); - final int expected = Java7Reflector.isAtLeastJava7() ? 0440 : 0444; - - assertEquals( "This test will fail if your umask is not X2X (or more)", - expected, fileAttributes.getOctalMode() ); + assertEquals( 0440, fileAttributes.getOctalMode() ); } @@ -275,10 +268,7 @@ public void testOverrideDetectedFileAttributes() PlexusIoResourceAttributes fileAttributes = PlexusIoResourceAttributeUtils.getFileAttributes( new File( tempTarDir, tempFile.getName() ) ); - final int expected = Java7Reflector.isAtLeastJava7() ? 0660 : 0644; - - assertEquals( "This test will fail if your umask is not X2X (or more)", - expected, fileAttributes.getOctalMode() ); + assertEquals( 0660, fileAttributes.getOctalMode() ); } @@ -345,9 +335,7 @@ public void testOverrideDetectedFileAttributesUsingFileMode() PlexusIoResourceAttributes fileAttributes = PlexusIoResourceAttributeUtils.getFileAttributes( new File( tempTarDir, tempFile.getName() ) ); - final int expected = Java7Reflector.isAtLeastJava7() ? 0660 : 0644; - assertEquals( "This test will fail if your umask is not X2X (or more)", - expected, fileAttributes.getOctalMode() ); + assertEquals( 0660, fileAttributes.getOctalMode() ); } diff --git a/src/test/java/org/codehaus/plexus/archiver/util/ArchiveEntryUtilsTest.java b/src/test/java/org/codehaus/plexus/archiver/util/ArchiveEntryUtilsTest.java index 4a03a758f..b09075f68 100644 --- a/src/test/java/org/codehaus/plexus/archiver/util/ArchiveEntryUtilsTest.java +++ b/src/test/java/org/codehaus/plexus/archiver/util/ArchiveEntryUtilsTest.java @@ -3,8 +3,7 @@ import java.io.File; import java.io.IOException; import java.util.HashMap; -import org.codehaus.plexus.components.io.attributes.Java7FileAttributes; -import org.codehaus.plexus.components.io.attributes.Java7Reflector; +import org.codehaus.plexus.components.io.attributes.FileAttributes; import org.codehaus.plexus.logging.console.ConsoleLogger; import org.codehaus.plexus.util.Os; import junit.framework.TestCase; @@ -27,10 +26,6 @@ public void testChmodForFileWithDollarPLXCOMP164() throws Exception public void testChmodWithJava7() throws Exception { - if ( !Java7Reflector.isAtLeastJava7() ) - { - return; // Require at least java7 - } if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) { return; @@ -44,8 +39,8 @@ public void testChmodWithJava7() throws Exception private void assert0770( File temp ) throws IOException { - Java7FileAttributes j7 = new Java7FileAttributes( temp, new HashMap(), - new HashMap() ); + FileAttributes j7 = new FileAttributes( temp, new HashMap(), + new HashMap() ); assertTrue( j7.isGroupExecutable() ); assertTrue( j7.isGroupReadable() ); assertTrue( j7.isGroupWritable() ); diff --git a/src/test/java/org/codehaus/plexus/archiver/zip/ZipArchiverTest.java b/src/test/java/org/codehaus/plexus/archiver/zip/ZipArchiverTest.java index 615e59226..df122d6c3 100644 --- a/src/test/java/org/codehaus/plexus/archiver/zip/ZipArchiverTest.java +++ b/src/test/java/org/codehaus/plexus/archiver/zip/ZipArchiverTest.java @@ -53,7 +53,7 @@ import org.codehaus.plexus.archiver.util.DefaultArchivedFileSet; import org.codehaus.plexus.archiver.util.DefaultFileSet; import org.codehaus.plexus.archiver.util.Streams; -import org.codehaus.plexus.components.io.attributes.Java7FileAttributes; +import org.codehaus.plexus.components.io.attributes.FileAttributes; import org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributeUtils; import org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributes; import org.codehaus.plexus.components.io.attributes.SimpleResourceAttributes; @@ -520,7 +520,7 @@ public void testSymlinkZip() zipUnArchiver.setDestFile( output ); zipUnArchiver.extract(); File symDir = new File( "target/output/unzipped/plexus/src/symDir" ); - PlexusIoResourceAttributes fa = Java7FileAttributes.uncached( symDir ); + PlexusIoResourceAttributes fa = FileAttributes.uncached( symDir ); assertTrue( fa.isSymbolicLink() ); } @@ -541,7 +541,7 @@ public void testSymlinkFileSet() zipUnArchiver.setDestFile( output ); zipUnArchiver.extract(); File symDir = new File( output, "bzz/symDir" ); - PlexusIoResourceAttributes fa = Java7FileAttributes.uncached( symDir ); + PlexusIoResourceAttributes fa = FileAttributes.uncached( symDir ); assertTrue( fa.isSymbolicLink() ); } From 7640802f55852931e88203347f8754d02a6d272d Mon Sep 17 00:00:00 2001 From: Plamen Totev Date: Tue, 9 May 2017 23:22:42 +0300 Subject: [PATCH 3/3] Deprecate useJvmChmod Prior to Java 7, the `chmod` command was used to change the files mode. `useJvmChmod` was a way to force the usage of the JVM instead of the external command. Now Java 7 is the minimum required version and no external commands are needed to change the files mode and useJvmChmod` is just ignored. Deprecate this setting so it can be removed from future versions. --- pom.xml | 9 --- .../plexus/archiver/AbstractUnArchiver.java | 2 +- .../codehaus/plexus/archiver/Archiver.java | 6 +- .../codehaus/plexus/archiver/UnArchiver.java | 4 ++ .../archiver/dir/DirectoryArchiver.java | 2 +- .../archiver/util/ArchiveEntryUtils.java | 62 ++++++++----------- .../jar/DirectoryArchiverUnpackJarTest.java | 14 ++--- .../plexus/archiver/tar/TarArchiverTest.java | 15 +---- .../archiver/util/ArchiveEntryUtilsTest.java | 7 +-- .../plexus/archiver/zip/ZipArchiverTest.java | 14 +---- 10 files changed, 45 insertions(+), 90 deletions(-) diff --git a/pom.xml b/pom.xml index fba9d7bfc..83c7aa888 100644 --- a/pom.xml +++ b/pom.xml @@ -24,10 +24,6 @@ https://github.com/codehaus-plexus/plexus-archiver/issues - - true - - Dan Tran @@ -108,11 +104,6 @@ org.apache.maven.plugins maven-surefire-plugin - - - ${useJvmChmod} - - org.apache.maven.plugins diff --git a/src/main/java/org/codehaus/plexus/archiver/AbstractUnArchiver.java b/src/main/java/org/codehaus/plexus/archiver/AbstractUnArchiver.java index f9035c8cb..bd462d93b 100644 --- a/src/main/java/org/codehaus/plexus/archiver/AbstractUnArchiver.java +++ b/src/main/java/org/codehaus/plexus/archiver/AbstractUnArchiver.java @@ -351,7 +351,7 @@ else if ( isDirectory ) if ( !isIgnorePermissions() && mode != null && !isDirectory ) { - ArchiveEntryUtils.chmod( f, mode, getLogger(), isUseJvmChmod() ); + ArchiveEntryUtils.chmod( f, mode ); } } catch ( final FileNotFoundException ex ) diff --git a/src/main/java/org/codehaus/plexus/archiver/Archiver.java b/src/main/java/org/codehaus/plexus/archiver/Archiver.java index 1dad07f02..c0735f971 100644 --- a/src/main/java/org/codehaus/plexus/archiver/Archiver.java +++ b/src/main/java/org/codehaus/plexus/archiver/Archiver.java @@ -366,20 +366,22 @@ ResourceIterator getResources() void setDuplicateBehavior( String duplicate ); /** - * For java7 and above, new java method will be used, regardless of this setting * to use or not the jvm method for file permissions : user all not active for group permissions * * @since 1.1 * @param useJvmChmod + * @deprecated this setting is now ignored. The jvm is always used. */ + @Deprecated void setUseJvmChmod( boolean useJvmChmod ); /** - * For java7 and above, new java method will be used, regardless of this setting * * @since 1.1 * @return + * @deprecated this setting is now ignored. The jvm is always used. */ + @Deprecated boolean isUseJvmChmod(); /** diff --git a/src/main/java/org/codehaus/plexus/archiver/UnArchiver.java b/src/main/java/org/codehaus/plexus/archiver/UnArchiver.java index 5afcfcfc5..7b6bc1f2e 100644 --- a/src/main/java/org/codehaus/plexus/archiver/UnArchiver.java +++ b/src/main/java/org/codehaus/plexus/archiver/UnArchiver.java @@ -89,13 +89,17 @@ void extract( String path, File outputDirectory ) * * @since 1.1 * @param useJvmChmod + * @deprecated this setting is now ignored. The jvm is always used. */ + @Deprecated void setUseJvmChmod( boolean useJvmChmod ); /** * @since 1.1 * @return + * @deprecated this setting is now ignored. The jvm is always used. */ + @Deprecated boolean isUseJvmChmod(); /** diff --git a/src/main/java/org/codehaus/plexus/archiver/dir/DirectoryArchiver.java b/src/main/java/org/codehaus/plexus/archiver/dir/DirectoryArchiver.java index fdb370a18..de280ef79 100644 --- a/src/main/java/org/codehaus/plexus/archiver/dir/DirectoryArchiver.java +++ b/src/main/java/org/codehaus/plexus/archiver/dir/DirectoryArchiver.java @@ -190,7 +190,7 @@ private void setFileModes( ArchiveEntry entry, File outFile, long inLastModified { if ( !isIgnorePermissions() ) { - ArchiveEntryUtils.chmod( outFile, entry.getMode(), getLogger(), isUseJvmChmod() ); + ArchiveEntryUtils.chmod( outFile, entry.getMode() ); } outFile.setLastModified( inLastModified == PlexusIoResource.UNKNOWN_MODIFICATION_DATE diff --git a/src/main/java/org/codehaus/plexus/archiver/util/ArchiveEntryUtils.java b/src/main/java/org/codehaus/plexus/archiver/util/ArchiveEntryUtils.java index 63d1548c9..9da66c94d 100644 --- a/src/main/java/org/codehaus/plexus/archiver/util/ArchiveEntryUtils.java +++ b/src/main/java/org/codehaus/plexus/archiver/util/ArchiveEntryUtils.java @@ -26,37 +26,42 @@ public final class ArchiveEntryUtils { - public static boolean jvmFilePermAvailable; - - static - { - try - { - jvmFilePermAvailable = File.class.getMethod( "setReadable", Boolean.TYPE ) != null; - } - catch ( final Exception e ) - { - // ignore exception log this ? - } - } - private ArchiveEntryUtils() { // no op } /** - * @since 1.1 - * @param file - * @param mode - * @param logger - * @param useJvmChmod - * will use jvm file permissions not available for group level + * This method is now deprecated. + * + * The {@code useJvmChmod} flag is ignored as the JVM is always used. + * The {@code logger} provided is no longer used. * - * @throws ArchiverException + * @deprecated Use {@link #chmod(File, int)} */ + @Deprecated public static void chmod( final File file, final int mode, final Logger logger, boolean useJvmChmod ) throws ArchiverException + { + chmod( file, mode ); + } + + /** + * This method is now deprecated. + * + * The {@code logger} provided is no longer used. + * + * @deprecated Use {@link #chmod(File, int)} + */ + @Deprecated + public static void chmod( final File file, final int mode, final Logger logger ) + throws ArchiverException + { + chmod( file, mode ); + } + + public static void chmod( final File file, final int mode ) + throws ArchiverException { if ( !Os.isFamily( Os.FAMILY_UNIX ) ) { @@ -73,19 +78,4 @@ public static void chmod( final File file, final int mode, final Logger logger, } } - /** - * jvm chmod will be used only if System property useJvmChmod set to true - * - * @param file - * @param mode - * @param logger - * - * @throws ArchiverException - */ - public static void chmod( final File file, final int mode, final Logger logger ) - throws ArchiverException - { - chmod( file, mode, logger, Boolean.getBoolean( "useJvmChmod" ) && jvmFilePermAvailable ); - } - } diff --git a/src/test/java/org/codehaus/plexus/archiver/jar/DirectoryArchiverUnpackJarTest.java b/src/test/java/org/codehaus/plexus/archiver/jar/DirectoryArchiverUnpackJarTest.java index e130f88cf..84a7a0d07 100644 --- a/src/test/java/org/codehaus/plexus/archiver/jar/DirectoryArchiverUnpackJarTest.java +++ b/src/test/java/org/codehaus/plexus/archiver/jar/DirectoryArchiverUnpackJarTest.java @@ -11,8 +11,6 @@ import org.codehaus.plexus.archiver.util.DefaultArchivedFileSet; import org.codehaus.plexus.components.io.functions.InputStreamTransformer; import org.codehaus.plexus.components.io.resources.PlexusIoResource; -import org.codehaus.plexus.logging.Logger; -import org.codehaus.plexus.logging.console.ConsoleLogger; public class DirectoryArchiverUnpackJarTest extends PlexusTestCase @@ -59,14 +57,12 @@ public void test_dependency_sets_depSet_unpacked_rdonly() archiver.createArchive(); assertTrue( new File( "target/depset_unpack/child-1/META-INF/MANIFEST.MF" ).exists() ); - final Logger logger = new ConsoleLogger( Logger.LEVEL_DEBUG, this.getClass().getName() ); - // make them writeable or mvn clean will fail - ArchiveEntryUtils.chmod( new File( "target/depset_unpack/child-1/META-INF" ), 0777, logger ); - ArchiveEntryUtils.chmod( new File( "target/depset_unpack/child-1/META-INF/maven" ), 0777, logger ); - ArchiveEntryUtils.chmod( new File( "target/depset_unpack/child-1/META-INF/maven/test" ), 0777, logger ); - ArchiveEntryUtils.chmod( new File( "target/depset_unpack/child-1/META-INF/maven/test/child1" ), 0777, logger ); - ArchiveEntryUtils.chmod( new File( "target/depset_unpack/child-1/assembly-resources" ), 0777, logger ); + ArchiveEntryUtils.chmod( new File( "target/depset_unpack/child-1/META-INF" ), 0777 ); + ArchiveEntryUtils.chmod( new File( "target/depset_unpack/child-1/META-INF/maven" ), 0777 ); + ArchiveEntryUtils.chmod( new File( "target/depset_unpack/child-1/META-INF/maven/test" ), 0777 ); + ArchiveEntryUtils.chmod( new File( "target/depset_unpack/child-1/META-INF/maven/test/child1" ), 0777 ); + ArchiveEntryUtils.chmod( new File( "target/depset_unpack/child-1/assembly-resources" ), 0777 ); } } diff --git a/src/test/java/org/codehaus/plexus/archiver/tar/TarArchiverTest.java b/src/test/java/org/codehaus/plexus/archiver/tar/TarArchiverTest.java index dc22486b0..060b62a86 100644 --- a/src/test/java/org/codehaus/plexus/archiver/tar/TarArchiverTest.java +++ b/src/test/java/org/codehaus/plexus/archiver/tar/TarArchiverTest.java @@ -45,8 +45,6 @@ import org.codehaus.plexus.archiver.zip.ArchiveFileComparator; import org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributeUtils; import org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributes; -import org.codehaus.plexus.logging.Logger; -import org.codehaus.plexus.logging.console.ConsoleLogger; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.Os; @@ -61,17 +59,6 @@ public class TarArchiverTest extends PlexusTestCase { - private Logger logger; - - @Override - public void setUp() - throws Exception - { - super.setUp(); - - logger = new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ); - } - public void testCreateArchiveWithDetectedModes() throws Exception { @@ -275,7 +262,7 @@ private void writeFile( File dir, String fname, int mode ) IOUtil.close( writer ); } - ArchiveEntryUtils.chmod( file, mode, logger, false ); + ArchiveEntryUtils.chmod( file, mode ); } public void testCreateArchive() diff --git a/src/test/java/org/codehaus/plexus/archiver/util/ArchiveEntryUtilsTest.java b/src/test/java/org/codehaus/plexus/archiver/util/ArchiveEntryUtilsTest.java index b09075f68..047779afe 100644 --- a/src/test/java/org/codehaus/plexus/archiver/util/ArchiveEntryUtilsTest.java +++ b/src/test/java/org/codehaus/plexus/archiver/util/ArchiveEntryUtilsTest.java @@ -4,7 +4,6 @@ import java.io.IOException; import java.util.HashMap; import org.codehaus.plexus.components.io.attributes.FileAttributes; -import org.codehaus.plexus.logging.console.ConsoleLogger; import org.codehaus.plexus.util.Os; import junit.framework.TestCase; @@ -19,8 +18,7 @@ public void testChmodForFileWithDollarPLXCOMP164() throws Exception return; } File temp = File.createTempFile( "A$A", "BB$" ); - ArchiveEntryUtils.chmod( temp, 0770, new ConsoleLogger( org.codehaus.plexus.logging.Logger.LEVEL_DEBUG, "foo" ), - false ); + ArchiveEntryUtils.chmod( temp, 0770 ); assert0770( temp ); } @@ -32,8 +30,7 @@ public void testChmodWithJava7() throws Exception } File temp = File.createTempFile( "D$D", "BB$" ); - ArchiveEntryUtils. - chmod( temp, 0770, new ConsoleLogger( org.codehaus.plexus.logging.Logger.LEVEL_DEBUG, "foo" ) ); + ArchiveEntryUtils.chmod( temp, 0770 ); assert0770( temp ); } diff --git a/src/test/java/org/codehaus/plexus/archiver/zip/ZipArchiverTest.java b/src/test/java/org/codehaus/plexus/archiver/zip/ZipArchiverTest.java index df122d6c3..197c5afe5 100644 --- a/src/test/java/org/codehaus/plexus/archiver/zip/ZipArchiverTest.java +++ b/src/test/java/org/codehaus/plexus/archiver/zip/ZipArchiverTest.java @@ -61,8 +61,6 @@ import org.codehaus.plexus.components.io.resources.PlexusIoFileResourceCollection; import org.codehaus.plexus.components.io.resources.PlexusIoResource; import org.codehaus.plexus.components.io.resources.ResourceFactory; -import org.codehaus.plexus.logging.Logger; -import org.codehaus.plexus.logging.console.ConsoleLogger; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.Os; @@ -75,16 +73,6 @@ public class ZipArchiverTest extends BasePlexusArchiverTest { - private Logger logger; - - public void setUp() - throws Exception - { - super.setUp(); - - logger = new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ); - } - public void testImplicitPermissions() throws IOException { @@ -342,7 +330,7 @@ private void writeFile( File dir, String fname, int mode ) IOUtil.close( writer ); } - ArchiveEntryUtils.chmod( file, mode, logger, false ); + ArchiveEntryUtils.chmod( file, mode ); } public void testCreateArchive()