diff --git a/pom.xml b/pom.xml index 00cd5d12a..83c7aa888 100644 --- a/pom.xml +++ b/pom.xml @@ -24,10 +24,6 @@ https://github.com/codehaus-plexus/plexus-archiver/issues - - true - - Dan Tran @@ -56,13 +52,7 @@ org.codehaus.plexus plexus-io - 2.7.1 - - - - commons-io - commons-io - 2.5 + 3.0.0 org.apache.commons @@ -114,11 +104,6 @@ org.apache.maven.plugins maven-surefire-plugin - - - ${useJvmChmod} - - org.apache.maven.plugins @@ -166,8 +151,8 @@ maven-compiler-plugin - 1.6 - 1.6 + 1.7 + 1.7 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/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/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/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/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..9da66c94d 100644 --- a/src/main/java/org/codehaus/plexus/archiver/util/ArchiveEntryUtils.java +++ b/src/main/java/org/codehaus/plexus/archiver/util/ArchiveEntryUtils.java @@ -17,186 +17,64 @@ 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 { - 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. * - * @throws ArchiverException + * The {@code useJvmChmod} flag is ignored as the JVM is always used. + * 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, boolean useJvmChmod ) throws ArchiverException { - if ( !Os.isFamily( Os.FAMILY_UNIX ) ) - { - 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 ); - } - } - catch ( final CommandLineException e ) - { - throw new ArchiverException( "Error while executing chmod.", e ); - } - + chmod( file, mode ); } /** - * jvm chmod will be used only if System property useJvmChmod set to true + * This method is now deprecated. * - * @param file - * @param mode - * @param logger + * 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 ) throws ArchiverException { - chmod( file, mode, logger, Boolean.getBoolean( "useJvmChmod" ) && jvmFilePermAvailable ); + chmod( file, mode ); } - private static void applyPermissionsWithJvm( final File file, final String mode, final Logger logger ) + public static void chmod( final File file, final int mode ) throws ArchiverException { - final FilePermission filePermission; - try - { - filePermission = FilePermissionUtils.getFilePermissionFromMode( mode, logger ); - } - catch ( IllegalArgumentException e ) + if ( !Os.isFamily( Os.FAMILY_UNIX ) ) { - throw new ArchiverException( "Problem getting permission from mode for " + file.getPath(), e ); + return; } - 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() ); + AttributeUtils.chmod( file, mode ); } - catch ( final Exception e ) + catch ( IOException 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 ); + throw new ArchiverException( "Failed setting file attributes", 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/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/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..047779afe 100644 --- a/src/test/java/org/codehaus/plexus/archiver/util/ArchiveEntryUtilsTest.java +++ b/src/test/java/org/codehaus/plexus/archiver/util/ArchiveEntryUtilsTest.java @@ -3,9 +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.logging.console.ConsoleLogger; +import org.codehaus.plexus.components.io.attributes.FileAttributes; import org.codehaus.plexus.util.Os; import junit.framework.TestCase; @@ -20,32 +18,26 @@ 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 ); } public void testChmodWithJava7() throws Exception { - if ( !Java7Reflector.isAtLeastJava7() ) - { - return; // Require at least java7 - } if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) { return; } 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 ); } 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..197c5afe5 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; @@ -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() @@ -520,7 +508,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 +529,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() ); }