Author: krosenvold Date: Tue May 10 19:20:13 2011 New Revision: 1101609 URL: http://svn.apache.org/viewvc?rev=1101609&view=rev Log: [SUREFIRE-720] Toolchains fixed.
Added testcase submitted by Ronald Muller. Unfortunately I do not how to automate this Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/SurefireToolchains/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/SurefireToolchains/pom.xml (with props) maven/surefire/trunk/surefire-integration-tests/src/test/resources/SurefireToolchains/src/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/SurefireToolchains/src/main/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/SurefireToolchains/src/main/java/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/SurefireToolchains/src/main/java/test/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/SurefireToolchains/src/main/java/test/surefiretoolchains/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/SurefireToolchains/src/main/java/test/surefiretoolchains/App.java (with props) maven/surefire/trunk/surefire-integration-tests/src/test/resources/SurefireToolchains/src/test/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/SurefireToolchains/src/test/java/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/SurefireToolchains/src/test/java/test/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/SurefireToolchains/src/test/java/test/surefiretoolchains/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/SurefireToolchains/src/test/java/test/surefiretoolchains/AppTest.java (with props) Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java?rev=1101609&r1=1101608&r2=1101609&view=diff ============================================================================== --- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java (original) +++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java Tue May 10 19:20:13 2011 @@ -382,25 +382,6 @@ public abstract class AbstractSurefireMo new ProviderConfiguration( directoryScannerParameters, failIfNoTests, reporterConfiguration, testNg, testSuiteDefinition, providerProperties, null ); - Toolchain tc = getToolchain(); - - if ( tc != null ) - { - getLog().info( "Toolchain in " + getPluginName() + "-plugin: " + tc ); - if ( isForkModeNever() ) - { - setForkMode( ForkConfiguration.FORK_ONCE ); - } - if ( getJvm() != null ) - { - getLog().warn( "Toolchains are ignored, 'executable' parameter is set to " + getJvm() ); - } - else - { - setJvm( tc.findTool( "java" ) ); //NOI18N - } - } - return providerConfiguration1; } @@ -627,6 +608,25 @@ public abstract class AbstractSurefireMo showMap( getInternalSystemProperties(), "system property" ); } + Toolchain tc = getToolchain(); + + if ( tc != null ) + { + getLog().info( "Toolchain in " + getPluginName() + "-plugin: " + tc ); + if ( isForkModeNever() ) + { + setForkMode( ForkConfiguration.FORK_ONCE ); + } + if ( getJvm() != null ) + { + getLog().warn( "Toolchains are ignored, 'executable' parameter is set to " + getJvm() ); + } + else + { + setJvm( tc.findTool( "java" ) ); //NOI18N + } + } + if ( fork.isForking() ) { setUseSystemClassLoader( isUseSystemClassLoader() ); @@ -641,7 +641,8 @@ public abstract class AbstractSurefireMo fork.setDebugLine( getDebugForkedProcess() ); - if ( getJvm() == null || "".equals( getJvm() ) ) + + if ( (getJvm() == null || "".equals( getJvm() ))) { // use the same JVM as the one used to run Maven (the "java.home" one) setJvm( System.getProperty( "java.home" ) + File.separator + "bin" + File.separator + "java" ); Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/SurefireToolchains/pom.xml URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/SurefireToolchains/pom.xml?rev=1101609&view=auto ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/resources/SurefireToolchains/pom.xml (added) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/SurefireToolchains/pom.xml Tue May 10 19:20:13 2011 @@ -0,0 +1,72 @@ + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <modelVersion>4.0.0</modelVersion> + <groupId>test</groupId> + <artifactId>SurefireToolchains</artifactId> + <packaging>jar</packaging> + <version>1.0-SNAPSHOT</version> + <name>Test :: SurefireToolchains</name> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <prerequisites> + <maven>2.0.9</maven> + </prerequisites> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.8.2</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>2.3.2</version> + <configuration> + <source>1.5</source> + <target>1.5</target> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>${surefire.version}</version> + <configuration> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-toolchains-plugin</artifactId> + <version>1.0</version> + <executions> + <execution> + <phase>validate</phase> + <goals> + <goal>toolchain</goal> + </goals> + </execution> + </executions> + <configuration> + <toolchains> + <jdk> + <version>1.5</version> + <vendor>sun</vendor> + </jdk> + </toolchains> + </configuration> + </plugin> + </plugins> + </build> + +</project> Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/SurefireToolchains/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/SurefireToolchains/src/main/java/test/surefiretoolchains/App.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/SurefireToolchains/src/main/java/test/surefiretoolchains/App.java?rev=1101609&view=auto ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/resources/SurefireToolchains/src/main/java/test/surefiretoolchains/App.java (added) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/SurefireToolchains/src/main/java/test/surefiretoolchains/App.java Tue May 10 19:20:13 2011 @@ -0,0 +1,8 @@ +package test.surefiretoolchains; + +public final class App { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/SurefireToolchains/src/main/java/test/surefiretoolchains/App.java ------------------------------------------------------------------------------ svn:eol-style = native Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/SurefireToolchains/src/test/java/test/surefiretoolchains/AppTest.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/SurefireToolchains/src/test/java/test/surefiretoolchains/AppTest.java?rev=1101609&view=auto ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/resources/SurefireToolchains/src/test/java/test/surefiretoolchains/AppTest.java (added) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/SurefireToolchains/src/test/java/test/surefiretoolchains/AppTest.java Tue May 10 19:20:13 2011 @@ -0,0 +1,15 @@ +package test.surefiretoolchains; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class AppTest { + + @Test + public void testApp() { + // 1.5.0_19-b02 + assertEquals("1.5.0_19", System.getProperty("java.version")); + } + +} Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/SurefireToolchains/src/test/java/test/surefiretoolchains/AppTest.java ------------------------------------------------------------------------------ svn:eol-style = native