diff options
Diffstat (limited to 'src')
10 files changed, 137 insertions, 13 deletions
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 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.maven.its.nar</groupId> + <artifactId>it-parent</artifactId> + <version>1.0-SNAPSHOT</version> + <relativePath>../it-parent/pom.xml</relativePath> + </parent> + + <artifactId>it0020-lib-3rdparty</artifactId> + <packaging>nar</packaging> + + <name>Maven NAR Executable depending on 3rd party lib</name> + <version>1.0-SNAPSHOT</version> + <description> + Executable depending on a 3rd party lib. + </description> + + <properties> + <skipTests>true</skipTests> + </properties> + + <build> + <defaultGoal>install</defaultGoal> + <plugins> + <plugin> + <artifactId>maven-nar-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <libraries> + <library> + <type>shared</type> + </library> + </libraries> +<!-- + <tests> + <test> + <name>HelloWorldTest</name> + </test> + </tests> +--> + </configuration> + </plugin> + </plugins> + </build> +</project> 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 Binary files differnew file mode 100755 index 0000000..c2c207c --- /dev/null +++ b/src/it/it0020-lib-3rdparty/src/nar/resources/aol/x86_64-MacOSX-g++/lib/libit0007-lib-shared-1.0-SNAPSHOT.dylib 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 <stdio.h> +#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 @@ -37,31 +37,41 @@ 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() ) |