Skip to content

Commit 6397c3e

Browse files
committed
o Added support for java7 isSymlink
1 parent d854834 commit 6397c3e

File tree

4 files changed

+109
-2
lines changed

4 files changed

+109
-2
lines changed

pom.xml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ See the License for the specific language governing permissions and
1616
limitations under the License.
1717
-->
1818

19-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
19+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2021
<modelVersion>4.0.0</modelVersion>
2122

2223
<parent>
@@ -29,7 +30,9 @@ limitations under the License.
2930
<version>3.0.8-SNAPSHOT</version>
3031

3132
<name>Plexus Common Utilities</name>
32-
<description>A collection of various utility classes to ease working with strings, files, command lines, XML and more.</description>
33+
<description>A collection of various utility classes to ease working with strings, files, command lines, XML and
34+
more.
35+
</description>
3336
<url>http://plexus.codehaus.org/plexus-utils</url>
3437

3538
<scm>
@@ -66,6 +69,26 @@ limitations under the License.
6669
</systemProperties>
6770
</configuration>
6871
</plugin>
72+
<plugin>
73+
<groupId>org.apache.maven.plugins</groupId>
74+
<artifactId>maven-enforcer-plugin</artifactId>
75+
<version>1.1.1</version>
76+
<executions>
77+
<execution>
78+
<id>enforce-java</id>
79+
<goals>
80+
<goal>enforce</goal>
81+
</goals>
82+
<configuration>
83+
<rules>
84+
<requireJavaVersion>
85+
<version>1.7.0</version>
86+
</requireJavaVersion>
87+
</rules>
88+
</configuration>
89+
</execution>
90+
</executions>
91+
</plugin>
6992
</plugins>
7093
</build>
7194
</project>

src/main/java/org/codehaus/plexus/util/DirectoryScanner.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,10 @@ public String[] getDeselectedDirectories()
722722
public boolean isSymbolicLink( File parent, String name )
723723
throws IOException
724724
{
725+
if ( Java7Detector.isJava7() )
726+
{
727+
return Java7FileUtil.isSymLink( new File( parent, name ) );
728+
}
725729
File resolvedParent = new File( parent.getCanonicalPath() );
726730
File toTest = new File( resolvedParent, name );
727731
return !toTest.getAbsolutePath().equals( toTest.getCanonicalPath() );
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package org.codehaus.plexus.util;
2+
3+
/*
4+
* Copyright 2011 The Codehaus Foundation.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/**
20+
* Java7 feature detection
21+
*
22+
* @author Kristian Rosenvold
23+
*/
24+
class Java7Detector
25+
{
26+
27+
private static final boolean isJava7;
28+
29+
static
30+
{
31+
boolean isJava7x = true;
32+
try
33+
{
34+
Class.forName( "java.nio.file.Files" );
35+
}
36+
catch ( Exception e )
37+
{
38+
isJava7x = false;
39+
}
40+
isJava7 = isJava7x;
41+
}
42+
43+
44+
public static boolean isJava7()
45+
{
46+
return isJava7;
47+
}
48+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package org.codehaus.plexus.util;
2+
3+
/*
4+
* Copyright 2007 The Codehaus Foundation.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
import java.io.File;
20+
import java.nio.file.Files;
21+
22+
/**
23+
* Encapsulates use of java7 features
24+
*/
25+
public class Java7FileUtil
26+
{
27+
public static boolean isSymLink( File file )
28+
{
29+
return Files.isSymbolicLink( file.toPath() );
30+
}
31+
32+
}

0 commit comments

Comments
 (0)