From f724731d74a36e5324d2ef24ab1b10520256ddf4 Mon Sep 17 00:00:00 2001 From: Mark Donszelmann Date: Tue, 1 Dec 2009 14:42:17 +0100 Subject: Fixed NAR-16 --- .../java/org/apache/maven/plugin/nar/NarUtil.java | 47 +++++++++++++++++++--- 1 file changed, 42 insertions(+), 5 deletions(-) (limited to 'src/main/java/org/apache/maven/plugin/nar/NarUtil.java') 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