diff options
35 files changed, 1162 insertions, 375 deletions
diff --git a/src/it/it0016-layout/it0016-lib-shared/src/main/include/HelloWorldLib.h b/src/it/it0016-layout/include/HelloWorldLib.h index e801bec..e801bec 100644 --- a/src/it/it0016-layout/it0016-lib-shared/src/main/include/HelloWorldLib.h +++ b/src/it/it0016-layout/include/HelloWorldLib.h diff --git a/src/it/it0016-layout/it0016-executable-dep-lib-shared-layout20/pom.xml b/src/it/it0016-layout/it0016-executable-dep-lib-shared-layout20/pom.xml new file mode 100644 index 0000000..9974d0a --- /dev/null +++ b/src/it/it0016-layout/it0016-executable-dep-lib-shared-layout20/pom.xml @@ -0,0 +1,70 @@ +<?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>it0016-pom</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + + <artifactId>it0016-executable-dep-lib-shared-layout20</artifactId> + <packaging>nar</packaging> + + <name>Maven NAR Executable and Shared Library (Layout20)</name> + <version>1.0-SNAPSHOT</version> + <description> + Executable depending on a shared library. + </description> + + <properties> + <skipTests>true</skipTests> + </properties> + + <build> + <defaultGoal>integration-test</defaultGoal> + <plugins> + <plugin> + <artifactId>maven-nar-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <!-- dependencies get unpacked in NarLayout 20 --> + <layout>NarLayout20</layout> + <libraries> + <library> + <type>executable</type> + <run>true</run> + </library> + </libraries> + </configuration> + </plugin> + </plugins> + </build> + <dependencies> + <dependency> + <groupId>org.apache.maven.its.nar</groupId> + <artifactId>it0016-lib-shared-layout20</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + </dependencies> +</project> diff --git a/src/it/it0016-layout/it0016-executable-dep-lib-shared/src/main/c/HelloWorldExe.c b/src/it/it0016-layout/it0016-executable-dep-lib-shared-layout20/src/main/c/HelloWorldExe.c index 4aa35d8..4aa35d8 100644 --- a/src/it/it0016-layout/it0016-executable-dep-lib-shared/src/main/c/HelloWorldExe.c +++ b/src/it/it0016-layout/it0016-executable-dep-lib-shared-layout20/src/main/c/HelloWorldExe.c diff --git a/src/it/it0016-layout/it0016-executable-dep-lib-shared/pom.xml b/src/it/it0016-layout/it0016-executable-dep-lib-shared-layout21/pom.xml index e73be91..3322daa 100644 --- a/src/it/it0016-layout/it0016-executable-dep-lib-shared/pom.xml +++ b/src/it/it0016-layout/it0016-executable-dep-lib-shared-layout21/pom.xml @@ -28,10 +28,10 @@ under the License. <version>1.0-SNAPSHOT</version> </parent> - <artifactId>it0016-executable-dep-lib-shared</artifactId> + <artifactId>it0016-executable-dep-lib-shared-layout21</artifactId> <packaging>nar</packaging> - <name>Maven NAR Executable and Shared Library</name> + <name>Maven NAR Executable and Shared Library (Layout21)</name> <version>1.0-SNAPSHOT</version> <description> Executable depending on a shared library. @@ -48,7 +48,6 @@ under the License. <artifactId>maven-nar-plugin</artifactId> <extensions>true</extensions> <configuration> - <layout>NarLayout20</layout> <libraries> <library> <type>executable</type> @@ -62,7 +61,7 @@ under the License. <dependencies> <dependency> <groupId>org.apache.maven.its.nar</groupId> - <artifactId>it0016-lib-shared</artifactId> + <artifactId>it0016-lib-shared-layout21</artifactId> <version>1.0-SNAPSHOT</version> </dependency> </dependencies> diff --git a/src/it/it0016-layout/it0016-lib-shared/src/test/c/HelloWorldTest.c b/src/it/it0016-layout/it0016-executable-dep-lib-shared-layout21/src/main/c/HelloWorldExe.c index 4aa35d8..4aa35d8 100644 --- a/src/it/it0016-layout/it0016-lib-shared/src/test/c/HelloWorldTest.c +++ b/src/it/it0016-layout/it0016-executable-dep-lib-shared-layout21/src/main/c/HelloWorldExe.c diff --git a/src/it/it0016-layout/it0016-lib-shared/pom.xml b/src/it/it0016-layout/it0016-lib-shared-layout20/pom.xml index 831e48e..1b4c319 100644 --- a/src/it/it0016-layout/it0016-lib-shared/pom.xml +++ b/src/it/it0016-layout/it0016-lib-shared-layout20/pom.xml @@ -28,10 +28,10 @@ under the License. <version>1.0-SNAPSHOT</version> </parent> - <artifactId>it0016-lib-shared</artifactId> + <artifactId>it0016-lib-shared-layout20</artifactId> <packaging>nar</packaging> - <name>Maven NAR Shared Library</name> + <name>Maven NAR Shared Library (Layout20)</name> <version>1.0-SNAPSHOT</version> <description> Simple shared library and test file diff --git a/src/it/it0016-layout/it0016-lib-shared/src/main/c/HelloWorldLib.c b/src/it/it0016-layout/it0016-lib-shared-layout20/src/main/c/HelloWorldLib.c index 9f65143..9f65143 100644 --- a/src/it/it0016-layout/it0016-lib-shared/src/main/c/HelloWorldLib.c +++ b/src/it/it0016-layout/it0016-lib-shared-layout20/src/main/c/HelloWorldLib.c diff --git a/src/it/it0016-layout/it0016-lib-shared-layout20/src/main/include/HelloWorldLib.h b/src/it/it0016-layout/it0016-lib-shared-layout20/src/main/include/HelloWorldLib.h new file mode 100644 index 0000000..e801bec --- /dev/null +++ b/src/it/it0016-layout/it0016-lib-shared-layout20/src/main/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/it0016-layout/it0016-lib-shared-layout20/src/test/c/HelloWorldTest.c b/src/it/it0016-layout/it0016-lib-shared-layout20/src/test/c/HelloWorldTest.c new file mode 100644 index 0000000..4aa35d8 --- /dev/null +++ b/src/it/it0016-layout/it0016-lib-shared-layout20/src/test/c/HelloWorldTest.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/it/it0016-layout/it0016-lib-shared-layout21/pom.xml b/src/it/it0016-layout/it0016-lib-shared-layout21/pom.xml new file mode 100644 index 0000000..8eceedc --- /dev/null +++ b/src/it/it0016-layout/it0016-lib-shared-layout21/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>it0016-pom</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + + <artifactId>it0016-lib-shared-layout21</artifactId> + <packaging>nar</packaging> + + <name>Maven NAR Shared Library (Layout21)</name> + <version>1.0-SNAPSHOT</version> + <description> + Simple shared library and test file + </description> + <url>http://maven.apache.org/</url> + + <properties> + <skipTests>true</skipTests> + </properties> + + <build> + <defaultGoal>install</defaultGoal> + <plugins> + <plugin> + <artifactId>maven-nar-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <layout>NarLayout21</layout> + <libraries> + <library> + <type>shared</type> + </library> + </libraries> + <tests> + <test> + <name>HelloWorldTest</name> + <link>shared</link> + </test> + </tests> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/src/it/it0016-layout/it0016-lib-shared-layout21/src/main/c/HelloWorldLib.c b/src/it/it0016-layout/it0016-lib-shared-layout21/src/main/c/HelloWorldLib.c new file mode 100644 index 0000000..9f65143 --- /dev/null +++ b/src/it/it0016-layout/it0016-lib-shared-layout21/src/main/c/HelloWorldLib.c @@ -0,0 +1,7 @@ +#include <stdio.h> +#include "HelloWorldLib.h" + +char* HelloWorldLib_sayHello() { + return "Hello NAR LIB World!"; +} + diff --git a/src/it/it0016-layout/it0016-lib-shared-layout21/src/main/include/HelloWorldLib.h b/src/it/it0016-layout/it0016-lib-shared-layout21/src/main/include/HelloWorldLib.h new file mode 100644 index 0000000..e801bec --- /dev/null +++ b/src/it/it0016-layout/it0016-lib-shared-layout21/src/main/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/it0016-layout/it0016-lib-shared-layout21/src/test/c/HelloWorldTest.c b/src/it/it0016-layout/it0016-lib-shared-layout21/src/test/c/HelloWorldTest.c new file mode 100644 index 0000000..4aa35d8 --- /dev/null +++ b/src/it/it0016-layout/it0016-lib-shared-layout21/src/test/c/HelloWorldTest.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/it/it0016-layout/lib/x86_64-MacOSX-g++/shared/history.xml b/src/it/it0016-layout/lib/x86_64-MacOSX-g++/shared/history.xml new file mode 100644 index 0000000..2004850 --- /dev/null +++ b/src/it/it0016-layout/lib/x86_64-MacOSX-g++/shared/history.xml @@ -0,0 +1,8 @@ +<?xml version='1.0' encoding='UTF-8'?> +<history> + <processor signature="4.2.1 -dynamiclib -fexceptions -lstdc++"> + <target file="libit0016-lib-shared-1.0-SNAPSHOT.dylib" lastModified="125783ffc48"> + <source file="../../../../../obj/x86_64-MacOSX-g++/HelloWorldLib.o" lastModified="125783ff478"/> + </target> + </processor> +</history> diff --git a/src/it/it0016-layout/lib/x86_64-MacOSX-g++/shared/libit0016-lib-shared-1.0-SNAPSHOT.dylib b/src/it/it0016-layout/lib/x86_64-MacOSX-g++/shared/libit0016-lib-shared-1.0-SNAPSHOT.dylib Binary files differnew file mode 100644 index 0000000..fa18419 --- /dev/null +++ b/src/it/it0016-layout/lib/x86_64-MacOSX-g++/shared/libit0016-lib-shared-1.0-SNAPSHOT.dylib diff --git a/src/it/it0016-layout/pom.xml b/src/it/it0016-layout/pom.xml index 0fc5b68..c72a6f3 100644 --- a/src/it/it0016-layout/pom.xml +++ b/src/it/it0016-layout/pom.xml @@ -44,7 +44,9 @@ under the License. </build> <modules> - <module>it0016-executable-dep-lib-shared</module> - <module>it0016-lib-shared</module> + <module>it0016-executable-dep-lib-shared-layout20</module> + <module>it0016-executable-dep-lib-shared-layout21</module> + <module>it0016-lib-shared-layout20</module> + <module>it0016-lib-shared-layout21</module> </modules> </project> diff --git a/src/main/java/org/apache/maven/plugin/nar/AbstractCompileMojo.java b/src/main/java/org/apache/maven/plugin/nar/AbstractCompileMojo.java index d51861b..a38a1b5 100644 --- a/src/main/java/org/apache/maven/plugin/nar/AbstractCompileMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/AbstractCompileMojo.java @@ -128,7 +128,7 @@ public abstract class AbstractCompileMojo * @parameter expression="" */ private Java java; - + /** * Layout to be used for building and upacking artifacts * @@ -136,8 +136,9 @@ public abstract class AbstractCompileMojo * @required */ private String layout; + private NarLayout narLayout; - + private NarInfo narInfo; private List/* <String> */dependencyLibOrder; @@ -186,32 +187,38 @@ public abstract class AbstractCompileMojo return fortran; } - protected final int getMaxCores( AOL aol ) throws MojoExecutionException + protected final int getMaxCores( AOL aol ) + throws MojoExecutionException { return getNarInfo().getProperty( aol, "maxCores", maxCores ); } - protected final boolean useLibtool( AOL aol ) throws MojoExecutionException + protected final boolean useLibtool( AOL aol ) + throws MojoExecutionException { return getNarInfo().getProperty( aol, "libtool", libtool ); } - protected final boolean failOnError( AOL aol ) throws MojoExecutionException + protected final boolean failOnError( AOL aol ) + throws MojoExecutionException { return getNarInfo().getProperty( aol, "failOnError", failOnError ); } - protected final String getRuntime( AOL aol ) throws MojoExecutionException + protected final String getRuntime( AOL aol ) + throws MojoExecutionException { return getNarInfo().getProperty( aol, "runtime", runtime ); } - protected final String getOutput( AOL aol ) throws MojoExecutionException + protected final String getOutput( AOL aol ) + throws MojoExecutionException { return getNarInfo().getProperty( aol, "output", output ); } - protected final File getJavaHome( AOL aol ) throws MojoExecutionException + protected final File getJavaHome( AOL aol ) + throws MojoExecutionException { // FIXME should be easier by specifying default... return getNarInfo().getProperty( aol, "javaHome", NarUtil.getJavaHome( javaHome, getOS() ) ); @@ -265,7 +272,8 @@ public abstract class AbstractCompileMojo return dependencyLibOrder; } - protected final NarInfo getNarInfo() throws MojoExecutionException + protected final NarInfo getNarInfo() + throws MojoExecutionException { if ( narInfo == null ) { @@ -275,31 +283,15 @@ public abstract class AbstractCompileMojo } return narInfo; } - + // FIXME, needs to maybe move up - protected final NarLayout getLayout() throws MojoExecutionException + protected final NarLayout getLayout() + throws MojoExecutionException { - if (narLayout == null) { - String className = layout.indexOf( '.' ) < 0 ? NarLayout21.class.getPackage().getName()+"."+layout : layout; - getLog().debug( "Using "+className); - Class cls; - try - { - cls = Class.forName( className ); - narLayout = (NarLayout)cls.newInstance(); - } - catch ( ClassNotFoundException e ) - { - throw new MojoExecutionException( "Cannot find class for layout "+className, e ); - } - catch ( InstantiationException e ) - { - throw new MojoExecutionException( "Cannot instantiate class for layout "+className, e ); - } - catch ( IllegalAccessException e ) - { - throw new MojoExecutionException( "Cannot access class for layout "+className, e ); - } + if ( narLayout == null ) + { + narLayout = + AbstractNarLayout.getLayout( layout, getLog() ); } return narLayout; } diff --git a/src/main/java/org/apache/maven/plugin/nar/AbstractNarLayout.java b/src/main/java/org/apache/maven/plugin/nar/AbstractNarLayout.java index 2d13e63..3f2cf17 100644 --- a/src/main/java/org/apache/maven/plugin/nar/AbstractNarLayout.java +++ b/src/main/java/org/apache/maven/plugin/nar/AbstractNarLayout.java @@ -21,12 +21,17 @@ package org.apache.maven.plugin.nar; import java.io.File; import java.io.IOException; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectHelper; import org.codehaus.plexus.archiver.Archiver; import org.codehaus.plexus.archiver.ArchiverException; +import org.codehaus.plexus.archiver.UnArchiver; import org.codehaus.plexus.archiver.manager.ArchiverManager; import org.codehaus.plexus.archiver.manager.NoSuchArchiverException; @@ -37,9 +42,20 @@ import org.codehaus.plexus.archiver.manager.NoSuchArchiverException; public abstract class AbstractNarLayout implements NarLayout, NarConstants { + private Log log; - protected final void attachNar( ArchiverManager archiverManager, MavenProjectHelper projectHelper, MavenProject project, - String classifier, File dir, String include ) + protected AbstractNarLayout( Log log ) + { + this.log = log; + } + + protected Log getLog() + { + return log; + } + + protected final void attachNar( ArchiverManager archiverManager, MavenProjectHelper projectHelper, + MavenProject project, String classifier, File dir, String include ) throws MojoExecutionException { File narFile = @@ -70,4 +86,106 @@ public abstract class AbstractNarLayout } projectHelper.attachArtifact( project, NarConstants.NAR_TYPE, classifier, narFile ); } + + protected void unpackNarAndProcess( ArchiverManager archiverManager, File file, File narLocation, String os, + String linkerName, AOL defaultAOL ) + throws MojoExecutionException, MojoFailureException + { + + final String gpp = "g++"; + final String gcc = "gcc"; + + narLocation.mkdirs(); + + // unpack + try + { + UnArchiver unArchiver; + unArchiver = archiverManager.getUnArchiver( NarConstants.NAR_ROLE_HINT ); + unArchiver.setSourceFile( file ); + unArchiver.setDestDirectory( narLocation ); + unArchiver.extract(); + } + catch ( NoSuchArchiverException e ) + { + throw new MojoExecutionException( "Error unpacking file: " + file + " to: " + narLocation, e ); + } + catch ( ArchiverException e ) + { + throw new MojoExecutionException( "Error unpacking file: " + file + " to: " + narLocation, e ); + } + + // process + if ( !NarUtil.getOS( os ).equals( OS.WINDOWS ) ) + { + NarUtil.makeExecutable( new File( narLocation, "bin/" + defaultAOL ), log ); + // FIXME clumsy + if ( defaultAOL.hasLinker( gpp ) ) + { + 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 ) ) + { + NarUtil.runRanlib( new File( narLocation, "lib/" + defaultAOL ), log ); + // FIXME clumsy + if ( defaultAOL.hasLinker( gpp ) ) + { + NarUtil.runRanlib( + new File( narLocation, "lib/" + NarUtil.replace( gpp, gcc, defaultAOL.toString() ) ), + log ); + } + } + } + + /** + * @return + * @throws MojoExecutionException + */ + public static NarLayout getLayout( String layoutName, Log log ) + throws MojoExecutionException + { + String className = + layoutName.indexOf( '.' ) < 0 ? NarLayout21.class.getPackage().getName() + "." + layoutName : layoutName; + log.debug( "Using " + className ); + Class cls; + try + { + cls = Class.forName( className ); + Constructor ctor = cls.getConstructor( new Class[] { Log.class } ); + return (NarLayout) ctor.newInstance( new Object[] { log } ); + } + catch ( ClassNotFoundException e ) + { + throw new MojoExecutionException( "Cannot find class for layout " + className, e ); + } + catch ( InstantiationException e ) + { + throw new MojoExecutionException( "Cannot instantiate class for layout " + className, e ); + } + catch ( IllegalAccessException e ) + { + throw new MojoExecutionException( "Cannot access class for layout " + className, e ); + } + catch ( SecurityException e ) + { + throw new MojoExecutionException( "Cannot access class for layout " + className, e ); + } + catch ( NoSuchMethodException e ) + { + throw new MojoExecutionException( "Cannot find ctor(Log) for layout " + className, e ); + } + catch ( IllegalArgumentException e ) + { + throw new MojoExecutionException( "Wrong arguments ctor(Log) for layout " + className, e ); + } + catch ( InvocationTargetException e ) + { + throw new MojoExecutionException( "Cannot invokector(Log) for layout " + className, e ); + } + } + } 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 2b6b5bb..15f4119 100644 --- a/src/main/java/org/apache/maven/plugin/nar/AbstractResourcesMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/AbstractResourcesMojo.java @@ -81,7 +81,9 @@ public abstract class AbstractResourcesMojo File includeDir = new File( srcDir, resourceIncludeDir ); if ( includeDir.exists() ) { - File includeDstDir = getLayout().getIncludeDirectory( getTargetDirectory() ); + File includeDstDir = + getLayout().getIncludeDirectory( getTargetDirectory(), getMavenProject().getArtifactId(), + getMavenProject().getVersion() ); getLog().debug( "Copying includes from " + includeDir + " to " + includeDstDir ); copied += NarUtil.copyDirectoryStructure( includeDir, includeDstDir, null, NarUtil.DEFAULT_EXCLUDES ); } @@ -98,7 +100,9 @@ public abstract class AbstractResourcesMojo File binDir = new File( srcDir, resourceBinDir ); if ( binDir.exists() ) { - File binDstDir = getLayout().getBinDirectory( getTargetDirectory(), aol ); + File binDstDir = + getLayout().getBinDirectory( getTargetDirectory(), getMavenProject().getArtifactId(), + getMavenProject().getVersion(), aol ); getLog().debug( "Copying binaries from " + binDir + " to " + binDstDir ); copied += NarUtil.copyDirectoryStructure( binDir, binDstDir, null, NarUtil.DEFAULT_EXCLUDES ); } @@ -120,7 +124,9 @@ public abstract class AbstractResourcesMojo { Library library = (Library) i.next(); String type = library.getType(); - File libDstDir = getLayout().getLibDirectory( getTargetDirectory(), aol, type ); + File libDstDir = + getLayout().getLibDirectory( getTargetDirectory(), getMavenProject().getArtifactId(), + getMavenProject().getVersion(), aol, type ); getLog().debug( "Copying libraries from " + libDir + " to " + libDstDir ); // filter files for lib diff --git a/src/main/java/org/apache/maven/plugin/nar/NarArtifact.java b/src/main/java/org/apache/maven/plugin/nar/NarArtifact.java index 4372b2c..3da6abd 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarArtifact.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarArtifact.java @@ -43,4 +43,8 @@ public class NarArtifact { return narInfo; } + + public String getBaseFilename() { + return getArtifactId()+"-"+getVersion()+"-"+getClassifier(); + } } diff --git a/src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java index fe5f7cc..d0718f7 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java @@ -102,11 +102,13 @@ public class NarCompileMojo && dependency.getGroupId().equals( project.getGroupId() ) && dependency.getVersion().equals( project.getVersion() ) && dependency.getType().equals( "jar" ) ) { - getLog().info( "Added intermodule dependency to " + project.getArtifact()+" in "+project.getBuild().getDirectory() ); + getLog().info( + "Added intermodule dependency to " + project.getArtifact() + " in " + + project.getBuild().getDirectory() ); } } } - + // make sure destination is there getTargetDirectory().mkdirs(); @@ -131,7 +133,11 @@ public class NarCompileMojo try { // FIXME, should the include paths be defined at a higher level ? - getCpp().copyIncludeFiles( getMavenProject(), getLayout().getIncludeDirectory( getTargetDirectory() ) ); + getCpp().copyIncludeFiles( + getMavenProject(), + getLayout().getIncludeDirectory( getTargetDirectory(), + getMavenProject().getArtifactId(), + getMavenProject().getVersion() ) ); } catch ( IOException e ) { @@ -170,7 +176,7 @@ public class NarCompileMojo // configure task CCTask task = new CCTask(); task.setProject( antProject ); - + // subsystem SubsystemEnum subSystem = new SubsystemEnum(); subSystem.setValue( library.getSubSystem() ); @@ -196,11 +202,15 @@ public class NarCompileMojo File outDir; if ( type.equals( Library.EXECUTABLE ) ) { - outDir = getLayout().getBinDirectory( getTargetDirectory(), getAOL().toString() ); + outDir = + getLayout().getBinDirectory( getTargetDirectory(), getMavenProject().getArtifactId(), + getMavenProject().getVersion(), getAOL().toString() ); } else { - outDir = getLayout().getLibDirectory( getTargetDirectory(), getAOL().toString(), type ); + outDir = + getLayout().getLibDirectory( getTargetDirectory(), getMavenProject().getArtifactId(), + getMavenProject().getVersion(), getAOL().toString(), type ); } outDir.mkdirs(); @@ -254,7 +264,7 @@ public class NarCompileMojo { task.addConfiguredCompiler( fortran ); } - + // add javah include path File jniDirectory = getJavah().getJniDirectory(); if ( jniDirectory.exists() ) @@ -274,8 +284,12 @@ public class NarCompileMojo getLog().debug( "Looking for " + narDependency + " found binding " + binding ); if ( !binding.equals( Library.JNI ) ) { - File include = new File( getNarManager().getNarFile( narDependency ).getParentFile(), "nar/include" ); - getLog().debug( "Looking for for directory: " + include ); + // FIXED NAR-90 + File unpackDirectory = getNarManager().getUnpackDirectory( narDependency ); + File include = + getLayout().getIncludeDirectory( unpackDirectory, narDependency.getArtifactId(), + narDependency.getVersion() ); + getLog().info( "Looking for include directory: " + include ); if ( include.exists() ) { task.createIncludePath().setPath( include.getPath() ); @@ -339,11 +353,15 @@ public class NarCompileMojo if ( !binding.equals( Library.JNI ) ) { - File dir = new File( getNarManager().getNarFile( dependency ).getParentFile(), "nar" ); - // FIXME NAR-90 - // dir = getLayout().getLibDirectory( dir, aol, binding ); - dir = new File( dir, "lib/" + aol.toString() + "/" + binding ); - getLog().debug( "Looking for Library Directory: " + dir ); + File unpackDirectory = getNarManager().getUnpackDirectory( dependency ); + + // FIXED NAR-90 + File dir = + getLayout().getLibDirectory( unpackDirectory, dependency.getArtifactId(), + dependency.getVersion(), aol.toString(), binding ); + + // dir = new File( dir, "lib/" + aol.toString() + "/" + binding ); + getLog().info( "Looking for Library Directory: " + dir ); if ( dir.exists() ) { LibrarySet libSet = new LibrarySet(); diff --git a/src/main/java/org/apache/maven/plugin/nar/NarFileLayout.java b/src/main/java/org/apache/maven/plugin/nar/NarFileLayout.java new file mode 100644 index 0000000..6b36e62 --- /dev/null +++ b/src/main/java/org/apache/maven/plugin/nar/NarFileLayout.java @@ -0,0 +1,50 @@ +/* + * 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. + */ + +package org.apache.maven.plugin.nar; + + +/** + * Defines the layout inside the nar file. + * + * @author Mark Donszelmann (Mark.Donszelmann@gmail.com) + */ +public interface NarFileLayout +{ + /** + * Specifies where libraries are stored + * + * @return + */ + String getLibDirectory(String aol, String type ); + + /** + * Specifies where includes are stored + * + * @return + */ + String getIncludeDirectory(); + + /** + * Specifies where binaries are stored + * + * @return + */ + String getBinDirectory(String aol ); +} diff --git a/src/main/java/org/apache/maven/plugin/nar/NarFileLayout10.java b/src/main/java/org/apache/maven/plugin/nar/NarFileLayout10.java new file mode 100644 index 0000000..e4c8979 --- /dev/null +++ b/src/main/java/org/apache/maven/plugin/nar/NarFileLayout10.java @@ -0,0 +1,57 @@ +/* + * 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. + */ + +package org.apache.maven.plugin.nar; + +import java.io.File; + +/** + * @author Mark Donszelmann (Mark.Donszelmann@gmail.com) + */ +public class NarFileLayout10 + implements NarFileLayout +{ + + /* + * (non-Javadoc) + * @see org.apache.maven.plugin.nar.NarFileLayout#getIncludeDirectory() + */ + public String getIncludeDirectory() + { + return "include"; + } + + /* + * (non-Javadoc) + * @see org.apache.maven.plugin.nar.NarFileLayout#getLibDirectory(java.lang.String, java.lang.String) + */ + public String getLibDirectory( String aol, String type ) + { + return "lib" + File.separator + aol + File.separator + type; + } + + /* + * (non-Javadoc) + * @see org.apache.maven.plugin.nar.NarFileLayout#getBinDirectory(java.lang.String) + */ + public String getBinDirectory( String aol ) + { + return "bin" + File.separator + aol; + } +} diff --git a/src/main/java/org/apache/maven/plugin/nar/NarIntegrationTestMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarIntegrationTestMojo.java index ffab127..d6c9c87 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarIntegrationTestMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarIntegrationTestMojo.java @@ -86,7 +86,7 @@ import org.codehaus.plexus.util.StringUtils; * @goal nar-integration-test * @phase integration-test */ -//DUNS, changed class name, inheritance, goal and phase +// DUNS, changed class name, inheritance, goal and phase public class NarIntegrationTestMojo extends AbstractCompileMojo { @@ -107,7 +107,7 @@ public class NarIntegrationTestMojo // DUNS added because of naming conflict /** * Skip running of NAR integration test plugin - * + * * @parameter expression="${skipNar}" default-value="false" */ private boolean skipNar; @@ -121,18 +121,18 @@ public class NarIntegrationTestMojo * @since 2.4 */ private boolean skipNarTests; - + // DUNS changed to nar. because of naming conflict /** - * DEPRECATED This old parameter is just like skipTests, but bound to the old property maven.test.skip.exec. - * Use -DskipTests instead; it's shorter. + * DEPRECATED This old parameter is just like skipTests, but bound to the old property maven.test.skip.exec. Use + * -DskipTests instead; it's shorter. * * @deprecated * @parameter expression="${nar.test.skip.exec}" * @since 2.3 */ private boolean skipNarExec; - + // DUNS changed to nar. because of naming conflict /** * Set this to true to ignore a failure during testing. Its use is NOT RECOMMENDED, but quite convenient on @@ -161,7 +161,7 @@ public class NarIntegrationTestMojo /** * The directory containing generated classes of the project being tested. - * + * * @parameter expression="${project.build.outputDirectory}" * @required */ @@ -169,7 +169,7 @@ public class NarIntegrationTestMojo /** * The Maven Project Object - * + * * @parameter expression="${project}" * @required * @readonly @@ -193,7 +193,7 @@ public class NarIntegrationTestMojo * @since 2.4 */ private List additionalClasspathElements; - + /** * Base directory where all reports are written to. * @@ -212,10 +212,9 @@ public class NarIntegrationTestMojo /** * Specify this parameter to run individual tests by file name, overriding the <code>includes/excludes</code> - * parameters. Each pattern you specify here will be used to create an - * include pattern formatted like <code>**/${test}.java</code>, so you can just type "-Dtest=MyTest" - * to run a single test called "foo/MyTest.java". This parameter will override the TestNG suiteXmlFiles - * parameter. + * parameters. Each pattern you specify here will be used to create an include pattern formatted like + * <code>**/${test}.java</code>, so you can just type "-Dtest=MyTest" to run a single test called + * "foo/MyTest.java". This parameter will override the TestNG suiteXmlFiles parameter. * * @parameter expression="${test}" */ @@ -224,8 +223,8 @@ public class NarIntegrationTestMojo /** * List of patterns (separated by commas) used to specify the tests that should be included in testing. When not * specified and when the <code>test</code> parameter is not specified, the default includes will be - * <code>**/Test*.java **/*Test.java **/*TestCase.java</code>. This parameter is ignored if - * TestNG suiteXmlFiles are specified. + * <code>**/Test*.java **/*Test.java **/*TestCase.java</code>. This parameter is ignored if TestNG + * suiteXmlFiles are specified. * * @parameter */ @@ -234,8 +233,8 @@ public class NarIntegrationTestMojo /** * List of patterns (separated by commas) used to specify the tests that should be excluded in testing. When not * specified and when the <code>test</code> parameter is not specified, the default excludes will be - * <code>**/*$*</code> (which excludes all inner classes). This parameter is ignored if - * TestNG suiteXmlFiles are specified. + * <code>**/*$*</code> (which excludes all inner classes). This parameter is ignored if TestNG suiteXmlFiles are + * specified. * * @parameter */ @@ -250,7 +249,7 @@ public class NarIntegrationTestMojo * @readonly */ // DUNS, removed, already in superclass - //private ArtifactRepository localRepository; + // private ArtifactRepository localRepository; /** * List of System properties to pass to the JUnit tests. @@ -260,9 +259,9 @@ public class NarIntegrationTestMojo private Properties systemProperties; /** - * List of properties for configuring all TestNG related configurations. This is the new - * preferred method of configuring TestNG. - * + * List of properties for configuring all TestNG related configurations. This is the new preferred method of + * configuring TestNG. + * * @parameter * @since 2.4 */ @@ -324,7 +323,7 @@ public class NarIntegrationTestMojo * @since 2.4 */ private Boolean failIfNoTests; - + /** * Option to specify the forking mode. Can be "never", "once" or "always". "none" and "pertest" are also accepted * for backwards compatibility. @@ -352,25 +351,24 @@ public class NarIntegrationTestMojo private String argLine; /** - * Attach a debugger to the forked JVM. If set to "true", the process will suspend and - * wait for a debugger to attach on port 5005. If set to some other string, that - * string will be appended to the argLine, allowing you to configure arbitrary - * debuggability options (without overwriting the other options specified in the argLine). + * Attach a debugger to the forked JVM. If set to "true", the process will suspend and wait for a debugger to attach + * on port 5005. If set to some other string, that string will be appended to the argLine, allowing you to configure + * arbitrary debuggability options (without overwriting the other options specified in the argLine). * * @parameter expression="${maven.surefire.debug}" * @since 2.4 */ private String debugForkedProcess; - + /** - * Kill the forked test process after a certain number of seconds. If set to 0, - * wait forever for the process, never timing out. + * Kill the forked test process after a certain number of seconds. If set to 0, wait forever for the process, never + * timing out. * * @parameter expression="${surefire.timeout}" * @since 2.4 */ private int forkedProcessTimeoutInSeconds; - + /** * Additional environments to set on the command line. * @@ -389,8 +387,9 @@ public class NarIntegrationTestMojo /** * When false it makes tests run using the standard classloader delegation instead of the default Maven isolated - * classloader. Only used when forking (forkMode is not "none").<br/> Setting it to false helps with some problems - * caused by conflicts between xml parsers in the classpath and the Java 5 provider parser. + * classloader. Only used when forking (forkMode is not "none").<br/> + * Setting it to false helps with some problems caused by conflicts between xml parsers in the classpath and the + * Java 5 provider parser. * * @parameter expression="${childDelegation}" default-value="false" * @since 2.1 @@ -398,8 +397,8 @@ public class NarIntegrationTestMojo private boolean childDelegation; /** - * (TestNG only) Groups for this test. Only classes/methods/etc decorated with one of the groups specified here will be included - * in test run, if specified. This parameter is overridden if suiteXmlFiles are specified. + * (TestNG only) Groups for this test. Only classes/methods/etc decorated with one of the groups specified here will + * be included in test run, if specified. This parameter is overridden if suiteXmlFiles are specified. * * @parameter expression="${groups}" * @since 2.2 @@ -407,8 +406,8 @@ public class NarIntegrationTestMojo private String groups; /** - * (TestNG only) Excluded groups. Any methods/classes/etc with one of the groups specified in this list will specifically not be - * run. This parameter is overridden if suiteXmlFiles are specified. + * (TestNG only) Excluded groups. Any methods/classes/etc with one of the groups specified in this list will + * specifically not be run. This parameter is overridden if suiteXmlFiles are specified. * * @parameter expression="${excludedGroups}" * @since 2.2 @@ -416,15 +415,15 @@ public class NarIntegrationTestMojo private String excludedGroups; /** - * (TestNG only) List of TestNG suite xml file locations, seperated by commas. Note that suiteXmlFiles is incompatible - * with several other parameters on this plugin, like includes/excludes. This parameter is ignored if + * (TestNG only) List of TestNG suite xml file locations, seperated by commas. Note that suiteXmlFiles is + * incompatible with several other parameters on this plugin, like includes/excludes. This parameter is ignored if * the "test" parameter is specified (allowing you to run a single test instead of an entire suite). * * @parameter * @since 2.2 */ private File[] suiteXmlFiles; - + /** * Allows you to specify the name of the JUnit artifact. If not set, <code>junit:junit</code> will be used. * @@ -432,7 +431,7 @@ public class NarIntegrationTestMojo * @since 2.3.1 */ private String junitArtifactName; - + /** * Allows you to specify the name of the TestNG artifact. If not set, <code>org.testng:testng</code> will be used. * @@ -440,10 +439,10 @@ public class NarIntegrationTestMojo * @since 2.3.1 */ private String testNGArtifactName; - + /** - * (TestNG only) The attribute thread-count allows you to specify how many threads should be allocated for this execution. Only - * makes sense to use in conjunction with parallel. + * (TestNG only) The attribute thread-count allows you to specify how many threads should be allocated for this + * execution. Only makes sense to use in conjunction with parallel. * * @parameter expression="${threadCount}" * @since 2.2 @@ -451,9 +450,9 @@ public class NarIntegrationTestMojo private int threadCount; /** - * (TestNG only) When you use the parallel attribute, TestNG will try to run all your test methods in separate threads, except for - * methods that depend on each other, which will be run in the same thread in order to respect their order of - * execution. + * (TestNG only) When you use the parallel attribute, TestNG will try to run all your test methods in separate + * threads, except for methods that depend on each other, which will be run in the same thread in order to respect + * their order of execution. * * @parameter expression="${parallel}" * @todo test how this works with forking, and console/file output parallelism @@ -515,21 +514,19 @@ public class NarIntegrationTestMojo /** * Option to pass dependencies to the system's classloader instead of using an isolated class loader when forking. * Prevents problems with JDKs which implement the service provider lookup mechanism by using the system's - * classloader. Default value is "true". + * classloader. Default value is "true". * * @parameter expression="${surefire.useSystemClassLoader}" * @since 2.3 */ private Boolean useSystemClassLoader; - + /** - * By default, Surefire forks your tests using a manifest-only jar; set this parameter - * to "false" to force it to launch your tests with a plain old Java classpath. - * (See http://maven.apache.org/plugins/maven-surefire-plugin/examples/class-loading.html - * for a more detailed explanation of manifest-only jars and their benefits.) - * - * Default value is "true". Beware, setting this to "false" may cause your tests to - * fail on Windows if your classpath is too long. + * By default, Surefire forks your tests using a manifest-only jar; set this parameter to "false" to force it to + * launch your tests with a plain old Java classpath. (See + * http://maven.apache.org/plugins/maven-surefire-plugin/examples/class-loading.html for a more detailed explanation + * of manifest-only jars and their benefits.) Default value is "true". Beware, setting this to "false" may cause + * your tests to fail on Windows if your classpath is too long. * * @parameter expression="${surefire.useManifestOnlyJar}" default-value="true" * @since 2.4.3 @@ -544,16 +541,15 @@ public class NarIntegrationTestMojo * @since 2.3.1 */ private boolean enableAssertions; - + /** - * The current build session instance. - * + * The current build session instance. + * * @parameter expression="${session}" * @required * @readonly */ private MavenSession session; - // DUNS, changed name public void narExecute() @@ -579,7 +575,7 @@ public class NarIntegrationTestMojo throw new MojoExecutionException( e.getMessage(), e ); } - if ( originalSystemProperties != null && !surefireBooter.isForking() ) + if ( originalSystemProperties != null && !surefireBooter.isForking() ) { // restore system properties, only makes sense when not forking.. System.setProperties( originalSystemProperties ); @@ -589,9 +585,9 @@ public class NarIntegrationTestMojo { return; } - + String msg; - + if ( result == SurefireBooter.NO_TESTS_EXIT_CODE ) { if ( ( failIfNoTests == null ) || !failIfNoTests.booleanValue() ) @@ -599,13 +595,18 @@ public class NarIntegrationTestMojo return; } // TODO: i18n - throw new MojoFailureException( "No tests were executed! (Set -DfailIfNoTests=false to ignore this error.)" ); - } else { + throw new MojoFailureException( + "No tests were executed! (Set -DfailIfNoTests=false to ignore this error.)" ); + } + else + { // TODO: i18n - msg = "There are test failures.\n\nPlease refer to " + reportsDirectory + " for the individual test results."; + msg = + "There are test failures.\n\nPlease refer to " + reportsDirectory + + " for the individual test results."; } - + if ( testFailureIgnore ) { getLog().error( msg ); @@ -619,7 +620,7 @@ public class NarIntegrationTestMojo private boolean verifyParameters() throws MojoFailureException - { + { // DUNS if ( skipNar || skipNarTests || skipNarExec ) { @@ -646,8 +647,8 @@ public class NarIntegrationTestMojo } /** - * Converts old TestNG configuration parameters over to new properties based configuration - * method. (if any are defined the old way) + * Converts old TestNG configuration parameters over to new properties based configuration method. (if any are + * defined the old way) */ private void convertTestNGParameters() { @@ -708,11 +709,11 @@ public class NarIntegrationTestMojo if ( testNgArtifact != null ) { VersionRange range = VersionRange.createFromVersionSpec( "[4.7,)" ); - if ( !range.containsVersion( new DefaultArtifactVersion(testNgArtifact.getVersion()) ) ) + if ( !range.containsVersion( new DefaultArtifactVersion( testNgArtifact.getVersion() ) ) ) { throw new MojoFailureException( - "TestNG support requires version 4.7 or above. You have declared version " + - testNgArtifact.getVersion() ); + "TestNG support requires version 4.7 or above. You have declared version " + + testNgArtifact.getVersion() ); } convertTestNGParameters(); @@ -741,8 +742,8 @@ public class NarIntegrationTestMojo } catch ( ArtifactNotFoundException e ) { - throw new MojoExecutionException( "Unable to locate required surefire provider dependency: " + - e.getMessage(), e ); + throw new MojoExecutionException( "Unable to locate required surefire provider dependency: " + + e.getMessage(), e ); } catch ( InvalidVersionSpecificationException e ) { @@ -759,10 +760,11 @@ public class NarIntegrationTestMojo { throw new MojoExecutionException( "suiteXmlFiles is configured, but there is no TestNG dependency" ); } - + // TODO: properties should be passed in here too - surefireBooter.addTestSuite( "org.apache.maven.surefire.testng.TestNGXmlTestSuite", new Object[]{ - suiteXmlFiles, testSourceDirectory.getAbsolutePath(), testNgArtifact.getVersion(), testNgArtifact.getClassifier(), properties, reportsDirectory} ); + surefireBooter.addTestSuite( "org.apache.maven.surefire.testng.TestNGXmlTestSuite", new Object[] { + suiteXmlFiles, testSourceDirectory.getAbsolutePath(), testNgArtifact.getVersion(), + testNgArtifact.getClassifier(), properties, reportsDirectory } ); } else { @@ -790,12 +792,12 @@ public class NarIntegrationTestMojo for ( int i = 0; i < testRegexes.length; i++ ) { String testRegex = testRegexes[i]; - if (testRegex.endsWith( ".java" )) + if ( testRegex.endsWith( ".java" ) ) { testRegex = testRegex.substring( 0, testRegex.length() - 5 ); } // Allow paths delimited by '.' or '/' - testRegex = testRegex.replace('.', '/'); + testRegex = testRegex.replace( '.', '/' ); includeList.add( "**/" + testRegex + ".java" ); } } @@ -815,8 +817,7 @@ public class NarIntegrationTestMojo } if ( excludeList == null || excludeList.size() == 0 ) { - excludeList = - new ArrayList( Arrays.asList( new String[] { "**/*$*" } ) ); + excludeList = new ArrayList( Arrays.asList( new String[] { "**/*$*" } ) ); } } @@ -824,13 +825,13 @@ public class NarIntegrationTestMojo { surefireBooter.addTestSuite( "org.apache.maven.surefire.testng.TestNGDirectoryTestSuite", new Object[] { testClassesDirectory, includeList, excludeList, testSourceDirectory.getAbsolutePath(), - testNgArtifact.getVersion(), testNgArtifact.getClassifier(), properties, reportsDirectory} ); + testNgArtifact.getVersion(), testNgArtifact.getClassifier(), properties, reportsDirectory } ); } else { String junitDirectoryTestSuite; - if ( junitArtifact != null && junitArtifact.getBaseVersion() != null && - junitArtifact.getBaseVersion().startsWith( "4" ) ) + if ( junitArtifact != null && junitArtifact.getBaseVersion() != null + && junitArtifact.getBaseVersion().startsWith( "4" ) ) { junitDirectoryTestSuite = "org.apache.maven.surefire.junit4.JUnit4DirectoryTestSuite"; } @@ -873,36 +874,38 @@ public class NarIntegrationTestMojo surefireBooter.addClassPathUrl( classpathElement ); } - + Toolchain tc = getToolchain(); - - if (tc != null) + + if ( tc != null ) { - getLog().info("Toolchain in surefire-plugin: " + tc); - if (ForkConfiguration.FORK_NEVER.equals( forkMode ) ) + getLog().info( "Toolchain in surefire-plugin: " + tc ); + if ( ForkConfiguration.FORK_NEVER.equals( forkMode ) ) { forkMode = ForkConfiguration.FORK_ONCE; } - if ( jvm != null ) + if ( jvm != null ) { - getLog().warn("Toolchains are ignored, 'executable' parameter is set to " + jvm); - } else { - jvm = tc.findTool("java"); //NOI18N + getLog().warn( "Toolchains are ignored, 'executable' parameter is set to " + jvm ); + } + else + { + jvm = tc.findTool( "java" ); // NOI18N } } - + if ( additionalClasspathElements != null ) { for ( Iterator i = additionalClasspathElements.iterator(); i.hasNext(); ) { String classpathElement = (String) i.next(); - + getLog().debug( " " + classpathElement ); - + surefireBooter.addClassPathUrl( classpathElement ); } } - + // ---------------------------------------------------------------------- // Forking // ---------------------------------------------------------------------- @@ -931,12 +934,13 @@ public class NarIntegrationTestMojo fork.setUseManifestOnlyJar( useManifestOnlyJar ); fork.setSystemProperties( systemProperties ); - + if ( "true".equals( debugForkedProcess ) ) { - debugForkedProcess = "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"; + debugForkedProcess = + "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"; } - + fork.setDebugLine( debugForkedProcess ); if ( jvm == null || "".equals( jvm ) ) @@ -957,7 +961,6 @@ public class NarIntegrationTestMojo fork.setWorkingDirectory( basedir ); } - // BEGINDUNS if ( argLine == null ) { @@ -968,7 +971,9 @@ public class NarIntegrationTestMojo if ( testJNIModule() ) { // Add libraries to java.library.path for testing - File jniLibraryPathEntry = getLayout().getLibDirectory( getTargetDirectory(), getAOL().toString(), Library.JNI ); + File jniLibraryPathEntry = + getLayout().getLibDirectory( getTargetDirectory(), getMavenProject().getArtifactId(), + getMavenProject().getVersion(), getAOL().toString(), Library.JNI ); if ( jniLibraryPathEntry.exists() ) { getLog().debug( "Adding library directory to java.library.path: " + jniLibraryPathEntry ); @@ -979,7 +984,9 @@ public class NarIntegrationTestMojo javaLibraryPath.append( jniLibraryPathEntry ); } - File sharedLibraryPathEntry = getLayout().getLibDirectory( getTargetDirectory(), getAOL().toString(), Library.SHARED ); + File sharedLibraryPathEntry = + getLayout().getLibDirectory( getTargetDirectory(), getMavenProject().getArtifactId(), + getMavenProject().getVersion(), getAOL().toString(), Library.SHARED ); if ( sharedLibraryPathEntry.exists() ) { getLog().debug( "Adding library directory to java.library.path: " + sharedLibraryPathEntry ); @@ -1011,10 +1018,11 @@ public class NarIntegrationTestMojo String binding = bindings[j]; if ( !binding.equals( Library.STATIC ) ) { - // FIXME NAR-90 in repo + // FIXED NAR-90 File depLibPathEntry = - new File( getNarManager().getNarFile( dependency ).getParent(), "nar/lib/" + getAOL() + "/" - + binding ); + getLayout().getLibDirectory( getNarManager().getUnpackDirectory( dependency ), + dependency.getArtifactId(), dependency.getVersion(), + getAOL().toString(), binding ); if ( depLibPathEntry.exists() ) { getLog().debug( "Adding dependency directory to java.library.path: " + depLibPathEntry ); @@ -1047,7 +1055,6 @@ public class NarIntegrationTestMojo } // ENDDUNS - fork.setArgLine( argLine ); fork.setEnvironmentVariables( environmentVariables ); @@ -1070,7 +1077,7 @@ public class NarIntegrationTestMojo } surefireBooter.setFailIfNoTests( failIfNoTests == null ? false : failIfNoTests.booleanValue() ); - + surefireBooter.setForkedProcessTimeoutInSeconds( forkedProcessTimeoutInSeconds ); surefireBooter.setRedirectTestOutputToFile( redirectTestOutputToFile ); @@ -1124,8 +1131,8 @@ public class NarIntegrationTestMojo if ( filteredArtifact != null ) { filter = - new ExcludesArtifactFilter( Collections.singletonList( filteredArtifact.getGroupId() + ":" + - filteredArtifact.getArtifactId() ) ); + new ExcludesArtifactFilter( Collections.singletonList( filteredArtifact.getGroupId() + ":" + + filteredArtifact.getArtifactId() ) ); } Artifact originatingArtifact = artifactFactory.createBuildArtifact( "dummy", "dummy", "1.0", "jar" ); @@ -1158,16 +1165,16 @@ public class NarIntegrationTestMojo } originalSystemProperties = (Properties) System.getProperties().clone(); - + // We used to take all of our system properties and dump them in with the // user specified properties for SUREFIRE-121, causing SUREFIRE-491. // Not gonna do THAT any more... but I'm leaving this code here in case // we need it later when we try to fix SUREFIRE-121 again. - + // Get the properties from the MavenSession instance to make embedded use work correctly Properties userSpecifiedProperties = (Properties) session.getExecutionProperties().clone(); userSpecifiedProperties.putAll( systemProperties ); - //systemProperties = userSpecifiedProperties; + // systemProperties = userSpecifiedProperties; systemProperties.setProperty( "basedir", basedir.getAbsolutePath() ); systemProperties.setProperty( "user.dir", workingDirectory.getAbsolutePath() ); @@ -1262,24 +1269,27 @@ public class NarIntegrationTestMojo { this.skipNarTests = skipExec; } - - //TODO remove the part with ToolchainManager lookup once we depend on - //3.0.9 (have it as prerequisite). Define as regular component field then. - private Toolchain getToolchain() + + // TODO remove the part with ToolchainManager lookup once we depend on + // 3.0.9 (have it as prerequisite). Define as regular component field then. + private Toolchain getToolchain() { Toolchain tc = null; - try + try { - if (session != null) //session is null in tests.. + if ( session != null ) // session is null in tests.. { - ToolchainManager toolchainManager = (ToolchainManager) session.getContainer().lookup(ToolchainManager.ROLE); - if (toolchainManager != null) + ToolchainManager toolchainManager = + (ToolchainManager) session.getContainer().lookup( ToolchainManager.ROLE ); + if ( toolchainManager != null ) { - tc = toolchainManager.getToolchainFromBuildContext("jdk", session); + tc = toolchainManager.getToolchainFromBuildContext( "jdk", session ); } } - } catch (ComponentLookupException componentLookupException) { - //just ignore, could happen in pre-3.0.9 builds.. + } + catch ( ComponentLookupException componentLookupException ) + { + // just ignore, could happen in pre-3.0.9 builds.. } return tc; } 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 cdb4ba7..64455aa 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarLayout.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarLayout.java @@ -39,16 +39,16 @@ public interface NarLayout /** * Specifies where all the "no architecture" specific files are stored */ - File getNoArchDirectory( File baseDir ) + File getNoArchDirectory( File baseDir, String artifactId, String version ) throws MojoExecutionException, MojoFailureException; - + /** * Specifies where libraries are stored * * @return * @throws MojoExecutionException, MojoFailureException */ - File getLibDirectory( File baseDir, String aol, String type ) + File getLibDirectory( File baseDir, String artifactId, String version, String aol, String type ) throws MojoExecutionException, MojoFailureException; /** @@ -56,7 +56,7 @@ public interface NarLayout * * @return */ - File getIncludeDirectory( File baseDir ) + File getIncludeDirectory( File baseDir, String artifactId, String version ) throws MojoExecutionException, MojoFailureException; /** @@ -64,7 +64,7 @@ public interface NarLayout * * @return */ - File getBinDirectory( File baseDir, String aol ) + File getBinDirectory( File baseDir, String artifactId, String version, String aol ) throws MojoExecutionException, MojoFailureException; /** @@ -74,4 +74,12 @@ public interface NarLayout void attachNars( File baseDir, ArchiverManager archiverManager, MavenProjectHelper projectHelper, MavenProject project, NarInfo narInfo ) throws MojoExecutionException, MojoFailureException; + + /** + * Called to unpack a nar file + * @param defaultAOL + * @param linkerName + */ + void unpackNar( ArchiverManager archiverManager, File file, String os, String linkerName, AOL defaultAOL ) + 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 e2e0207..299e706 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarLayout20.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarLayout20.java @@ -1,12 +1,15 @@ package org.apache.maven.plugin.nar; import java.io.File; +import java.io.IOException; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectHelper; import org.codehaus.plexus.archiver.manager.ArchiverManager; +import org.codehaus.plexus.util.FileUtils; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -44,38 +47,46 @@ import org.codehaus.plexus.archiver.manager.ArchiverManager; public class NarLayout20 extends AbstractNarLayout { - /* (non-Javadoc) + private NarFileLayout fileLayout; + + public NarLayout20( Log log ) + { + super( log ); + this.fileLayout = new NarFileLayout10(); + } + + /* + * (non-Javadoc) * @see org.apache.maven.plugin.nar.NarLayout#getNoArchDirectory(java.io.File) */ - public File getNoArchDirectory( File baseDir ) + public File getNoArchDirectory( File baseDir, String artifactId, String version ) throws MojoExecutionException, MojoFailureException { return baseDir; } - + /* * (non-Javadoc) * @see org.apache.maven.plugin.nar.NarLayout#getIncludeDirectory(java.io.File) */ - public final File getIncludeDirectory( File baseDir ) + public final File getIncludeDirectory( File baseDir, String artifactId, String version ) { - return new File( baseDir, "include" ); + return new File( baseDir, fileLayout.getIncludeDirectory() ); } /* * (non-Javadoc) * @see org.apache.maven.plugin.nar.NarLayout#getLibDir(java.io.File, org.apache.maven.plugin.nar.AOL, String type) */ - public final File getLibDirectory( File baseDir, String aol, String type ) throws MojoFailureException + public final File getLibDirectory( File baseDir, String artifactId, String version, String aol, String type ) + throws MojoFailureException { if ( type.equals( Library.EXECUTABLE ) ) { throw new MojoFailureException( "INTERNAL ERROR, Replace call to getLibDirectory with getBinDirectory" ); } - File dir = new File( baseDir, "lib" ); - dir = new File( dir, aol ); - dir = new File( dir, type ); + File dir = new File( baseDir, fileLayout.getLibDirectory( aol, type ) ); return dir; } @@ -83,10 +94,9 @@ public class NarLayout20 * (non-Javadoc) * @see org.apache.maven.plugin.nar.NarLayout#getBinDirectory(java.io.File, java.lang.String) */ - public final File getBinDirectory( File baseDir, String aol ) + public final File getBinDirectory( File baseDir, String artifactId, String version, String aol ) { - File dir = new File( baseDir, "bin" ); - dir = new File( dir, aol ); + File dir = new File( baseDir, fileLayout.getBinDirectory( aol )); return dir; } @@ -95,10 +105,11 @@ public class NarLayout20 * @see org.apache.maven.plugin.nar.NarLayout#attachNars(java.io.File, org.apache.maven.project.MavenProjectHelper, * org.apache.maven.project.MavenProject, org.apache.maven.plugin.nar.NarInfo) */ - public final void attachNars( File baseDir, ArchiverManager archiverManager, MavenProjectHelper projectHelper, MavenProject project, NarInfo narInfo ) + public final void attachNars( File baseDir, ArchiverManager archiverManager, MavenProjectHelper projectHelper, + MavenProject project, NarInfo narInfo ) throws MojoExecutionException { - if ( getIncludeDirectory( baseDir ).exists() ) + if ( getIncludeDirectory( baseDir, project.getArtifactId(), project.getVersion() ).exists() ) { attachNar( archiverManager, projectHelper, project, "noarch", baseDir, "include/**" ); narInfo.setNar( null, "noarch", project.getGroupId() + ":" + project.getArtifactId() + ":" @@ -108,11 +119,11 @@ public class NarLayout20 String[] binAOL = new File( baseDir, "bin" ).list(); for ( int i = 0; ( binAOL != null ) && ( i < binAOL.length ); i++ ) { - attachNar( archiverManager, projectHelper, project, binAOL[i] + "-" + Library.EXECUTABLE, baseDir, "bin/" + binAOL[i] - + "/**" ); + attachNar( archiverManager, projectHelper, project, binAOL[i] + "-" + Library.EXECUTABLE, baseDir, "bin/" + + binAOL[i] + "/**" ); narInfo.setNar( null, Library.EXECUTABLE, project.getGroupId() + ":" + project.getArtifactId() + ":" + NarConstants.NAR_TYPE + ":" + "${aol}" + "-" + Library.EXECUTABLE ); - narInfo.setBinding( new AOL(binAOL[i]), Library.EXECUTABLE ); + narInfo.setBinding( new AOL( binAOL[i] ), Library.EXECUTABLE ); narInfo.setBinding( null, Library.EXECUTABLE ); } @@ -124,8 +135,8 @@ public class NarLayout20 String[] libType = new File( libDir, libAOL[i] ).list(); for ( int j = 0; ( libType != null ) && ( j < libType.length ); j++ ) { - attachNar( archiverManager, projectHelper, project, libAOL[i] + "-" + libType[j], baseDir, "lib/" + libAOL[i] + "/" - + libType[j] + "/**" ); + attachNar( archiverManager, projectHelper, project, libAOL[i] + "-" + libType[j], baseDir, "lib/" + + libAOL[i] + "/" + libType[j] + "/**" ); narInfo.setNar( null, libType[j], project.getGroupId() + ":" + project.getArtifactId() + ":" + NarConstants.NAR_TYPE + ":" + "${aol}" + "-" + libType[j] ); @@ -136,7 +147,7 @@ public class NarLayout20 } } - AOL aol = new AOL(libAOL[i]); + AOL aol = new AOL( libAOL[i] ); if ( narInfo.getBinding( aol, null ) == null ) { narInfo.setBinding( aol, bindingType != null ? bindingType : Library.NONE ); @@ -147,4 +158,43 @@ public class NarLayout20 } } } + + public void unpackNar( ArchiverManager archiverManager, File file, String os, String linkerName, AOL defaultAOL ) + throws MojoExecutionException, MojoFailureException + { + File narLocation = new File( file.getParentFile(), "nar" ); + + File flagFile = + new File( narLocation, FileUtils.basename( file.getPath(), "." + NarConstants.NAR_EXTENSION ) + ".flag" ); + + boolean process = false; + if ( !narLocation.exists() ) + { + narLocation.mkdirs(); + process = true; + } + else if ( !flagFile.exists() ) + { + process = true; + } + else if ( file.lastModified() > flagFile.lastModified() ) + { + process = true; + } + + if ( process ) + { + try + { + unpackNarAndProcess( archiverManager, file, narLocation, os, linkerName, defaultAOL ); + FileUtils.fileDelete( flagFile.getPath() ); + FileUtils.fileWrite( flagFile.getPath(), "" ); + } + catch ( IOException e ) + { + throw new MojoFailureException( "Cannot create flag file: " + flagFile.getPath(), e ); + } + } + } + } 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 623e3fa..090e83e 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarLayout21.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarLayout21.java @@ -3,9 +3,12 @@ package org.apache.maven.plugin.nar; import java.io.File; import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectHelper; import org.codehaus.plexus.archiver.manager.ArchiverManager; +import org.codehaus.plexus.util.FileUtils; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -42,28 +45,31 @@ import org.codehaus.plexus.archiver.manager.ArchiverManager; public class NarLayout21 extends AbstractNarLayout { - public File getNoArchDirectory( File baseDir ) + private NarFileLayout fileLayout; + + public NarLayout21( Log log ) { - return new File( baseDir, NarConstants.NAR_NO_ARCH ); + super( log ); + this.fileLayout = new NarFileLayout10(); } - private File getAolDirectory( File baseDir ) + public File getNoArchDirectory( File baseDir, String artifactId, String version ) { - return new File( baseDir, NarConstants.NAR_AOL ); + return new File( baseDir, artifactId + "-" + version + "-" + NarConstants.NAR_NO_ARCH ); } - private File getAolDirectory( File baseDir, String aol, String type ) + private File getAolDirectory( File baseDir, String artifactId, String version, String aol, String type ) { - return new File( getAolDirectory( baseDir ), aol + "-" + type ); + return new File( baseDir, artifactId + "-" + version + "-" + aol + "-" + type ); } /* * (non-Javadoc) * @see org.apache.maven.plugin.nar.NarLayout#getIncludeDirectory(java.io.File) */ - public final File getIncludeDirectory( File baseDir ) + public final File getIncludeDirectory( File baseDir, String artifactId, String version ) { - return new File( getNoArchDirectory( baseDir ), "include" ); + return new File( getNoArchDirectory( baseDir, artifactId, version ), fileLayout.getIncludeDirectory() ); } /* @@ -71,7 +77,7 @@ public class NarLayout21 * @see org.apache.maven.plugin.nar.NarLayout#getLibDir(java.io.File, org.apache.maven.plugin.nar.AOL, * java.lang.String) */ - public final File getLibDirectory( File baseDir, String aol, String type ) + public final File getLibDirectory( File baseDir, String artifactId, String version, String aol, String type ) throws MojoExecutionException { if ( type.equals( Library.EXECUTABLE ) ) @@ -80,10 +86,8 @@ public class NarLayout21 "NAR: for type EXECUTABLE call getBinDirectory instead of getLibDirectory" ); } - File dir = getAolDirectory( baseDir, aol, type ); - dir = new File( dir, "lib" ); - dir = new File( dir, aol ); - dir = new File( dir, type ); + File dir = getAolDirectory( baseDir, artifactId, version, aol, type ); + dir = new File( dir, fileLayout.getLibDirectory( aol, type ) ); return dir; } @@ -92,11 +96,10 @@ public class NarLayout21 * @see org.apache.maven.plugin.nar.NarLayout#getLibDir(java.io.File, org.apache.maven.plugin.nar.AOL, * java.lang.String) */ - public final File getBinDirectory( File baseDir, String aol ) + public final File getBinDirectory( File baseDir, String artifactId, String version, String aol ) { - File dir = getAolDirectory( baseDir, aol, Library.EXECUTABLE ); - dir = new File( dir, "bin" ); - dir = new File( dir, aol ); + File dir = getAolDirectory( baseDir, artifactId, version, aol, Library.EXECUTABLE ); + dir = new File(dir, fileLayout.getBinDirectory( aol )); return dir; } @@ -105,33 +108,41 @@ public class NarLayout21 * @see org.apache.maven.plugin.nar.NarLayout#attachNars(java.io.File, org.apache.maven.project.MavenProjectHelper, * org.apache.maven.project.MavenProject, org.apache.maven.plugin.nar.NarInfo) */ - public final void attachNars( File baseDir, ArchiverManager archiverManager, MavenProjectHelper projectHelper, MavenProject project, NarInfo narInfo ) + public final void attachNars( File baseDir, ArchiverManager archiverManager, MavenProjectHelper projectHelper, + MavenProject project, NarInfo narInfo ) throws MojoExecutionException { - if ( getNoArchDirectory( baseDir ).exists() ) + if ( getNoArchDirectory( baseDir, project.getArtifactId(), project.getVersion() ).exists() ) { - attachNar( archiverManager, projectHelper, project, NarConstants.NAR_NO_ARCH, getNoArchDirectory( baseDir ), "*/**" ); + attachNar( archiverManager, projectHelper, project, NarConstants.NAR_NO_ARCH, + getNoArchDirectory( baseDir, project.getArtifactId(), project.getVersion() ), "*/**" ); narInfo.setNar( null, NarConstants.NAR_NO_ARCH, project.getGroupId() + ":" + project.getArtifactId() + ":" + NarConstants.NAR_TYPE + ":" + NarConstants.NAR_NO_ARCH ); } - File classifierDir = getAolDirectory( baseDir ); - String[] classifier = classifierDir.list(); - for ( int i = 0; ( classifier != null ) && ( i < classifier.length ); i++ ) + // list all directories in basedir, scan them for classifiers + String[] subDirs = baseDir.list(); + for ( int i = 0; ( subDirs != null ) && ( i < subDirs.length ); i++ ) { - File dir = new File( classifierDir, classifier[i] ); - attachNar( archiverManager, projectHelper, project, classifier[i], dir, "*/**" ); - - String type = null; - AOL aol = null; - - File binDir = new File( dir, "bin" ); - String[] aolDir = binDir.list(); - if ( ( aolDir != null ) && aolDir.length > 0 ) + String artifactIdVersion = project.getArtifactId()+"-"+project.getVersion(); + + // skip entries not belonging to this project + if (!subDirs[i].startsWith( artifactIdVersion )) continue; + + String classifier = subDirs[i].substring( artifactIdVersion.length()+1 ); + System.err.println("*** "+classifier); + // skip noarch here + if (classifier.equals( NarConstants.NAR_NO_ARCH )) continue; + + File dir = new File( baseDir, subDirs[i] ); + attachNar( archiverManager, projectHelper, project, classifier, dir, "*/**" ); + + int lastDash = classifier.lastIndexOf( '-' ); + String type = classifier.substring( lastDash+1); + AOL aol = new AOL(classifier.substring( 0, lastDash-1 )); + + if (type.equals( Library.EXECUTABLE )) { - type = Library.EXECUTABLE; - aol = new AOL(aolDir[0]); - if ( narInfo.getBinding( aol, null ) == null ) { narInfo.setBinding( aol, Library.EXECUTABLE ); @@ -143,39 +154,47 @@ public class NarLayout21 } else { - // look for type in aol/<aol-type>/lib/<aol>/<type> - File libDir = new File( dir, "lib" ); - aolDir = libDir.list(); - if ( ( aolDir != null ) && aolDir.length > 0 ) - { - aol = new AOL(aolDir[0]); - String[] typeDir = new File( libDir, aol.toString() ).list(); - if ( ( typeDir != null ) && ( typeDir.length > 0 ) ) - { - type = typeDir[0]; - } - } - - assert(aol != null); - assert(type != null); - // and not set or override if SHARED - if (( narInfo.getBinding( aol, null ) == null ) || type.equals( Library.SHARED ) ) + if ( ( narInfo.getBinding( aol, null ) == null ) || type.equals( Library.SHARED ) ) { narInfo.setBinding( aol, type ); } // and not set or override if SHARED - if (( narInfo.getBinding( null, null ) == null ) || type.equals( Library.SHARED ) ) + if ( ( narInfo.getBinding( null, null ) == null ) || type.equals( Library.SHARED ) ) { narInfo.setBinding( null, type ); } } - - assert(type != null); + narInfo.setNar( null, type, project.getGroupId() + ":" + project.getArtifactId() + ":" - + NarConstants.NAR_TYPE + ":" + "${aol}" + "-" + type ); + + NarConstants.NAR_TYPE + ":" + "${aol}" + "-" + type ); + } + } + + public void unpackNar( ArchiverManager archiverManager, File file, String os, String linkerName, AOL defaultAOL ) + throws MojoExecutionException, MojoFailureException + { + File narLocation = new File( file.getParentFile(), "nar" ); + File dir = new File( narLocation, FileUtils.basename( file.getPath(), "." + NarConstants.NAR_EXTENSION ) ); + boolean process = false; + if ( !narLocation.exists() ) + { + narLocation.mkdirs(); + process = true; + } + else if ( !dir.exists() ) + { + process = true; + } + else if ( file.lastModified() > dir.lastModified() ) + { + process = true; } + if ( process ) + { + unpackNarAndProcess( archiverManager, file, dir, os, linkerName, defaultAOL ); + } } -} +}
\ No newline at end of file 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 17ed990..e6c5b3a 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarManager.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarManager.java @@ -39,11 +39,7 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.archiver.ArchiverException; -import org.codehaus.plexus.archiver.UnArchiver; import org.codehaus.plexus.archiver.manager.ArchiverManager; -import org.codehaus.plexus.archiver.manager.NoSuchArchiverException; -import org.codehaus.plexus.util.FileUtils; /** * @author Mark Donszelmann (Mark.Donszelmann@gmail.com) @@ -61,7 +57,8 @@ public class NarManager private String linkerName; - private String[] narTypes = { NarConstants.NAR_NO_ARCH, Library.STATIC, Library.SHARED, Library.JNI, Library.PLUGIN }; + private String[] narTypes = + { NarConstants.NAR_NO_ARCH, Library.STATIC, Library.SHARED, Library.JNI, Library.PLUGIN }; public NarManager( Log log, ArtifactRepository repository, MavenProject project, String architecture, String os, Linker linker ) @@ -127,7 +124,7 @@ public class NarManager } public final List/* <AttachedNarArtifact> */getAttachedNarDependencies( List/* <NarArtifacts> */narArtifacts, - String classifier ) + String classifier ) throws MojoExecutionException, MojoFailureException { AOL aol = null; @@ -161,8 +158,8 @@ public class NarManager * @throws MojoExecutionException * @throws MojoFailureException */ - public final List/* <AttachedNarArtifact> */getAttachedNarDependencies( List/* <NarArtifacts> */narArtifacts, AOL archOsLinker, - String type ) + public final List/* <AttachedNarArtifact> */getAttachedNarDependencies( List/* <NarArtifacts> */narArtifacts, + AOL archOsLinker, String type ) throws MojoExecutionException, MojoFailureException { boolean noarch = false; @@ -200,7 +197,8 @@ public class NarManager return artifactList; } - private List/* <AttachedNarArtifact> */getAttachedNarDependencies( Artifact dependency, AOL archOsLinker, String type ) + private List/* <AttachedNarArtifact> */getAttachedNarDependencies( Artifact dependency, AOL archOsLinker, + String type ) throws MojoExecutionException, MojoFailureException { AOL aol = archOsLinker; @@ -261,11 +259,11 @@ public class NarManager dependency.isSnapshot(); File file = new File( repository.getBasedir(), repository.pathOf( dependency ) ); - if (!file.exists()) + if ( !file.exists() ) { return null; } - + JarFile jar = null; try { @@ -323,13 +321,13 @@ public class NarManager } public final void downloadAttachedNars( List/* <NarArtifacts> */narArtifacts, List remoteRepositories, - ArtifactResolver resolver, String classifier ) + ArtifactResolver resolver, String classifier ) throws MojoExecutionException, MojoFailureException { // FIXME this may not be the right way to do this.... -U ignored and // also SNAPSHOT not used List dependencies = getAttachedNarDependencies( narArtifacts, classifier ); - + log.debug( "Download called with classifier: " + classifier + " for NarDependencies {" ); for ( Iterator i = dependencies.iterator(); i.hasNext(); ) { @@ -358,8 +356,8 @@ public class NarManager } } - public final void unpackAttachedNars( List/* <NarArtifacts> */narArtifacts, ArchiverManager manager, String classifier, - String os ) + public final void unpackAttachedNars( List/* <NarArtifacts> */narArtifacts, ArchiverManager archiverManager, + String classifier, String os, NarLayout layout ) throws MojoExecutionException, MojoFailureException { log.debug( "Unpack called for OS: " + os + ", classifier: " + classifier + " for NarArtifacts {" ); @@ -375,85 +373,18 @@ public class NarManager Artifact dependency = (Artifact) i.next(); log.debug( "Unpack " + dependency ); File file = getNarFile( dependency ); - File narLocation = new File( file.getParentFile(), "nar" ); - File flagFile = - new File( narLocation, FileUtils.basename( file.getPath(), "." + NarConstants.NAR_EXTENSION ) - + ".flag" ); - - boolean process = false; - if ( !narLocation.exists() ) - { - narLocation.mkdirs(); - process = true; - } - else if ( !flagFile.exists() ) - { - process = true; - } - else if ( file.lastModified() > flagFile.lastModified() ) - { - process = true; - } - if ( process ) - { - try - { - final String gpp = "g++"; - final String gcc = "gcc"; - - unpackNar( manager, file, narLocation ); - if ( !NarUtil.getOS( os ).equals( OS.WINDOWS ) ) - { - NarUtil.makeExecutable( new File( narLocation, "bin/" + defaultAOL ), log ); - // FIXME clumsy - if ( defaultAOL.hasLinker( gpp ) ) - { - 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 ) ) - { - NarUtil.runRanlib( new File( narLocation, "lib/" + defaultAOL ), log ); - // FIXME clumsy - if ( defaultAOL.hasLinker( gpp ) ) - { - NarUtil.runRanlib( new File( narLocation, "lib/" - + NarUtil.replace( gpp, gcc, defaultAOL.toString() ) ), log ); - } - } - FileUtils.fileDelete( flagFile.getPath() ); - FileUtils.fileWrite( flagFile.getPath(), "" ); - } - catch ( IOException e ) - { - log.warn( "Cannot create flag file: " + flagFile.getPath() ); - } - } + layout.unpackNar(archiverManager, file, os, linkerName, defaultAOL); } } - private void unpackNar( ArchiverManager archiverManager, File file, File location ) - throws MojoExecutionException + /** + * @param narDependency + * @return + * @throws MojoFailureException + */ + public File getUnpackDirectory( Artifact narDependency ) throws MojoFailureException { - try - { - UnArchiver unArchiver; - unArchiver = archiverManager.getUnArchiver( NarConstants.NAR_ROLE_HINT ); - unArchiver.setSourceFile( file ); - unArchiver.setDestDirectory( location ); - unArchiver.extract(); - } - catch ( NoSuchArchiverException e ) - { - throw new MojoExecutionException( "Error unpacking file: " + file + " to: " + location, e ); - } - catch ( ArchiverException e ) - { - throw new MojoExecutionException( "Error unpacking file: " + file + " to: " + location, e ); - } + return new File(getNarFile( narDependency ).getParentFile(), "nar"); } } 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 b730a52..0fd8245 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarResourcesMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarResourcesMojo.java @@ -65,7 +65,7 @@ public class NarResourcesMojo File noarchDir = new File( resourceDirectory, NarConstants.NAR_NO_ARCH ); if ( noarchDir.exists() ) { - File noarchDstDir = getLayout().getNoArchDirectory( getTargetDirectory() ); + File noarchDstDir = getLayout().getNoArchDirectory( getTargetDirectory(), getMavenProject().getArtifactId(), getMavenProject().getVersion() ); getLog().debug( "Copying noarch from " + noarchDir + " to " + noarchDstDir ); copied += NarUtil.copyDirectoryStructure( noarchDir, noarchDstDir, null, NarUtil.DEFAULT_EXCLUDES ); } diff --git a/src/main/java/org/apache/maven/plugin/nar/NarTestCompileMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarTestCompileMojo.java index d59cc0a..6e27b5c 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarTestCompileMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarTestCompileMojo.java @@ -140,7 +140,11 @@ public class NarTestCompileMojo // add dependency include paths for ( Iterator i = getNarManager().getNarDependencies( "test" ).iterator(); i.hasNext(); ) { - File include = new File( getNarManager().getNarFile( (Artifact) i.next() ).getParentFile(), "nar/include" ); + // FIXED NAR-90 + Artifact artifact = (Artifact) i.next(); + File include = + getLayout().getIncludeDirectory( getNarManager().getUnpackDirectory( artifact ), + artifact.getArtifactId(), artifact.getVersion() ); if ( include.exists() ) { task.createIncludePath().setPath( include.getPath() ); @@ -152,8 +156,12 @@ public class NarTestCompileMojo // FIXME hardcoded values String libName = getFinalName(); - File includeDir = getLayout().getIncludeDirectory( getTargetDirectory() ); - File libDir = getLayout().getLibDirectory( getTargetDirectory(), getAOL().toString(), test.getLink() ); + File includeDir = + getLayout().getIncludeDirectory( getTargetDirectory(), getMavenProject().getArtifactId(), + getMavenProject().getVersion() ); + File libDir = + getLayout().getLibDirectory( getTargetDirectory(), getMavenProject().getArtifactId(), + getMavenProject().getVersion(), getAOL().toString(), test.getLink() ); // copy shared library // FIXME why do we do this ? @@ -227,16 +235,18 @@ public class NarTestCompileMojo Artifact dependency = (Artifact) i.next(); // FIXME: this should be preferred binding - File lib = - new File( getNarManager().getNarFile( dependency ).getParentFile(), "nar/lib/" + getAOL() + "/" - + test.getLink() ); - if ( lib.exists() ) + // FIXED NAR-90 + File libDirectory = + getLayout().getLibDirectory( getNarManager().getUnpackDirectory( dependency ), + dependency.getArtifactId(), dependency.getVersion(), getAOL().toString(), + test.getLink() ); + if ( libDirectory.exists() ) { LibrarySet libset = new LibrarySet(); libset.setProject( antProject ); libset.setLibs( new CUtil.StringArrayBuilder( dependency.getArtifactId() + "-" + dependency.getVersion() ) ); - libset.setDir( lib ); + libset.setDir( libDirectory ); task.addLibset( libset ); } } diff --git a/src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java index db4e68d..0498b18 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java @@ -73,6 +73,7 @@ public class NarTestMojo // run if requested if ( test.shouldRun() ) { + // FIXME NAR-90 String name = getTestTargetDirectory().getPath() + "/bin/" + getAOL() + "/" + test.getName(); getLog().info( "Running test " + name ); @@ -96,9 +97,10 @@ public class NarTestMojo if ( library.getType().equals( Library.EXECUTABLE ) && library.shouldRun() ) { MavenProject project = getMavenProject(); - // FIXME NAR-90, we could make dure we get the final name from layout + // FIXME NAR-90, we could make sure we get the final name from layout File executable = - new File( getLayout().getBinDirectory( getTargetDirectory(), getAOL().toString() ), + new File( getLayout().getBinDirectory( getTargetDirectory(), getMavenProject().getArtifactId(), + getMavenProject().getVersion(), getAOL().toString() ), project.getArtifactId() ); getLog().info( "Running executable " + executable ); List args = library.getArgs(); @@ -132,7 +134,8 @@ public class NarTestMojo if ( lib.getType().equals( Library.SHARED ) ) { File path = - getLayout().getLibDirectory( getTargetDirectory(), getAOL().toString(), lib.getType() ); + getLayout().getLibDirectory( getTargetDirectory(), getMavenProject().getArtifactId(), + getMavenProject().getVersion(), getAOL().toString(), lib.getType() ); getLog().debug( "Adding path to shared library: " + path ); sharedPaths.add( path ); } @@ -152,11 +155,12 @@ public class NarTestMojo // of getBaseVersion, called in pathOf. dependency.isSnapshot(); - // FIXME NAR-90 - File libDir = new File( getLocalRepository().pathOf( dependency ) ); - libDir = new File( getLocalRepository().getBasedir(), libDir.getParent() ); - libDir = new File( libDir, "nar/lib/" + getAOL() + "/shared" ); - sharedPaths.add( libDir ); + // FIXED NAR-90 + File libDirectory = + getLayout().getLibDirectory( getNarManager().getUnpackDirectory( dependency ), + dependency.getArtifactId(), dependency.getVersion(), getAOL().toString(), + Library.SHARED ); + sharedPaths.add( libDirectory ); } // set environment diff --git a/src/main/java/org/apache/maven/plugin/nar/NarUnpackMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarUnpackMojo.java index 991f3e3..ad4cb25 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarUnpackMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarUnpackMojo.java @@ -37,7 +37,7 @@ import org.codehaus.plexus.archiver.manager.ArchiverManager; * @author Mark Donszelmann */ public class NarUnpackMojo - extends AbstractDependencyMojo + extends AbstractCompileMojo { /** @@ -61,13 +61,13 @@ public class NarUnpackMojo List narArtifacts = getNarManager().getNarDependencies( "compile" ); if ( classifiers == null ) { - getNarManager().unpackAttachedNars( narArtifacts, archiverManager, null, getOS() ); + getNarManager().unpackAttachedNars( narArtifacts, archiverManager, null, getOS(), getLayout() ); } else { for ( Iterator j = classifiers.iterator(); j.hasNext(); ) { - getNarManager().unpackAttachedNars( narArtifacts, archiverManager, (String) j.next(), getOS() ); + getNarManager().unpackAttachedNars( narArtifacts, archiverManager, (String) j.next(), getOS(), getLayout() ); } } } diff --git a/src/test/java/org/apache/maven/plugin/nar/test/TestNarFileLayout10.java b/src/test/java/org/apache/maven/plugin/nar/test/TestNarFileLayout10.java new file mode 100644 index 0000000..e75736b --- /dev/null +++ b/src/test/java/org/apache/maven/plugin/nar/test/TestNarFileLayout10.java @@ -0,0 +1,77 @@ +/* + * 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. + */ + +package org.apache.maven.plugin.nar.test; + +import java.io.File; + +import org.apache.maven.plugin.nar.Library; +import org.apache.maven.plugin.nar.NarFileLayout; +import org.apache.maven.plugin.nar.NarFileLayout10; + +import junit.framework.Assert; +import junit.framework.TestCase; + +/** + * @author Mark Donszelmann (Mark.Donszelmann@gmail.com) + * @version $Id$ + */ +public class TestNarFileLayout10 + extends TestCase +{ + private NarFileLayout fileLayout; + + private String artifactId; + + private String version; + + private String aol; + + private String type; + + /* + * (non-Javadoc) + * @see junit.framework.TestCase#setUp() + */ + protected void setUp() + throws Exception + { + fileLayout = new NarFileLayout10(); + artifactId = "artifactId"; + version = "version"; + aol = "x86_64-MacOSX-g++"; + type = Library.SHARED; + } + + public final void testGetIncludeDirectory() + { + Assert.assertEquals( "include", fileLayout.getIncludeDirectory() ); + } + + public final void testGetLibDirectory() + { + Assert.assertEquals( "lib" + File.separator + aol + File.separator + type, fileLayout.getLibDirectory( aol, + type ) ); + } + + public final void testGetBinDirectory() + { + Assert.assertEquals( "bin" + File.separator + aol, fileLayout.getBinDirectory( aol ) ); + } +} diff --git a/src/test/java/org/apache/maven/plugin/nar/test/TestNarLayout20.java b/src/test/java/org/apache/maven/plugin/nar/test/TestNarLayout20.java new file mode 100644 index 0000000..f78e45c --- /dev/null +++ b/src/test/java/org/apache/maven/plugin/nar/test/TestNarLayout20.java @@ -0,0 +1,118 @@ +/* + * 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. + */ + +package org.apache.maven.plugin.nar.test; + +import java.io.File; + +import junit.framework.Assert; +import junit.framework.TestCase; + +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.logging.Log; +import org.apache.maven.plugin.logging.SystemStreamLog; +import org.apache.maven.plugin.nar.AbstractNarLayout; +import org.apache.maven.plugin.nar.Library; +import org.apache.maven.plugin.nar.NarFileLayout; +import org.apache.maven.plugin.nar.NarFileLayout10; +import org.apache.maven.plugin.nar.NarLayout; +import org.apache.maven.plugin.nar.NarLayout20; + +/** + * @author Mark Donszelmann (Mark.Donszelmann@gmail.com) + */ +public class TestNarLayout20 + extends TestCase +{ + private NarFileLayout fileLayout; + + private Log log; + + private NarLayout layout; + + private File baseDir; + + private String aol; + + private String type; + + /* + * (non-Javadoc) + * @see junit.framework.TestCase#setUp() + */ + protected void setUp() + throws Exception + { + log = new SystemStreamLog(); + fileLayout = new NarFileLayout10(); + layout = new NarLayout20( log ); + baseDir = new File( "/Users/maven" ); + aol = "x86_64-MacOSX-g++"; + type = Library.SHARED; + } + + public final void testGetLayout() + throws MojoExecutionException + { + AbstractNarLayout.getLayout( "NarLayout20", log ); + } + + /** + * Test method for {@link org.apache.maven.plugin.nar.NarLayout20#getIncludeDirectory(java.io.File)}. + * + * @throws MojoFailureException + * @throws MojoExecutionException + */ + public final void testGetIncludeDirectory() + throws MojoExecutionException, MojoFailureException + { + Assert.assertEquals( new File( baseDir, fileLayout.getIncludeDirectory() ), + layout.getIncludeDirectory( baseDir, null, null ) ); + } + + /** + * Test method for + * {@link org.apache.maven.plugin.nar.NarLayout20#getLibDirectory(java.io.File, java.lang.String, java.lang.String)} + * . + * + * @throws MojoFailureException + * @throws MojoExecutionException + */ + public final void testGetLibDirectory() + throws MojoExecutionException, MojoFailureException + { + Assert.assertEquals( new File( baseDir, fileLayout.getLibDirectory( aol, type ) ), + layout.getLibDirectory( baseDir, null, null, aol, type ) ); + } + + /** + * Test method for {@link org.apache.maven.plugin.nar.NarLayout20#getBinDirectory(java.io.File, java.lang.String)}. + * + * @throws MojoFailureException + * @throws MojoExecutionException + */ + public final void testGetBinDirectory() + throws MojoExecutionException, MojoFailureException + { + Assert.assertEquals( new File( baseDir, fileLayout.getBinDirectory( aol ) ), layout.getBinDirectory( baseDir, + null, + null, aol ) ); + } +} diff --git a/src/test/java/org/apache/maven/plugin/nar/test/TestNarLayout21.java b/src/test/java/org/apache/maven/plugin/nar/test/TestNarLayout21.java new file mode 100644 index 0000000..794fbaa --- /dev/null +++ b/src/test/java/org/apache/maven/plugin/nar/test/TestNarLayout21.java @@ -0,0 +1,125 @@ +/* + * 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. + */ + +package org.apache.maven.plugin.nar.test; + +import java.io.File; + +import junit.framework.Assert; +import junit.framework.TestCase; + +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.logging.Log; +import org.apache.maven.plugin.logging.SystemStreamLog; +import org.apache.maven.plugin.nar.AbstractNarLayout; +import org.apache.maven.plugin.nar.Library; +import org.apache.maven.plugin.nar.NarConstants; +import org.apache.maven.plugin.nar.NarFileLayout; +import org.apache.maven.plugin.nar.NarFileLayout10; +import org.apache.maven.plugin.nar.NarLayout; +import org.apache.maven.plugin.nar.NarLayout21; + +/** + * @author Mark Donszelmann (Mark.Donszelmann@gmail.com) + */ +public class TestNarLayout21 + extends TestCase +{ + private NarFileLayout fileLayout; + + private Log log; + + private NarLayout layout; + + private File baseDir; + + private String artifactId; + + private String version; + + private String aol; + + private String type; + + /* + * (non-Javadoc) + * @see junit.framework.TestCase#setUp() + */ + protected void setUp() + throws Exception + { + fileLayout = new NarFileLayout10(); + artifactId = "artifactId"; + version = "version"; + baseDir = new File( "/Users/maven" ); + aol = "x86_64-MacOSX-g++"; + type = Library.SHARED; + + log = new SystemStreamLog(); + layout = new NarLayout21( log ); + } + + public final void testGetLayout() + throws MojoExecutionException + { + AbstractNarLayout.getLayout( "NarLayout21", log ); + } + + /** + * Test method for {@link org.apache.maven.plugin.nar.NarLayout20#getIncludeDirectory(java.io.File)}. + * + * @throws MojoFailureException + * @throws MojoExecutionException + */ + public final void testGetIncludeDirectory() + throws MojoExecutionException, MojoFailureException + { + Assert.assertEquals( new File( baseDir, artifactId + "-" + version + "-" + NarConstants.NAR_NO_ARCH + + File.separator + fileLayout.getIncludeDirectory() ), layout.getIncludeDirectory( baseDir, artifactId, version ) ); + } + + /** + * Test method for + * {@link org.apache.maven.plugin.nar.NarLayout20#getLibDirectory(java.io.File, java.lang.String, java.lang.String)} + * . + * + * @throws MojoFailureException + * @throws MojoExecutionException + */ + public final void testGetLibDirectory() + throws MojoExecutionException, MojoFailureException + { + Assert.assertEquals( new File( baseDir, artifactId + "-" + version + "-" + aol + "-" + type + File.separator + + fileLayout.getLibDirectory( aol, type ) ), layout.getLibDirectory( baseDir, artifactId, version, aol, type ) ); + } + + /** + * Test method for {@link org.apache.maven.plugin.nar.NarLayout20#getBinDirectory(java.io.File, java.lang.String)}. + * + * @throws MojoFailureException + * @throws MojoExecutionException + */ + public final void testGetBinDirectory() + throws MojoExecutionException, MojoFailureException + { + Assert.assertEquals( new File( baseDir, artifactId + "-" + version + "-" + aol + "-" + "executable" + + File.separator + fileLayout.getBinDirectory( aol ) ), layout.getBinDirectory( baseDir, artifactId, version, aol ) ); + } +} |