-
Notifications
You must be signed in to change notification settings - Fork 10
Upgrade to Java 7 #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I just created milestone 3.0. I think it is best to bump version to 3.0.0 and get rid of all stuff no matter what. This is fine for a major release. |
@@ -114,8 +114,7 @@ private void createZipFile( File dest, File dir ) throws IOException | |||
private void compare( InputStream in, File file ) | |||
throws IOException | |||
{ | |||
InputStream fIn = new FileInputStream( file ); | |||
try | |||
try(InputStream fIn = new FileInputStream( file )) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing whitespace.
sb.append("\nuid: "); | ||
sb.append(hasUserId() ? Integer.toString(userId) : ""); | ||
sb.append("\ngid: "); | ||
sb.append(hasGroupId() ? Integer.toString(groupId) : ""); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use System.lineSeparator()
instead of \n
.
verifyLsModeSet( "-r--------", new boolean[]{ true, false, false, false, false, false, false, false, false } ); | ||
verifyLsModeSet( "--w-------", new boolean[]{ false, true, false, false, false, false, false, false, false } ); | ||
} | ||
if ( Os.isFamily( Os.FAMILY_WINDOWS ) || Os.isFamily( Os.FAMILY_WIN9X ) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can safely drop WIN9X
.
@@ -94,7 +67,7 @@ public void testGetAttributesForThisTestClass() | |||
assertEquals( System.getProperty( "user.name" ), fileAttrs.getUserName() ); | |||
} | |||
|
|||
public void testFolderJava7() | |||
public void testFolder() | |||
throws IOException, CommandLineException { | |||
|
|||
if (Os.isFamily( Os.FAMILY_WINDOWS ) || Os.isFamily( Os.FAMILY_WIN9X )){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here probably throughout.
@@ -200,119 +130,18 @@ public void testSrcResource() | |||
|
|||
assertTrue(pr.getOctalMode() > 0); | |||
} | |||
public void testPermissionDenied() | |||
public void testNonExistingFolder() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unix does not know folders, but only directories.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'm not quite sure I follow you. Do you mean that in Unix there are 'directories' not 'folders' and that's why the method name should be'testNonExistingDirectory
? I choose this name because it's consistent with the rest of the existing test names (such as testFolderJava7
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, update accordingly since you already doing update.
Completed the review. Looks good to me. Please review the codestyle. In most cases whitespace is missing before and after parens. |
@@ -183,141 +174,11 @@ public static PlexusIoResourceAttributes getFileAttributes( File file ) | |||
return o; | |||
} | |||
|
|||
public static Map<String, PlexusIoResourceAttributes> getFileAttributesByPath( File dir ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I've deleted this one by mistake - it does make sense and it's used by Plexus Archiver. I'll restore it.
README.md
Outdated
It is therefore recommended to run mvn -Djava.language.downgrade=true clean install before relasing, to assess | ||
that features still work with older jdk versions. | ||
|
||
|
||
Version 2.6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is incomplete anyway, drop it altogether.
Waiting for your updated PR. Tell me when you are done. |
Now the changelog is kept in the Plexus Archiver project and the Java version bit is also going to to outdated after the update to Java 7.
fc7cd6c
to
eb7996f
Compare
I have updated the PR. About the code style - there seems to be quite a lot violations. Maybe I should fix them in separate commit. Have to figure out how to do it though. The InteliJ Idea and Eclipse auto-formatting is long way from perfect. |
Agreed. A separate commit makes sense. Let me review the new changes.... |
/* | ||
* Copyright 2016 Plexus developers. | ||
* Copyright 2011 The Codehaus Foundation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This copyright change is weird...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually FileAttributesTest
is not modified at all. It's deleted and Java7FileAttributesTest
is renamed to FileAttributesTest
(the same goes for FileAttributes
and Java7FileAttributes
). Git shows those as diffs but they are actually delete + rename. Maybe I should state that explicitly in the commit message as it's not obvious from looking at the diffs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. Please go ahead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. I've modified the commit message.
The classes related to file attributes are depending on features introduced in Java 7. To support Java version prior to 7, plexus IO uses reflection check to choose between two different implementations. The legacy one that parses the output from the `ls` command and the Java 7 one that is pure Java. Because now Java 7 is the minimum required version, remove all the reflection Java version checks and remove any legacy code that executes only for Java versions below 7. There were two version of `FileAttributes` - `FileAttributes` and `Java7FileAttributes`. Remove the legacy `FileAttributes` and rename `Java7FileAttributes` to `FileAttributes`. Rename `Java7AttributeUtils` to `AttributeUtils` as there is no longer Java version specific implementations for attributes related classes. NOTE: The commit diff shows `FileAttributes` as changed but it's actually deleted and `Java7FileAttributes` is renamed to `FileAttributes`. The same goes for `FileAttributesTest` and `Java7FileAttributesTest` Also remove `PlexusIoResourceAttributeUtils#getFileAttributesByPath( File dir, boolean recursive, boolean includeNumericUserId )`. `includeNumericUserId` is related to the `ls` command and is no longer needed. Update the tests. Delete no longer needed resources and tests. All tests and resources related to the `ls` output parsing are no longer needed. Also replace `PlexusIoResourceAttributeUtilsTest#testPermissionDenied` with `testNonExistingFolder` - when folder is missing we no longer get `cannot access` response from the `ls` command and the new test method name is more suitable.
We could quite safely assume that the tests are not going to be executed on Windows 9x.
Unix uses the term 'Directory' and the test runs only on Unix-like OSes. Change the test name accordingly.
eb7996f
to
9ccf45d
Compare
9ccf45d
to
55773f5
Compare
I've fixed the code style. Or at least I've tried 😄 . |
You did very well... |
Hi,
As discussed on codehaus-plexus/plexus-archiver#55, Plexus Archiver is going to require Java 7.
I'm using the occasion to purpose an update for Plexus IO as well.
The proposed changes are:
<>
) and try with resources)ls
command to get the file attributes when running on Java versions prior to 7. Remove all legacy code and use only the Java 7 implementation.Unfortunately the proposed changes are not backward compatible. Instead of having
FileAttributes
,Java7FileAttributes
andJava7AttributeUtils
, now we haveFileAttributes
andAttributeUtils
.Java7Reflector
,AttributeParser
classes and the publicPlexusIoResourceAttributeUtils#getFileAttributesByPath( File dir, boolean recursive, boolean includeNumericUserId )
method are deleted. What do you think? We could remove the legacy code without changing the public interfaces and classes, but I think it's better to just remove the legacy code and interfaces - it will make the maintenance easier in long run.p.s. If we make backward incompatible changes I guess we need to bump the project version.