summaryrefslogtreecommitdiff
path: root/src/main/java/org/apache
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/apache')
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/AbstractCompileMojo.java6
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/AbstractResourcesMojo.java10
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/DefaultNarLayout.java59
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/Library.java2
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java23
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarIntegrationTestMojo.java5
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarLayout.java46
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarPackageMojo.java82
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarSystemMojo.java121
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarTestCompileMojo.java3
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java16
11 files changed, 323 insertions, 50 deletions
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 4359e22..08ad9f6 100644
--- a/src/main/java/org/apache/maven/plugin/nar/AbstractCompileMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/AbstractCompileMojo.java
@@ -252,4 +252,10 @@ public abstract class AbstractCompileMojo
}
return narInfo;
}
+
+ // FIXME, needs to be configurable and maybe move up
+ protected NarLayout getLayout()
+ {
+ return new DefaultNarLayout();
+ }
}
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 0a7478a..b98a8cb 100644
--- a/src/main/java/org/apache/maven/plugin/nar/AbstractResourcesMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/AbstractResourcesMojo.java
@@ -81,6 +81,7 @@ public abstract class AbstractResourcesMojo
File includeDir = new File( srcDir, resourceIncludeDir );
if ( includeDir.exists() )
{
+ // FIXME NAR-90
File includeDstDir = new File( getTargetDirectory(), "include" );
getLog().debug( "Copying includes from " + includeDir + " to " + includeDstDir );
copied += NarUtil.copyDirectoryStructure( includeDir, includeDstDir, null, NarUtil.DEFAULT_EXCLUDES );
@@ -98,10 +99,8 @@ public abstract class AbstractResourcesMojo
File binDir = new File( srcDir, resourceBinDir );
if ( binDir.exists() )
{
- File binDstDir = new File( getTargetDirectory(), "bin" );
- binDstDir = new File( binDstDir, aol );
+ File binDstDir = getLayout().getLibDirectory( getTargetDirectory(), aol, Library.EXECUTABLE );
getLog().debug( "Copying binaries from " + binDir + " to " + binDstDir );
-
copied += NarUtil.copyDirectoryStructure( binDir, binDstDir, null, NarUtil.DEFAULT_EXCLUDES );
}
@@ -122,10 +121,7 @@ public abstract class AbstractResourcesMojo
{
Library library = (Library) i.next();
String type = library.getType();
- File libDstDir = new File( getTargetDirectory(), "lib" );
- libDstDir = new File( libDstDir, aol );
- libDstDir = new File( libDstDir, type );
-
+ File libDstDir = getLayout().getLibDirectory( getTargetDirectory(), 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/DefaultNarLayout.java b/src/main/java/org/apache/maven/plugin/nar/DefaultNarLayout.java
new file mode 100644
index 0000000..cf77e08
--- /dev/null
+++ b/src/main/java/org/apache/maven/plugin/nar/DefaultNarLayout.java
@@ -0,0 +1,59 @@
+package org.apache.maven.plugin.nar;
+
+import java.io.File;
+
+/*
+ * 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.
+ */
+
+/**
+ * @author Mark Donszelmann (Mark.Donszelmann@gmail.com)
+ */
+public class DefaultNarLayout
+ implements NarLayout
+{
+ public File getAolDirectory( File baseDir )
+ {
+ return new File( baseDir, "aol" );
+ }
+
+ private File getNoarchDirectory( File baseDir )
+ {
+ return new File( baseDir, "noarch" );
+ }
+
+ private File getAolDirectory( File baseDir, String aol, String type )
+ {
+ return new File( getAolDirectory( baseDir ), aol + "-" + type );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.maven.plugin.nar.NarLayout#getLibDir(org.apache.maven.plugin.nar.AOL, java.lang.String)
+ */
+ public File getLibDirectory( File baseDir, String aol, String type )
+ {
+ File dir = getAolDirectory( baseDir, aol, type );
+ dir = new File( dir, type.equals( Library.EXECUTABLE ) ? "bin" : "lib" );
+ dir = new File( dir, aol.toString() );
+ if ( !dir.equals( Library.EXECUTABLE ) )
+ dir = new File( dir, type );
+ return dir;
+ }
+
+}
diff --git a/src/main/java/org/apache/maven/plugin/nar/Library.java b/src/main/java/org/apache/maven/plugin/nar/Library.java
index 5b8959b..6cf6a04 100644
--- a/src/main/java/org/apache/maven/plugin/nar/Library.java
+++ b/src/main/java/org/apache/maven/plugin/nar/Library.java
@@ -50,7 +50,7 @@ public class Library
*
* @parameter expression=""
*/
- protected String type = "shared";
+ protected String type = SHARED;
/**
* Link with stdcpp if necessary Defaults to true.
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 63b12e6..cefc224 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarCompileMojo.java
@@ -54,7 +54,6 @@ import org.codehaus.plexus.util.StringUtils;
public class NarCompileMojo
extends AbstractCompileMojo
{
-
public void execute()
throws MojoExecutionException, MojoFailureException
{
@@ -139,10 +138,7 @@ public class NarCompileMojo
task.setLinkFortran( library.linkFortran() );
// outDir
- File outDir = new File( getTargetDirectory(), type.equals( Library.EXECUTABLE ) ? "bin" : "lib" );
- outDir = new File( outDir, getAOL().toString() );
- if ( !type.equals( Library.EXECUTABLE ) )
- outDir = new File( outDir, type );
+ File outDir = getLayout().getLibDirectory( getTargetDirectory(), getAOL().toString(), type );
outDir.mkdirs();
// outFile
@@ -227,23 +223,19 @@ public class NarCompileMojo
// to comply with the order specified by the user
if ( ( depLibOrder != null ) && !depLibOrder.isEmpty() )
{
-
List tmp = new LinkedList();
for ( Iterator i = depLibOrder.iterator(); i.hasNext(); )
{
-
String depToOrderName = (String) i.next();
for ( Iterator j = depLibs.iterator(); j.hasNext(); )
{
-
NarArtifact dep = (NarArtifact) j.next();
String depName = dep.getGroupId() + ":" + dep.getArtifactId();
if ( depName.equals( depToOrderName ) )
{
-
tmp.add( dep );
j.remove();
}
@@ -256,7 +248,6 @@ public class NarCompileMojo
for ( Iterator i = depLibs.iterator(); i.hasNext(); )
{
-
NarArtifact dependency = (NarArtifact) i.next();
// FIXME no handling of "local"
@@ -270,9 +261,10 @@ public class NarCompileMojo
if ( !binding.equals( Library.JNI ) )
{
- File dir =
- new File( getNarManager().getNarFile( dependency ).getParentFile(), "nar/lib/" + aol.toString()
- + "/" + binding );
+ 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 );
if ( dir.exists() )
{
@@ -330,11 +322,10 @@ public class NarCompileMojo
{
throw new MojoExecutionException( "NAR: Compile failed", e );
}
-
+
// FIXME, this should be done in CPPTasks at some point
if ( getRuntime( getAOL() ).equals( "dynamic" ) && getOS().equals( OS.WINDOWS )
- && getLinker().getName( null, null ).equals( "msvc" )
- && !getLinker().getVersion().startsWith( "6." ) )
+ && getLinker().getName( null, null ).equals( "msvc" ) && !getLinker().getVersion().startsWith( "6." ) )
{
String libType = library.getType();
if ( libType.equals( Library.JNI ) || libType.equals( Library.SHARED ) )
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 ce700a5..b81de03 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarIntegrationTestMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarIntegrationTestMojo.java
@@ -972,7 +972,7 @@ public class NarIntegrationTestMojo
if ( testJNIModule() )
{
// Add libraries to java.library.path for testing
- File jniLibraryPathEntry = new File( project.getBasedir(), "target/nar/lib/" + getAOL() + "/jni" );
+ File jniLibraryPathEntry = getLayout().getLibDirectory( getTargetDirectory(), getAOL().toString(), Library.JNI );
if ( jniLibraryPathEntry.exists() )
{
getLog().debug( "Adding library directory to java.library.path: " + jniLibraryPathEntry );
@@ -981,7 +981,7 @@ public class NarIntegrationTestMojo
javaLibraryPath.append( jniLibraryPathEntry );
}
- File sharedLibraryPathEntry = new File( project.getBasedir(), "target/nar/lib/" + getAOL() + "/shared" );
+ File sharedLibraryPathEntry = getLayout().getLibDirectory( getTargetDirectory(), getAOL().toString(), Library.SHARED );
if ( sharedLibraryPathEntry.exists() )
{
getLog().debug( "Adding library directory to java.library.path: " + sharedLibraryPathEntry );
@@ -1011,6 +1011,7 @@ public class NarIntegrationTestMojo
String binding = bindings[j];
if ( !binding.equals( Library.STATIC ) )
{
+ // FIXME NAR-90 in repo
File depLibPathEntry =
new File( getNarManager().getNarFile( dependency ).getParent(), "nar/lib/" + getAOL() + "/"
+ binding );
diff --git a/src/main/java/org/apache/maven/plugin/nar/NarLayout.java b/src/main/java/org/apache/maven/plugin/nar/NarLayout.java
new file mode 100644
index 0000000..5c722a1
--- /dev/null
+++ b/src/main/java/org/apache/maven/plugin/nar/NarLayout.java
@@ -0,0 +1,46 @@
+package org.apache.maven.plugin.nar;
+
+import java.io.File;
+
+/*
+
+ * 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.
+ */
+
+/**
+ * Interface to define the layout of nar files (executables, libs, include dirs) in both the
+ * repository (local, unpacked) as well as in target.
+ *
+ * @author Mark Donszelmann (Mark.Donszelmann@gmail.com)
+ */
+public interface NarLayout
+{
+ /**
+ * Specifies where the aol specific libs are unpacked
+ *
+ * @return
+ */
+ public File getAolDirectory( File baseDir );
+
+ /**
+ * Specifies where libraries are stored
+ *
+ * @return
+ */
+ public File getLibDirectory(File baseDir, String aol, String type);
+}
diff --git a/src/main/java/org/apache/maven/plugin/nar/NarPackageMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarPackageMojo.java
index e7aaa37..6937a4b 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarPackageMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarPackageMojo.java
@@ -49,8 +49,6 @@ public class NarPackageMojo
*/
private MavenProjectHelper projectHelper;
- private File narDirectory;
-
public void execute()
throws MojoExecutionException, MojoFailureException
{
@@ -60,21 +58,21 @@ public class NarPackageMojo
// FIX for NARPLUGIN-??? where -DupdateReleaseInfo copies to a .nar file
getMavenProject().getArtifact().setArtifactHandler( new NarArtifactHandler() );
- narDirectory = new File( getOutputDirectory(), "nar" );
-
// noarch
+ // FIXME NAR-90
String include = "include";
- if ( new File( narDirectory, include ).exists() )
+ if ( new File( getTargetDirectory(), include ).exists() )
{
- attachNar( "include", null, NAR_NO_ARCH );
+ attachNarOld( "include", null, NAR_NO_ARCH );
}
// create nar with binaries
+ // FIXME NAR-90
String bin = "bin";
- String[] binAOLs = new File( narDirectory, bin ).list();
+ String[] binAOLs = new File( getTargetDirectory(), bin ).list();
for ( int i = 0; i < ( binAOLs != null ? binAOLs.length : 0 ); i++ )
{
- attachNar( bin + "/" + binAOLs[i], binAOLs[i], Library.EXECUTABLE );
+ attachNarOld( bin + "/" + binAOLs[i], binAOLs[i], Library.EXECUTABLE );
}
// create nars for each type of library (static, shared).
@@ -87,11 +85,12 @@ public class NarPackageMojo
bindingType = type;
// create nar with libraries
- String lib = "lib";
- String[] libAOLs = new File( narDirectory, lib ).list();
- for ( int j = 0; j < ( libAOLs != null ? libAOLs.length : 0 ); j++ )
+ // FIXME NAR-90, the resources nar may copy extra libs in.
+ File aolDirectory = getLayout().getAolDirectory( getTargetDirectory() );
+ String[] subDirs = aolDirectory.list();
+ for ( int j = 0; j < ( subDirs != null ? subDirs.length : 0 ); j++ )
{
- attachNar( lib + "/" + libAOLs[j] + "/" + type, libAOLs[j], type );
+ attachNar( new File( aolDirectory, subDirs[j] ), subDirs[j], type );
}
}
@@ -119,13 +118,35 @@ public class NarPackageMojo
}
}
- private void attachNar( String dir, String aol, String type )
+ private String getNarReference( String type )
+ {
+ return getMavenProject().getGroupId() + ":" + getMavenProject().getArtifactId() + ":" + NAR_TYPE + ":"
+ + "${aol}-" + type;
+ }
+
+ /**
+ * @param file
+ * @param string
+ * @param type
+ * @throws MojoExecutionException
+ */
+ private void attachNar( File dir, String string, String type )
+ throws MojoExecutionException
+ {
+ String aolType = dir.getName();
+ File narFile = new File( getOutputDirectory(), getFinalName() + "-" + dir.getName() + "." + NAR_EXTENSION );
+ nar( narFile, dir );
+ projectHelper.attachArtifact( getMavenProject(), NAR_TYPE, aolType, narFile );
+ getNarInfo().setNar( null, type, getNarReference( type ) );
+ }
+
+ private void attachNarOld( String dir, String aol, String type )
throws MojoExecutionException
{
File libFile =
new File( getOutputDirectory(), getFinalName() + "-" + ( aol != null ? aol + "-" : "" ) + type + "."
+ NAR_EXTENSION );
- nar( libFile, narDirectory, new String[] { dir } );
+ narOld( libFile, getTargetDirectory(), new String[] { dir } );
projectHelper.attachArtifact( getMavenProject(), NAR_TYPE, ( aol != null ? aol + "-" : "" ) + type, libFile );
getNarInfo().setNar(
null,
@@ -135,7 +156,38 @@ public class NarPackageMojo
}
- private void nar( File nar, File dir, String[] dirs )
+ private void nar( File nar, File dir )
+ throws MojoExecutionException
+ {
+ try
+ {
+ if ( nar.exists() )
+ {
+ nar.delete();
+ }
+
+ Archiver archiver = new ZipArchiver();
+ // seems to return same archiver all the time
+ // archiverManager.getArchiver(NAR_ROLE_HINT);
+ String[] includes = new String[] { "*/**" };
+ archiver.addDirectory( dir, includes, null );
+ archiver.setDestFile( nar );
+ archiver.createArchive();
+ }
+ catch ( ArchiverException e )
+ {
+ throw new MojoExecutionException( "Error while creating NAR archive.", e );
+ // } catch (NoSuchArchiverException e) {
+ // throw new MojoExecutionException("Error while creating NAR
+ // archive.", e );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Error while creating NAR archive.", e );
+ }
+ }
+
+ private void narOld( File nar, File dir, String[] dirs )
throws MojoExecutionException
{
try
diff --git a/src/main/java/org/apache/maven/plugin/nar/NarSystemMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarSystemMojo.java
new file mode 100644
index 0000000..13d4e18
--- /dev/null
+++ b/src/main/java/org/apache/maven/plugin/nar/NarSystemMojo.java
@@ -0,0 +1,121 @@
+package org.apache.maven.plugin.nar;
+
+/*
+ * 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.
+ */
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Iterator;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+
+/**
+ * Generates a NarSystem class with static methods to use inside the java part of the library.
+ *
+ * @goal nar-system-generate
+ * @phase generate-sources
+ * @requiresProject
+ * @author Mark Donszelmann
+ */
+public class NarSystemMojo
+ extends AbstractCompileMojo
+{
+
+ public void execute()
+ throws MojoExecutionException, MojoFailureException
+ {
+ if ( shouldSkip() )
+ return;
+
+ // get packageName if specified for JNI.
+ String packageName = null;
+ String narSystemName = null;
+ String narSystemDirectory = null;
+ boolean jniFound = false;
+ for ( Iterator i = getLibraries().iterator(); !jniFound && i.hasNext(); )
+ {
+ Library library = (Library) i.next();
+ if ( library.getType().equals( Library.JNI ) )
+ {
+ packageName = library.getNarSystemPackage();
+ narSystemName = library.getNarSystemName();
+ narSystemDirectory = library.getNarSystemDirectory();
+ jniFound = true;
+ }
+ }
+
+ if ( !jniFound || packageName == null)
+ return;
+
+ File narSystemTarget = new File(getMavenProject().getBasedir(), narSystemDirectory);
+
+ // make sure destination is there
+ narSystemTarget.mkdirs();
+
+ getMavenProject().addCompileSourceRoot( narSystemTarget.getPath() );
+
+ File fullDir = new File( narSystemTarget, packageName.replace( '.', '/' ) );
+ fullDir.mkdirs();
+
+ File narSystem = new File( fullDir, narSystemName + ".java" );
+ getLog().info("Generating "+narSystem);
+ try
+ {
+ String artifactId = getMavenProject().getArtifactId();
+ String version = getMavenProject().getVersion();
+ FileOutputStream fos = new FileOutputStream( narSystem );
+ PrintWriter p = new PrintWriter( fos );
+ p.println( "// DO NOT EDIT: Generated by NarSystemGenerate." );
+ p.println( "package " + packageName + ";" );
+ p.println( "" );
+ p.println( "/**" );
+ p.println( " * Generated class to load the correct version of the jni library" );
+ p.println( " *" );
+ p.println( " * @author maven-nar-plugin" );
+ p.println( " */" );
+ p.println( "public class NarSystem" );
+ p.println( "{" );
+ p.println( "" );
+ p.println( " private NarSystem() " );
+ p.println( " {" );
+ p.println( " }" );
+ p.println( "" );
+ p.println( " /**" );
+ p.println( " * Load jni library: "+artifactId+"-"+version );
+ p.println( " *" );
+ p.println( " * @author maven-nar-plugin" );
+ p.println( " */" );
+ p.println( " public static void loadLibrary()" );
+ p.println( " {" );
+ p.println( " System.loadLibrary(\"" + artifactId + "-"
+ + version + "\");" );
+ p.println( " }" );
+ p.println( "}" );
+ p.close();
+ fos.close();
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Could not write '" + narSystemName + "'", e );
+ }
+ }
+}
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 9b5a98f..2b1d95a 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarTestCompileMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarTestCompileMojo.java
@@ -131,8 +131,7 @@ public class NarTestCompileMojo
// FIXME hardcoded values
String libName = getFinalName();
File includeDir = new File( getMavenProject().getBuild().getDirectory(), "nar/include" );
- File libDir =
- new File( getMavenProject().getBuild().getDirectory(), "nar/lib/" + getAOL() + "/" + test.getLink() );
+ File libDir = getLayout().getLibDirectory( super.getTargetDirectory(), getAOL().toString(), test.getLink() );
// copy shared library
// FIXME why do we do this ?
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 3dd89ff..bc7d487 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java
@@ -44,7 +44,6 @@ import org.codehaus.plexus.util.StringUtils;
public class NarTestMojo
extends AbstractCompileMojo
{
-
/**
* The classpath elements of the project being tested.
*
@@ -100,15 +99,16 @@ public class NarTestMojo
if ( library.getType().equals( Library.EXECUTABLE ) && library.shouldRun() )
{
MavenProject project = getMavenProject();
- String name = "target/nar/bin/" + getAOL() + "/" + project.getArtifactId();
- getLog().info( "Running executable " + name );
+ // FIXME NAR-90, we could make dure we get the final name from layout
+ File executable = new File(getLayout().getLibDirectory( super.getTargetDirectory(), getAOL().toString(), library.getType() ), project.getArtifactId() );
+ getLog().info( "Running executable " + executable );
List args = library.getArgs();
int result =
- NarUtil.runCommand( project.getBasedir() + "/" + name,
+ NarUtil.runCommand( executable.getPath(),
(String[]) args.toArray( new String[args.size()] ), null,
generateEnvironment( library, getLog() ), getLog() );
if ( result != 0 )
- throw new MojoFailureException( "Test " + name + " failed with exit code: " + result + " 0x"
+ throw new MojoFailureException( "Test " + executable + " failed with exit code: " + result + " 0x"
+ Integer.toHexString( result ) );
}
}
@@ -131,8 +131,9 @@ public class NarTestMojo
Library lib = (Library) i.next();
if ( lib.getType().equals( Library.SHARED ) )
{
- sharedPaths.add( new File( getMavenProject().getBasedir(), "target/nar/lib/" + getAOL() + "/"
- + lib.getType() ) );
+ File path = getLayout().getLibDirectory( super.getTargetDirectory(), getAOL().toString(), lib.getType() );
+ getLog().debug( "Adding path to shared library: "+path );
+ sharedPaths.add( path );
}
}
@@ -151,6 +152,7 @@ public class NarTestMojo
if ( 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" );