diff options
author | Mark Donszelmann <Mark.Donszelmann@gmail.com> | 2009-12-04 21:28:31 +0100 |
---|---|---|
committer | Mark Donszelmann <Mark.Donszelmann@gmail.com> | 2009-12-04 21:28:31 +0100 |
commit | 8984c192a541668463dd099693182415531918f8 (patch) | |
tree | ce9bafeca48de175e4f5493c2b07788f8c38d8af /src/main/java/org | |
parent | 7ca14517504d597617083bae733cf61b3ba5742e (diff) | |
download | maven-nar-plugin-8984c192a541668463dd099693182415531918f8.tar.gz maven-nar-plugin-8984c192a541668463dd099693182415531918f8.tar.bz2 maven-nar-plugin-8984c192a541668463dd099693182415531918f8.tar.xz maven-nar-plugin-8984c192a541668463dd099693182415531918f8.zip |
Fixed NAR-84
Diffstat (limited to 'src/main/java/org')
-rw-r--r-- | src/main/java/org/apache/maven/plugin/nar/NarUtil.java | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/src/main/java/org/apache/maven/plugin/nar/NarUtil.java b/src/main/java/org/apache/maven/plugin/nar/NarUtil.java index 93f938e..6654932 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarUtil.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarUtil.java @@ -24,6 +24,8 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -232,7 +234,8 @@ public final class NarUtil if ( !sofile.exists() ) { // ln -s lib.so.xx lib.so - int result = runCommand( "ln", new String[] { "-s", file.getName(), sofile.getPath() }, null, null, log ); + int result = + runCommand( "ln", new String[] { "-s", file.getName(), sofile.getPath() }, null, null, log ); if ( result != 0 ) { throw new MojoExecutionException( "Failed to execute 'ln -s " + file.getName() + " " @@ -374,11 +377,45 @@ public final class NarUtil String dest = file.getAbsolutePath(); dest = dest.substring( sourcePath.length() + 1 ); File destination = new File( destinationDirectory, dest ); + System.err.println( "** " + destination ); if ( file.isFile() ) { - destination = destination.getParentFile(); - FileUtils.copyFileToDirectory( file, destination ); + // destination = destination.getParentFile(); + FileUtils.copyFile( file, destination ); copied++; + + // copy executable bit + try + { + // 1.6 only so coded using introspection + // destination.setExecutable( file.canExecute(), false ); + Method canExecute = file.getClass().getDeclaredMethod( "canExecute", new Class[] {} ); + Method setExecutable = + destination.getClass().getDeclaredMethod( "setExecutable", + new Class[] { boolean.class, boolean.class } ); + setExecutable.invoke( destination, new Object[] { + (Boolean) canExecute.invoke( file, new Object[] {} ), Boolean.FALSE } ); + } + catch ( SecurityException e ) + { + // ignored + } + catch ( NoSuchMethodException e ) + { + // ignored + } + catch ( IllegalArgumentException e ) + { + // ignored + } + catch ( IllegalAccessException e ) + { + // ignored + } + catch ( InvocationTargetException e ) + { + // ignored + } } else if ( file.isDirectory() ) { |