summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Donszelmann <Mark.Donszelmann@gmail.com>2009-10-19 22:49:36 +0200
committerMark Donszelmann <Mark.Donszelmann@gmail.com>2009-10-19 22:49:36 +0200
commit72983d6e09fd565f8b99764940ec51d85f8560c5 (patch)
treeb8a6af6cb5d9d2309e7b2917a057d5d901fa34b8
parentd03cbbf6a547b88a060f2b682df52969e067a3c7 (diff)
downloadmaven-nar-plugin-72983d6e09fd565f8b99764940ec51d85f8560c5.tar.gz
maven-nar-plugin-72983d6e09fd565f8b99764940ec51d85f8560c5.tar.bz2
maven-nar-plugin-72983d6e09fd565f8b99764940ec51d85f8560c5.tar.xz
maven-nar-plugin-72983d6e09fd565f8b99764940ec51d85f8560c5.zip
Partial fix of NAR-73
-rw-r--r--pom.xml28
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/AbstractCompileMojo.java2
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/Javah.java30
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarJavahMojo.java15
-rw-r--r--src/main/java/org/apache/maven/plugin/nar/NarUtil.java3
5 files changed, 60 insertions, 18 deletions
diff --git a/pom.xml b/pom.xml
index aeb30ff..ae80d05 100644
--- a/pom.xml
+++ b/pom.xml
@@ -46,7 +46,7 @@
</distributionManagement>
<prerequisites>
- <maven>2.0.6</maven>
+ <maven>2.0.9</maven>
</prerequisites>
<scm>
@@ -60,7 +60,7 @@
</issueManagement>
<properties>
- <mavenVersion>2.0.6</mavenVersion>
+ <mavenVersion>2.0.9</mavenVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
@@ -83,7 +83,7 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-toolchain</artifactId>
- <version>1.0</version>
+ <version>2.0.10</version>
</dependency>
<dependency>
@@ -133,6 +133,28 @@
<build>
<defaultGoal>install</defaultGoal>
<plugins>
+<!-- FIXME NAR-73, wait for this plugin to be available
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-toolchains-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <phase>validate</phase>
+ <goals>
+ <goal>toolchain</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <toolchains>
+ <jdk>
+ <version>[1.4)</version>
+ </jdk>
+ </toolchains>
+ </configuration>
+ </plugin>
+-->
<!--
<plugin>
<groupId>org.apache.maven.plugins</groupId>
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 ab43ddf..4359e22 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;
-
+
private NarInfo narInfo;
private List/* <String> */dependencyLibOrder;
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 2856972..8383a4f 100644
--- a/src/main/java/org/apache/maven/plugin/nar/Javah.java
+++ b/src/main/java/org/apache/maven/plugin/nar/Javah.java
@@ -31,7 +31,6 @@ import org.apache.bcel.classfile.ClassFormatException;
import org.apache.bcel.classfile.JavaClass;
import org.apache.bcel.classfile.Method;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
-import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.toolchain.Toolchain;
@@ -41,7 +40,6 @@ import org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner;
import org.codehaus.plexus.compiler.util.scan.StaleSourceScanner;
import org.codehaus.plexus.compiler.util.scan.mapping.SingleTargetSourceMapping;
import org.codehaus.plexus.compiler.util.scan.mapping.SuffixMapping;
-import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.StringUtils;
@@ -125,15 +123,6 @@ public class Javah
* @parameter
*/
private File timestampFile;
-
- /**
- * The current build session instance.
- *
- * @parameter expression="${session}"
- * @required
- * @readonly
- */
- private MavenSession session;
private AbstractCompileMojo mojo;
@@ -250,6 +239,9 @@ public class Javah
File javahFile = new File( mojo.getJavaHome( mojo.getAOL() ), "bin" );
String javah = new File( javahFile, name ).getAbsolutePath();
+ Toolchain tc = getToolchain();
+ System.err.println( tc.findTool( "javac" ) );
+
mojo.getLog().info( "Running " + javah + " compiler on " + files.size() + " classes..." );
int result = NarUtil.runCommand( javah, generateArgs( files ), null, null, mojo.getLog() );
if ( result != 0 )
@@ -308,4 +300,20 @@ public class Javah
return (String[]) args.toArray( new String[args.size()] );
}
+
+ //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()
+ {
+ Toolchain toolChain = null;
+ ToolchainManager toolchainManager = ((NarJavahMojo)mojo).toolchainManager;
+ System.err.println("tcm: "+toolchainManager);
+
+ if ( toolchainManager != null )
+ {
+ toolChain = toolchainManager.getToolchainFromBuildContext( "jdk", ((NarJavahMojo)mojo).session );
+ System.err.println("tc: "+toolChain);
+ }
+ return toolChain;
+ }
}
diff --git a/src/main/java/org/apache/maven/plugin/nar/NarJavahMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarJavahMojo.java
index 4642313..474eb8b 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarJavahMojo.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarJavahMojo.java
@@ -19,8 +19,10 @@ package org.apache.maven.plugin.nar;
* under the License.
*/
+import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.toolchain.ToolchainManager;
/**
* Compiles class files into c/c++ headers using "javah". Any class file that contains methods that were declared
@@ -33,6 +35,19 @@ import org.apache.maven.plugin.MojoFailureException;
public class NarJavahMojo
extends AbstractCompileMojo
{
+ /**
+ * @component
+ */
+ ToolchainManager toolchainManager;
+
+ /**
+ * The current build session instance.
+ *
+ * @parameter expression="${session}"
+ * @required
+ * @readonly
+ */
+ MavenSession session;
public void execute()
throws MojoExecutionException, MojoFailureException
diff --git a/src/main/java/org/apache/maven/plugin/nar/NarUtil.java b/src/main/java/org/apache/maven/plugin/nar/NarUtil.java
index 829b240..07e8212 100644
--- a/src/main/java/org/apache/maven/plugin/nar/NarUtil.java
+++ b/src/main/java/org/apache/maven/plugin/nar/NarUtil.java
@@ -28,7 +28,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
-import java.util.Vector;
import java.util.regex.Pattern;
import org.apache.bcel.classfile.ClassFormatException;
@@ -39,8 +38,6 @@ import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.logging.Log;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.PropertyUtils;
-import org.codehaus.plexus.util.cli.CommandLineException;
-import org.codehaus.plexus.util.cli.CommandLineUtils;
import org.codehaus.plexus.util.cli.Commandline;
/**