From cd4ddec0a0c14db770877eb0211327c57c0cff08 Mon Sep 17 00:00:00 2001 From: Mark Donszelmann Date: Wed, 2 Dec 2009 15:17:54 +0100 Subject: Fixed NAR-12 --- src/it/it0020-lib-3rdparty/pom.xml | 68 +++++++++++++++++++++ .../lib/libit0007-lib-shared-1.0-SNAPSHOT.dylib | Bin 0 -> 4240 bytes .../nar/resources/noarch/include/HelloWorldLib.h | 9 +++ .../it0020-lib-3rdparty/src/test/c/HelloWorldExe.c | 9 +++ .../maven/plugin/nar/AbstractResourcesMojo.java | 6 +- .../java/org/apache/maven/plugin/nar/Linker.java | 2 +- .../org/apache/maven/plugin/nar/NarLayout.java | 20 ++++-- .../org/apache/maven/plugin/nar/NarLayout20.java | 9 +++ .../org/apache/maven/plugin/nar/NarLayout21.java | 8 +-- .../apache/maven/plugin/nar/NarResourcesMojo.java | 19 ++++++ 10 files changed, 137 insertions(+), 13 deletions(-) create mode 100644 src/it/it0020-lib-3rdparty/pom.xml create mode 100755 src/it/it0020-lib-3rdparty/src/nar/resources/aol/x86_64-MacOSX-g++/lib/libit0007-lib-shared-1.0-SNAPSHOT.dylib create mode 100644 src/it/it0020-lib-3rdparty/src/nar/resources/noarch/include/HelloWorldLib.h create mode 100644 src/it/it0020-lib-3rdparty/src/test/c/HelloWorldExe.c diff --git a/src/it/it0020-lib-3rdparty/pom.xml b/src/it/it0020-lib-3rdparty/pom.xml new file mode 100644 index 0000000..b81bc07 --- /dev/null +++ b/src/it/it0020-lib-3rdparty/pom.xml @@ -0,0 +1,68 @@ + + + + + + 4.0.0 + + + org.apache.maven.its.nar + it-parent + 1.0-SNAPSHOT + ../it-parent/pom.xml + + + it0020-lib-3rdparty + nar + + Maven NAR Executable depending on 3rd party lib + 1.0-SNAPSHOT + + Executable depending on a 3rd party lib. + + + + true + + + + install + + + maven-nar-plugin + true + + + + shared + + + + + + + + diff --git a/src/it/it0020-lib-3rdparty/src/nar/resources/aol/x86_64-MacOSX-g++/lib/libit0007-lib-shared-1.0-SNAPSHOT.dylib b/src/it/it0020-lib-3rdparty/src/nar/resources/aol/x86_64-MacOSX-g++/lib/libit0007-lib-shared-1.0-SNAPSHOT.dylib new file mode 100755 index 0000000..c2c207c Binary files /dev/null and b/src/it/it0020-lib-3rdparty/src/nar/resources/aol/x86_64-MacOSX-g++/lib/libit0007-lib-shared-1.0-SNAPSHOT.dylib differ diff --git a/src/it/it0020-lib-3rdparty/src/nar/resources/noarch/include/HelloWorldLib.h b/src/it/it0020-lib-3rdparty/src/nar/resources/noarch/include/HelloWorldLib.h new file mode 100644 index 0000000..e801bec --- /dev/null +++ b/src/it/it0020-lib-3rdparty/src/nar/resources/noarch/include/HelloWorldLib.h @@ -0,0 +1,9 @@ +#ifndef HelloWorldLib_H +#define HelloWorldLib_H + +#ifdef WIN32 +__declspec(dllexport) +#endif +extern char* HelloWorldLib_sayHello(); + +#endif diff --git a/src/it/it0020-lib-3rdparty/src/test/c/HelloWorldExe.c b/src/it/it0020-lib-3rdparty/src/test/c/HelloWorldExe.c new file mode 100644 index 0000000..4aa35d8 --- /dev/null +++ b/src/it/it0020-lib-3rdparty/src/test/c/HelloWorldExe.c @@ -0,0 +1,9 @@ +#include +#include "HelloWorldLib.h" + +int main(int argc, char *argv[]) { + printf("%s\n", HelloWorldLib_sayHello()); + return 0; +} + + diff --git a/src/main/java/org/apache/maven/plugin/nar/AbstractResourcesMojo.java b/src/main/java/org/apache/maven/plugin/nar/AbstractResourcesMojo.java index 2aedf8b..2b6b5bb 100644 --- a/src/main/java/org/apache/maven/plugin/nar/AbstractResourcesMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/AbstractResourcesMojo.java @@ -168,15 +168,15 @@ public abstract class AbstractResourcesMojo } catch ( IOException e ) { - throw new MojoExecutionException( "NAR: Could not copy resources", e ); + throw new MojoExecutionException( "NAR: Could not copy resources for " + aol, e ); } catch ( NoSuchArchiverException e ) { - throw new MojoExecutionException( "NAR: Could not find archiver", e ); + throw new MojoExecutionException( "NAR: Could not find archiver for " + aol, e ); } catch ( ArchiverException e ) { - throw new MojoExecutionException( "NAR: Could not unarchive jar file", e ); + throw new MojoExecutionException( "NAR: Could not unarchive jar file for " + aol, e ); } getLog().info( "Copied " + copied + " resources for " + aol ); } diff --git a/src/main/java/org/apache/maven/plugin/nar/Linker.java b/src/main/java/org/apache/maven/plugin/nar/Linker.java index 51c89cb..9b9edcb 100644 --- a/src/main/java/org/apache/maven/plugin/nar/Linker.java +++ b/src/main/java/org/apache/maven/plugin/nar/Linker.java @@ -177,7 +177,7 @@ public class Linker return name; } - public final String getVersion() + public final String getVersion() throws MojoFailureException, MojoExecutionException { if ( name == null ) diff --git a/src/main/java/org/apache/maven/plugin/nar/NarLayout.java b/src/main/java/org/apache/maven/plugin/nar/NarLayout.java index 062bec9..cdb4ba7 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarLayout.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarLayout.java @@ -36,32 +36,42 @@ import org.codehaus.plexus.archiver.manager.ArchiverManager; */ public interface NarLayout { + /** + * Specifies where all the "no architecture" specific files are stored + */ + File getNoArchDirectory( File baseDir ) + throws MojoExecutionException, MojoFailureException; + /** * Specifies where libraries are stored * * @return - * @throws MojoExecutionException, MojoFailureException + * @throws MojoExecutionException, MojoFailureException */ - File getLibDirectory( File baseDir, String aol, String type ) throws MojoExecutionException, MojoFailureException; + File getLibDirectory( File baseDir, String aol, String type ) + throws MojoExecutionException, MojoFailureException; /** * Specifies where includes are stored * * @return */ - File getIncludeDirectory( File targetDirectory ) throws MojoExecutionException, MojoFailureException; + File getIncludeDirectory( File baseDir ) + throws MojoExecutionException, MojoFailureException; /** * Specifies where binaries are stored * * @return */ - File getBinDirectory( File baseDir, String aol ) throws MojoExecutionException, MojoFailureException; + File getBinDirectory( File baseDir, String aol ) + throws MojoExecutionException, MojoFailureException; /** * Called to attach nars to main jar file. This method needs to produce all the attached nar files and set NarInfo * accordingly. */ - void attachNars( File baseDir, ArchiverManager archiverManager, MavenProjectHelper projectHelper, MavenProject project, NarInfo narInfo ) + void attachNars( File baseDir, ArchiverManager archiverManager, MavenProjectHelper projectHelper, + MavenProject project, NarInfo narInfo ) throws MojoExecutionException, MojoFailureException; } diff --git a/src/main/java/org/apache/maven/plugin/nar/NarLayout20.java b/src/main/java/org/apache/maven/plugin/nar/NarLayout20.java index 23b9f19..e2e0207 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarLayout20.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarLayout20.java @@ -44,6 +44,15 @@ import org.codehaus.plexus.archiver.manager.ArchiverManager; public class NarLayout20 extends AbstractNarLayout { + /* (non-Javadoc) + * @see org.apache.maven.plugin.nar.NarLayout#getNoArchDirectory(java.io.File) + */ + public File getNoArchDirectory( File baseDir ) + throws MojoExecutionException, MojoFailureException + { + return baseDir; + } + /* * (non-Javadoc) * @see org.apache.maven.plugin.nar.NarLayout#getIncludeDirectory(java.io.File) diff --git a/src/main/java/org/apache/maven/plugin/nar/NarLayout21.java b/src/main/java/org/apache/maven/plugin/nar/NarLayout21.java index 8301330..623e3fa 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarLayout21.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarLayout21.java @@ -42,7 +42,7 @@ import org.codehaus.plexus.archiver.manager.ArchiverManager; public class NarLayout21 extends AbstractNarLayout { - private File getNoarchDirectory( File baseDir ) + public File getNoArchDirectory( File baseDir ) { return new File( baseDir, NarConstants.NAR_NO_ARCH ); } @@ -63,7 +63,7 @@ public class NarLayout21 */ public final File getIncludeDirectory( File baseDir ) { - return new File( getNoarchDirectory( baseDir ), "include" ); + return new File( getNoArchDirectory( baseDir ), "include" ); } /* @@ -108,9 +108,9 @@ public class NarLayout21 public final void attachNars( File baseDir, ArchiverManager archiverManager, MavenProjectHelper projectHelper, MavenProject project, NarInfo narInfo ) throws MojoExecutionException { - if ( getNoarchDirectory( baseDir ).exists() ) + if ( getNoArchDirectory( baseDir ).exists() ) { - attachNar( archiverManager, projectHelper, project, NarConstants.NAR_NO_ARCH, getNoarchDirectory( baseDir ), "*/**" ); + attachNar( archiverManager, projectHelper, project, NarConstants.NAR_NO_ARCH, getNoArchDirectory( baseDir ), "*/**" ); narInfo.setNar( null, NarConstants.NAR_NO_ARCH, project.getGroupId() + ":" + project.getArtifactId() + ":" + NarConstants.NAR_TYPE + ":" + NarConstants.NAR_NO_ARCH ); } diff --git a/src/main/java/org/apache/maven/plugin/nar/NarResourcesMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarResourcesMojo.java index fa05acd..b730a52 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarResourcesMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarResourcesMojo.java @@ -20,6 +20,7 @@ package org.apache.maven.plugin.nar; */ import java.io.File; +import java.io.IOException; import java.util.Iterator; import org.apache.maven.plugin.MojoExecutionException; @@ -57,6 +58,24 @@ public class NarResourcesMojo public final void narExecute() throws MojoExecutionException, MojoFailureException { + // noarch resources + try + { + int copied = 0; + File noarchDir = new File( resourceDirectory, NarConstants.NAR_NO_ARCH ); + if ( noarchDir.exists() ) + { + File noarchDstDir = getLayout().getNoArchDirectory( getTargetDirectory() ); + getLog().debug( "Copying noarch from " + noarchDir + " to " + noarchDstDir ); + copied += NarUtil.copyDirectoryStructure( noarchDir, noarchDstDir, null, NarUtil.DEFAULT_EXCLUDES ); + } + getLog().info( "Copied " + copied + " resources" ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "NAR: Could not copy resources", e ); + } + // scan resourceDirectory for AOLs File aolDir = new File( resourceDirectory, NarConstants.NAR_AOL ); if ( aolDir.exists() ) -- cgit v1.2.3