summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/Library.java4
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/Linker.java20
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarSystemGenerate.java18
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java7
4 files changed, 33 insertions, 16 deletions
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 5785ac6..5b8959b 100644
--- a/src/main/java/org/apache/maven/plugin/nar/Library.java
+++ b/src/main/java/org/apache/maven/plugin/nar/Library.java
@@ -87,7 +87,7 @@ public class Library
* @parameter expression="${project.build.dir}/nar/nar-generated"
* @required
*/
- protected File narSystemDirectory = new File( "target/nar/nar-generated" );
+ protected String narSystemDirectory = "target/nar/nar-generated";
/**
* When true and if type is "executable" run this executable. Defaults to false;
@@ -139,7 +139,7 @@ public class Library
return narSystemName;
}
- public File getNarSystemDirectory()
+ public String getNarSystemDirectory()
{
return narSystemDirectory;
}
diff --git a/src/main/java/org/apache/maven/plugin/nar/Linker.java b/src/main/java/org/apache/maven/plugin/nar/Linker.java
index 5d9069f..2bfc6aa 100644
--- a/src/main/java/org/apache/maven/plugin/nar/Linker.java
+++ b/src/main/java/org/apache/maven/plugin/nar/Linker.java
@@ -179,28 +179,38 @@ public class Linker
throw new MojoFailureException( "Cannot deduce linker version if name is null" );
String version = null;
-
+
TextStream out = new StringTextStream();
TextStream err = new StringTextStream();
TextStream dbg = new StringTextStream();
if ( name.equals( "g++" ) || name.equals( "gcc" ) )
{
- NarUtil.runCommand( "gcc", new String[] { "--version" }, null, null, out, err, dbg );
+ int r = NarUtil.runCommand( "gcc", new String[] { "--version" }, null, null, out, err, dbg );
Pattern p = Pattern.compile( "\\d+\\.\\d+\\.\\d+" );
Matcher m = p.matcher( out.toString() );
- if (m.find()) {
+ if ( m.find() )
+ {
version = m.group( 0 );
}
+ else
+ {
+ throw new MojoFailureException( "Cannot deduce version number from: " + out );
+ }
}
else if ( name.equals( "msvc" ) )
{
- NarUtil.runCommand( "link", new String[] { "/version" }, null, null, out, err, dbg );
+ int r = NarUtil.runCommand( "link", new String[] { "/version" }, null, null, out, err, dbg );
Pattern p = Pattern.compile( "\\d+\\.\\d+\\.\\d+" );
Matcher m = p.matcher( out.toString() );
- if (m.find()) {
+ if ( m.find() )
+ {
version = m.group( 0 );
}
+ else
+ {
+ throw new MojoFailureException( "Cannot deduce version number from: " + out );
+ }
}
else
{
diff --git a/src/main/java/org/apache/maven/plugin/nar/NarSystemGenerate.java b/src/main/java/org/apache/maven/plugin/nar/NarSystemGenerate.java
index 84db06e..988300d 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarSystemGenerate.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarSystemGenerate.java
@@ -49,8 +49,9 @@ public class NarSystemGenerate
// get packageName if specified for JNI.
String packageName = null;
String narSystemName = null;
- File narSystemDirectory = null;
- for ( Iterator i = getLibraries().iterator(); i.hasNext() && ( packageName == 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 ) )
@@ -58,18 +59,21 @@ public class NarSystemGenerate
packageName = library.getNarSystemPackage();
narSystemName = library.getNarSystemName();
narSystemDirectory = library.getNarSystemDirectory();
+ jniFound = true;
}
}
-
- if ( packageName == null )
+
+ if ( !jniFound )
return;
+ File narSystemTarget = new File(getMavenProject().getBasedir(), narSystemDirectory);
+
// make sure destination is there
- narSystemDirectory.mkdirs();
+ narSystemTarget.mkdirs();
- getMavenProject().addCompileSourceRoot( narSystemDirectory.getPath() );
+ getMavenProject().addCompileSourceRoot( narSystemTarget.getPath() );
- File fullDir = new File( narSystemDirectory, packageName.replace( '.', '/' ) );
+ File fullDir = new File( narSystemTarget, packageName.replace( '.', '/' ) );
fullDir.mkdirs();
File narSystem = new File( fullDir, narSystemName + ".java" );
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 46b7dae..3dd89ff 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarTestMojo.java
@@ -80,10 +80,13 @@ public class NarTestMojo
{
String name = "target/test-nar/bin/" + getAOL() + "/" + test.getName();
getLog().info( "Running test " + name );
+
+ File workingDir = getMavenProject().getBasedir();
+ getLog().info( " in " + workingDir );
List args = test.getArgs();
int result =
NarUtil.runCommand( getMavenProject().getBasedir() + "/" + name,
- (String[]) args.toArray( new String[args.size()] ), null,
+ (String[]) args.toArray( new String[args.size()] ), workingDir,
generateEnvironment( test, getLog() ), getLog() );
if ( result != 0 )
throw new MojoFailureException( "Test " + name + " failed with exit code: " + result + " 0x"
@@ -102,7 +105,7 @@ public class NarTestMojo
List args = library.getArgs();
int result =
NarUtil.runCommand( project.getBasedir() + "/" + name,
- (String[]) args.toArray( new String[args.size()] ), null,
+ (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"