summaryrefslogtreecommitdiff
path: root/src/main/java/org/apache/maven/plugin/nar/NarUtil.java
diff options
context:
space:
mode:
authorMark Donszelmann <Mark.Donszelmann@gmail.com>2009-12-01 14:42:17 +0100
committerMark Donszelmann <Mark.Donszelmann@gmail.com>2009-12-01 14:42:17 +0100
commitf724731d74a36e5324d2ef24ab1b10520256ddf4 (patch)
tree9a3b1e1627a916d464f3261669f13763c4a62ca4 /src/main/java/org/apache/maven/plugin/nar/NarUtil.java
parent3d36be1293200ddf6d6eb266e2c468c0b750601b (diff)
downloadmaven-nar-plugin-f724731d74a36e5324d2ef24ab1b10520256ddf4.tar.gz
maven-nar-plugin-f724731d74a36e5324d2ef24ab1b10520256ddf4.tar.bz2
maven-nar-plugin-f724731d74a36e5324d2ef24ab1b10520256ddf4.tar.xz
maven-nar-plugin-f724731d74a36e5324d2ef24ab1b10520256ddf4.zip
Fixed NAR-16
Diffstat (limited to 'src/main/java/org/apache/maven/plugin/nar/NarUtil.java')
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarUtil.java47
1 files changed, 42 insertions, 5 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 654883a..93f938e 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarUtil.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarUtil.java
@@ -45,10 +45,11 @@ import org.codehaus.plexus.util.cli.Commandline;
public final class NarUtil
{
- private NarUtil() {
+ private NarUtil()
+ {
// never instantiate
}
-
+
private static Properties defaults;
public static Properties getDefaults()
@@ -207,6 +208,40 @@ public final class NarUtil
}
}
+ public static void makeLink( File file, final Log log )
+ throws MojoExecutionException, MojoFailureException
+ {
+ if ( !file.exists() )
+ {
+ return;
+ }
+
+ if ( file.isDirectory() )
+ {
+ File[] files = file.listFiles();
+ for ( int i = 0; i < files.length; i++ )
+ {
+ makeLink( files[i], log );
+ }
+ }
+ if ( file.isFile() && file.canRead() && file.canWrite() && !file.isHidden()
+ && file.getName().matches( ".*\\.so(\\.\\d+)+$" ) )
+ {
+ File sofile =
+ new File( file.getParent(), file.getName().substring( 0, file.getName().indexOf( ".so" ) + 3 ) );
+ if ( !sofile.exists() )
+ {
+ // ln -s lib.so.xx lib.so
+ 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() + " "
+ + sofile.getPath() + "'" + " return code: \'" + result + "\'." );
+ }
+ }
+ }
+ }
+
/**
* Returns the Bcel Class corresponding to the given class filename
*
@@ -262,7 +297,7 @@ public final class NarUtil
{
final String escQ = "\\Q";
final String escE = "\\E";
-
+
int slashEIndex = s.indexOf( escE );
if ( slashEIndex == -1 )
{
@@ -520,6 +555,7 @@ public final class NarUtil
extends Thread
{
private InputStream is;
+
private TextStream ts;
private StreamGobbler( InputStream is, TextStream ts )
@@ -544,8 +580,9 @@ public final class NarUtil
{
// e.printStackTrace()
StackTraceElement[] stackTrace = e.getStackTrace();
- for (int i=0; i<stackTrace.length; i++) {
- ts.println( stackTrace[i].toString());
+ for ( int i = 0; i < stackTrace.length; i++ )
+ {
+ ts.println( stackTrace[i].toString() );
}
}
}