[ http://jira.codehaus.org/browse/MSUREFIRE-145?page=comments#action_69334 ]
Vincent Massol commented on MSUREFIRE-145: ------------------------------------------ > can you post the problem instead of the solution, since I think you have > misdiagnosed this. Ok > I can't reproduce it. With: > <systemProperties> > <property><name>cargo</name><value>blargo</value></property> > </systemProperties> > and an assertion in the test case that checks the system property, it works > with forkModes of once, never and always. This is what I have. This is the parent POM. See http://fisheye.codehaus.org/browse/cargo/cargo/trunk/samples/pom.xml?r=1074 for parent POM where the surefire config is located. The POM where it's used is here: http://fisheye.codehaus.org/browse/cargo/cargo/trunk/samples/java/pom.xml?r=1068 Then I use a System.getPRoperty() in my code to get the cargo.containers property. Here's what maven says: {noformat} [INFO] ------------------------------------------------------------------------ [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] org.codehaus.cargo.sample.java.AllLocalContainerTest; nested exception is java.lang.RuntimeEx ception: System property "cargo.containers" must be defined.; nested exception is org.apache.maven.s urefire.testset.TestSetFailedException: org.codehaus.cargo.sample.java.AllLocalContainerTest; nested exception is java.lang.RuntimeException: System property "cargo.containers" must be defined. {noformat} > The mistaken assumptions you have above: > * isForking is true when forkMode is once and never, despite what you said. > * when forking, the system properties are passed on to surefire to set on > the child process, not set immediately. Therefore, the expression is > !isForking because you only want to set the system properties if you are not > forking > * the logs are not misleading. The system properties are always set, just > in different JVMs. 2 things: # I have put logs in the surefire plugin source code and indeed I can see that the code inside the "if ( setInSystem )" is NOT executed. As you can see in the POM above, the forMode is set to perTest. # Without changing anything in my project, it works with 2.1.3 and fails with 2.2 and 2.3-SNAPSHOT. Thanks Brett. Let me know if you need me to do something more. > Plugin not longer sets system properties when forking is on and debugging > information is not correct > ---------------------------------------------------------------------------------------------------- > > Key: MSUREFIRE-145 > URL: http://jira.codehaus.org/browse/MSUREFIRE-145 > Project: Maven 2.x Surefire Plugin > Type: Bug > Versions: 2.1.3 > Reporter: Vincent Massol > Priority: Blocker > > > The following code is in SurefirePlugin.java: > {code:java} > processSystemProperties( !fork.isForking() ); > if ( getLog().isDebugEnabled() ) > { > showMap( systemProperties, "system property" ); > } > {code} > 2 problems: > 1) fork.isForking() is false when forking is enabled and thus system > properties are not set: > {code:java} > protected void processSystemProperties( boolean setInSystem ) > { > [...] > if ( setInSystem ) > { > // Add all system properties configured by the user > Iterator iter = systemProperties.keySet().iterator(); > while ( iter.hasNext() ) > { > String key = (String) iter.next(); > String value = systemProperties.getProperty( key ); > System.setProperty( key, value ); > } > } > } > {code} > 2) showMap() is called regardless of whether the system properties are set > or not, leading to the following kind of misleading logs: > {noformat} > [...] > [DEBUG] Setting system property [cargo.jetty4x.port]=[8280] > [DEBUG] Setting system property [cargo.jetty6x.port]=[8280] > [DEBUG] Setting system property [cargo.jetty5x.port]=[8280] > [...] > {noformat} > Those properties are actually NOT set. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira