diff options
author | Mark Donszelmann <Mark.Donszelmann@gmail.com> | 2009-11-04 22:25:31 +0100 |
---|---|---|
committer | Mark Donszelmann <Mark.Donszelmann@gmail.com> | 2009-11-04 22:25:31 +0100 |
commit | 589cb40ca4a843e7d1d0a8ceed7f66d3659cbf9c (patch) | |
tree | eb3789ff3e501d3245383b03504fedcc066dd665 | |
parent | 3ea795d8d745bf050e6d98b7aa0d42dc5f33fcef (diff) | |
download | maven-nar-plugin-589cb40ca4a843e7d1d0a8ceed7f66d3659cbf9c.tar.gz maven-nar-plugin-589cb40ca4a843e7d1d0a8ceed7f66d3659cbf9c.tar.bz2 maven-nar-plugin-589cb40ca4a843e7d1d0a8ceed7f66d3659cbf9c.tar.xz maven-nar-plugin-589cb40ca4a843e7d1d0a8ceed7f66d3659cbf9c.zip |
Fixed NAR-73
-rw-r--r-- | src/main/java/org/apache/maven/plugin/nar/Javah.java | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/main/java/org/apache/maven/plugin/nar/Javah.java b/src/main/java/org/apache/maven/plugin/nar/Javah.java index 1ea908a..e727bcb 100644 --- a/src/main/java/org/apache/maven/plugin/nar/Javah.java +++ b/src/main/java/org/apache/maven/plugin/nar/Javah.java @@ -236,9 +236,8 @@ public class Javah getJniDirectory().mkdirs(); getTimestampDirectory().mkdirs(); - File javahFile = new File( mojo.getJavaHome( mojo.getAOL() ), "bin" ); - String javah = new File( javahFile, name ).getAbsolutePath(); - + String javah = getJavah(); + mojo.getLog().info( "Running " + javah + " compiler on " + files.size() + " classes..." ); int result = NarUtil.runCommand( javah, generateArgs( files ), null, null, mojo.getLog() ); if ( result != 0 ) @@ -298,6 +297,29 @@ public class Javah return (String[]) args.toArray( new String[args.size()] ); } + private String getJavah() throws MojoExecutionException, MojoFailureException { + String javah = null; + + // try toolchain + Toolchain toolchain = getToolchain(); + if (toolchain != null) { + javah = toolchain.findTool( "javah" ); + } + + // try java home + if (javah == null) { + File javahFile = new File( mojo.getJavaHome( mojo.getAOL() ), "bin" ); + javah = new File( javahFile, name ).getAbsolutePath(); + } + + // forget it... + if (javah == null) { + throw new MojoExecutionException( "NAR: Cannot find 'javah' in Toolchain or on JavaHome" ); + } + + return javah; + } + //TODO remove the part with ToolchainManager lookup once we depend on //2.0.9 (have it as prerequisite). Define as regular component field then. private Toolchain getToolchain() |