summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Donszelmann <Mark.Donszelmann@gmail.com>2009-12-04 21:28:31 +0100
committerMark Donszelmann <Mark.Donszelmann@gmail.com>2009-12-04 21:28:31 +0100
commit8984c192a541668463dd099693182415531918f8 (patch)
treece9bafeca48de175e4f5493c2b07788f8c38d8af
parent7ca14517504d597617083bae733cf61b3ba5742e (diff)
downloadmaven-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
-rw-r--r--src/it/it0013-gnu-executable/pom.xml2
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarUtil.java43
2 files changed, 40 insertions, 5 deletions
diff --git a/src/it/it0013-gnu-executable/pom.xml b/src/it/it0013-gnu-executable/pom.xml
index 338478c..5f36ada 100644
--- a/src/it/it0013-gnu-executable/pom.xml
+++ b/src/it/it0013-gnu-executable/pom.xml
@@ -53,9 +53,7 @@ under the License.
<libraries>
<library>
<type>executable</type>
-<!-- NAR-84
<run>true</run>
--->
</library>
</libraries>
</configuration>
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() )
{