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 --- .../org/apache/maven/plugin/nar/NarManager.java | 2 + .../java/org/apache/maven/plugin/nar/NarUtil.java | 47 +++++++++++++++++++--- .../org/apache/maven/plugin/nar/aol.properties | 20 ++++----- 3 files changed, 54 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/apache/maven/plugin/nar/NarManager.java b/src/main/java/org/apache/maven/plugin/nar/NarManager.java index e5414b6..17ed990 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarManager.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarManager.java @@ -412,6 +412,8 @@ public class NarManager NarUtil.makeExecutable( new File( narLocation, "bin/" + NarUtil.replace( gpp, gcc, defaultAOL.toString() ) ), log ); } + // add link to versioned so files + NarUtil.makeLink(new File(narLocation, "lib/"+defaultAOL), log); } if ( linkerName.equals( gcc ) || linkerName.equals( gpp ) ) { 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