Skip to content

Commit a8b8831

Browse files
plamentotevmichael-o
authored andcommitted
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.
1 parent 6151890 commit a8b8831

File tree

10 files changed

+45
-90
lines changed

10 files changed

+45
-90
lines changed

Diff for: pom.xml

-9
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424
<url>https://github.com/codehaus-plexus/plexus-archiver/issues</url>
2525
</issueManagement>
2626

27-
<properties>
28-
<useJvmChmod>true</useJvmChmod>
29-
</properties>
30-
3127
<contributors>
3228
<contributor>
3329
<name>Dan Tran</name>
@@ -108,11 +104,6 @@
108104
<plugin>
109105
<groupId>org.apache.maven.plugins</groupId>
110106
<artifactId>maven-surefire-plugin</artifactId>
111-
<configuration>
112-
<systemPropertyVariables>
113-
<useJvmChmod>${useJvmChmod}</useJvmChmod>
114-
</systemPropertyVariables>
115-
</configuration>
116107
</plugin>
117108
<plugin>
118109
<groupId>org.apache.maven.plugins</groupId>

Diff for: src/main/java/org/codehaus/plexus/archiver/AbstractUnArchiver.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ else if ( isDirectory )
351351

352352
if ( !isIgnorePermissions() && mode != null && !isDirectory )
353353
{
354-
ArchiveEntryUtils.chmod( f, mode, getLogger(), isUseJvmChmod() );
354+
ArchiveEntryUtils.chmod( f, mode );
355355
}
356356
}
357357
catch ( final FileNotFoundException ex )

Diff for: src/main/java/org/codehaus/plexus/archiver/Archiver.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -366,20 +366,22 @@ ResourceIterator getResources()
366366
void setDuplicateBehavior( String duplicate );
367367

368368
/**
369-
* For java7 and above, new java method will be used, regardless of this setting
370369
* to use or not the jvm method for file permissions : user all <b>not active for group permissions</b>
371370
*
372371
* @since 1.1
373372
* @param useJvmChmod
373+
* @deprecated this setting is now ignored. The jvm is always used.
374374
*/
375+
@Deprecated
375376
void setUseJvmChmod( boolean useJvmChmod );
376377

377378
/**
378-
* For java7 and above, new java method will be used, regardless of this setting
379379
*
380380
* @since 1.1
381381
* @return
382+
* @deprecated this setting is now ignored. The jvm is always used.
382383
*/
384+
@Deprecated
383385
boolean isUseJvmChmod();
384386

385387
/**

Diff for: src/main/java/org/codehaus/plexus/archiver/UnArchiver.java

+4
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,17 @@ void extract( String path, File outputDirectory )
8989
*
9090
* @since 1.1
9191
* @param useJvmChmod
92+
* @deprecated this setting is now ignored. The jvm is always used.
9293
*/
94+
@Deprecated
9395
void setUseJvmChmod( boolean useJvmChmod );
9496

9597
/**
9698
* @since 1.1
9799
* @return
100+
* @deprecated this setting is now ignored. The jvm is always used.
98101
*/
102+
@Deprecated
99103
boolean isUseJvmChmod();
100104

101105
/**

Diff for: src/main/java/org/codehaus/plexus/archiver/dir/DirectoryArchiver.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ private void setFileModes( ArchiveEntry entry, File outFile, long inLastModified
190190
{
191191
if ( !isIgnorePermissions() )
192192
{
193-
ArchiveEntryUtils.chmod( outFile, entry.getMode(), getLogger(), isUseJvmChmod() );
193+
ArchiveEntryUtils.chmod( outFile, entry.getMode() );
194194
}
195195

196196
outFile.setLastModified( inLastModified == PlexusIoResource.UNKNOWN_MODIFICATION_DATE

Diff for: src/main/java/org/codehaus/plexus/archiver/util/ArchiveEntryUtils.java

+26-36
Original file line numberDiff line numberDiff line change
@@ -26,37 +26,42 @@
2626
public final class ArchiveEntryUtils
2727
{
2828

29-
public static boolean jvmFilePermAvailable;
30-
31-
static
32-
{
33-
try
34-
{
35-
jvmFilePermAvailable = File.class.getMethod( "setReadable", Boolean.TYPE ) != null;
36-
}
37-
catch ( final Exception e )
38-
{
39-
// ignore exception log this ?
40-
}
41-
}
42-
4329
private ArchiveEntryUtils()
4430
{
4531
// no op
4632
}
4733

4834
/**
49-
* @since 1.1
50-
* @param file
51-
* @param mode
52-
* @param logger
53-
* @param useJvmChmod
54-
* will use jvm file permissions <b>not available for group level</b>
35+
* This method is now deprecated.
36+
*
37+
* The {@code useJvmChmod} flag is ignored as the JVM is always used.
38+
* The {@code logger} provided is no longer used.
5539
*
56-
* @throws ArchiverException
40+
* @deprecated Use {@link #chmod(File, int)}
5741
*/
42+
@Deprecated
5843
public static void chmod( final File file, final int mode, final Logger logger, boolean useJvmChmod )
5944
throws ArchiverException
45+
{
46+
chmod( file, mode );
47+
}
48+
49+
/**
50+
* This method is now deprecated.
51+
*
52+
* The {@code logger} provided is no longer used.
53+
*
54+
* @deprecated Use {@link #chmod(File, int)}
55+
*/
56+
@Deprecated
57+
public static void chmod( final File file, final int mode, final Logger logger )
58+
throws ArchiverException
59+
{
60+
chmod( file, mode );
61+
}
62+
63+
public static void chmod( final File file, final int mode )
64+
throws ArchiverException
6065
{
6166
if ( !Os.isFamily( Os.FAMILY_UNIX ) )
6267
{
@@ -73,19 +78,4 @@ public static void chmod( final File file, final int mode, final Logger logger,
7378
}
7479
}
7580

76-
/**
77-
* <b>jvm chmod will be used only if System property <code>useJvmChmod</code> set to true</b>
78-
*
79-
* @param file
80-
* @param mode
81-
* @param logger
82-
*
83-
* @throws ArchiverException
84-
*/
85-
public static void chmod( final File file, final int mode, final Logger logger )
86-
throws ArchiverException
87-
{
88-
chmod( file, mode, logger, Boolean.getBoolean( "useJvmChmod" ) && jvmFilePermAvailable );
89-
}
90-
9181
}

Diff for: src/test/java/org/codehaus/plexus/archiver/jar/DirectoryArchiverUnpackJarTest.java

+5-9
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
import org.codehaus.plexus.archiver.util.DefaultArchivedFileSet;
1212
import org.codehaus.plexus.components.io.functions.InputStreamTransformer;
1313
import org.codehaus.plexus.components.io.resources.PlexusIoResource;
14-
import org.codehaus.plexus.logging.Logger;
15-
import org.codehaus.plexus.logging.console.ConsoleLogger;
1614

1715
public class DirectoryArchiverUnpackJarTest
1816
extends PlexusTestCase
@@ -59,14 +57,12 @@ public void test_dependency_sets_depSet_unpacked_rdonly()
5957
archiver.createArchive();
6058
assertTrue( new File( "target/depset_unpack/child-1/META-INF/MANIFEST.MF" ).exists() );
6159

62-
final Logger logger = new ConsoleLogger( Logger.LEVEL_DEBUG, this.getClass().getName() );
63-
6460
// make them writeable or mvn clean will fail
65-
ArchiveEntryUtils.chmod( new File( "target/depset_unpack/child-1/META-INF" ), 0777, logger );
66-
ArchiveEntryUtils.chmod( new File( "target/depset_unpack/child-1/META-INF/maven" ), 0777, logger );
67-
ArchiveEntryUtils.chmod( new File( "target/depset_unpack/child-1/META-INF/maven/test" ), 0777, logger );
68-
ArchiveEntryUtils.chmod( new File( "target/depset_unpack/child-1/META-INF/maven/test/child1" ), 0777, logger );
69-
ArchiveEntryUtils.chmod( new File( "target/depset_unpack/child-1/assembly-resources" ), 0777, logger );
61+
ArchiveEntryUtils.chmod( new File( "target/depset_unpack/child-1/META-INF" ), 0777 );
62+
ArchiveEntryUtils.chmod( new File( "target/depset_unpack/child-1/META-INF/maven" ), 0777 );
63+
ArchiveEntryUtils.chmod( new File( "target/depset_unpack/child-1/META-INF/maven/test" ), 0777 );
64+
ArchiveEntryUtils.chmod( new File( "target/depset_unpack/child-1/META-INF/maven/test/child1" ), 0777 );
65+
ArchiveEntryUtils.chmod( new File( "target/depset_unpack/child-1/assembly-resources" ), 0777 );
7066
}
7167

7268
}

Diff for: src/test/java/org/codehaus/plexus/archiver/tar/TarArchiverTest.java

+1-14
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@
4545
import org.codehaus.plexus.archiver.zip.ArchiveFileComparator;
4646
import org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributeUtils;
4747
import org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributes;
48-
import org.codehaus.plexus.logging.Logger;
49-
import org.codehaus.plexus.logging.console.ConsoleLogger;
5048
import org.codehaus.plexus.util.FileUtils;
5149
import org.codehaus.plexus.util.IOUtil;
5250
import org.codehaus.plexus.util.Os;
@@ -61,17 +59,6 @@ public class TarArchiverTest
6159
extends PlexusTestCase
6260
{
6361

64-
private Logger logger;
65-
66-
@Override
67-
public void setUp()
68-
throws Exception
69-
{
70-
super.setUp();
71-
72-
logger = new ConsoleLogger( Logger.LEVEL_DEBUG, "test" );
73-
}
74-
7562
public void testCreateArchiveWithDetectedModes()
7663
throws Exception
7764
{
@@ -275,7 +262,7 @@ private void writeFile( File dir, String fname, int mode )
275262
IOUtil.close( writer );
276263
}
277264

278-
ArchiveEntryUtils.chmod( file, mode, logger, false );
265+
ArchiveEntryUtils.chmod( file, mode );
279266
}
280267

281268
public void testCreateArchive()

Diff for: src/test/java/org/codehaus/plexus/archiver/util/ArchiveEntryUtilsTest.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import java.io.IOException;
55
import java.util.HashMap;
66
import org.codehaus.plexus.components.io.attributes.FileAttributes;
7-
import org.codehaus.plexus.logging.console.ConsoleLogger;
87
import org.codehaus.plexus.util.Os;
98
import junit.framework.TestCase;
109

@@ -19,8 +18,7 @@ public void testChmodForFileWithDollarPLXCOMP164() throws Exception
1918
return;
2019
}
2120
File temp = File.createTempFile( "A$A", "BB$" );
22-
ArchiveEntryUtils.chmod( temp, 0770, new ConsoleLogger( org.codehaus.plexus.logging.Logger.LEVEL_DEBUG, "foo" ),
23-
false );
21+
ArchiveEntryUtils.chmod( temp, 0770 );
2422
assert0770( temp );
2523
}
2624

@@ -32,8 +30,7 @@ public void testChmodWithJava7() throws Exception
3230
}
3331

3432
File temp = File.createTempFile( "D$D", "BB$" );
35-
ArchiveEntryUtils.
36-
chmod( temp, 0770, new ConsoleLogger( org.codehaus.plexus.logging.Logger.LEVEL_DEBUG, "foo" ) );
33+
ArchiveEntryUtils.chmod( temp, 0770 );
3734
assert0770( temp );
3835
}
3936

Diff for: src/test/java/org/codehaus/plexus/archiver/zip/ZipArchiverTest.java

+1-13
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@
6161
import org.codehaus.plexus.components.io.resources.PlexusIoFileResourceCollection;
6262
import org.codehaus.plexus.components.io.resources.PlexusIoResource;
6363
import org.codehaus.plexus.components.io.resources.ResourceFactory;
64-
import org.codehaus.plexus.logging.Logger;
65-
import org.codehaus.plexus.logging.console.ConsoleLogger;
6664
import org.codehaus.plexus.util.FileUtils;
6765
import org.codehaus.plexus.util.IOUtil;
6866
import org.codehaus.plexus.util.Os;
@@ -75,16 +73,6 @@ public class ZipArchiverTest
7573
extends BasePlexusArchiverTest
7674
{
7775

78-
private Logger logger;
79-
80-
public void setUp()
81-
throws Exception
82-
{
83-
super.setUp();
84-
85-
logger = new ConsoleLogger( Logger.LEVEL_DEBUG, "test" );
86-
}
87-
8876
public void testImplicitPermissions()
8977
throws IOException
9078
{
@@ -342,7 +330,7 @@ private void writeFile( File dir, String fname, int mode )
342330
IOUtil.close( writer );
343331
}
344332

345-
ArchiveEntryUtils.chmod( file, mode, logger, false );
333+
ArchiveEntryUtils.chmod( file, mode );
346334
}
347335

348336
public void testCreateArchive()

0 commit comments

Comments
 (0)