Author: mkleint
Date: Wed Sep 19 05:10:23 2007
New Revision: 577269

URL: http://svn.apache.org/viewvc?rev=577269&view=rev
Log:
MNG-468 toolchain-ize surefire plugin.

Modified:
    maven/plugins/branches/MNG-468/maven-surefire-plugin/pom.xml
    
maven/plugins/branches/MNG-468/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java

Modified: maven/plugins/branches/MNG-468/maven-surefire-plugin/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/branches/MNG-468/maven-surefire-plugin/pom.xml?rev=577269&r1=577268&r2=577269&view=diff
==============================================================================
--- maven/plugins/branches/MNG-468/maven-surefire-plugin/pom.xml (original)
+++ maven/plugins/branches/MNG-468/maven-surefire-plugin/pom.xml Wed Sep 19 
05:10:23 2007
@@ -107,6 +107,11 @@
       <artifactId>maven-artifact</artifactId>
       <version>2.0</version>
     </dependency>
+    <dependency>
+      <groupId>org.apache.maven.shared</groupId>
+      <artifactId>maven-toolchain</artifactId>
+      <version>1.0-SNAPSHOT</version>
+    </dependency>
   </dependencies>
 
   <profiles>

Modified: 
maven/plugins/branches/MNG-468/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/branches/MNG-468/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java?rev=577269&r1=577268&r2=577269&view=diff
==============================================================================
--- 
maven/plugins/branches/MNG-468/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
 (original)
+++ 
maven/plugins/branches/MNG-468/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
 Wed Sep 19 05:10:23 2007
@@ -56,6 +56,9 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import org.apache.maven.context.BuildContextManager;
+import org.apache.maven.toolchain.Toolchain;
+import org.apache.maven.toolchain.ToolchainManager;
 
 /**
  * Run tests using Surefire.
@@ -385,6 +388,19 @@
      * @parameter expression="${enableAssertions}" default-value="true"
      */
     private boolean enableAssertions;
+    
+    /**
+     *
+     * @component
+     */
+    private ToolchainManager toolchainManager;
+    
+    /**
+     *
+     * @component
+     */
+    private BuildContextManager buildContextManager;
+    
 
     public void execute()
         throws MojoExecutionException, MojoFailureException
@@ -659,7 +675,22 @@
 
             surefireBooter.addClassPathUrl( classpathElement );
         }
-
+        
+        //use the compilerId as identifier for toolchains as well.
+        Toolchain tc = toolchainManager.getToolchainFromBuildContext("jdk",  
+                                buildContextManager.readBuildContext(true));
+        if (tc != null) {
+            getLog().info("Toolchain in surefire: " + tc);
+            if (ForkConfiguration.FORK_NEVER.equals( forkMode ) ) {
+                forkMode = ForkConfiguration.FORK_ONCE;
+            }
+            if ( jvm  != null) {
+                getLog().warn("Toolchains are ignored, 'executable' parameter 
is set to " + jvm);
+            } else {
+                jvm = tc.findTool("java");
+            }
+        }
+        
         // 
----------------------------------------------------------------------
         // Forking
         // 
----------------------------------------------------------------------


Reply via email to