Hi Gilles,

Thanks for your comments.

On Mon, 2006-07-24 at 23:48 -0700, Gilles Scokart wrote:
> ${project.classpathElements} can be used when your parameter is a List . 
> Here you want to place it in a String.

True, and maybe that's the problem. The things that are working are all
of type String.

The data is magically managed via the declaration:
 /**
  * @parameter
  */
 private Properties systemProperties;

I believe that it is the plexus container that implements the necessary
"dependency injection" stuff to take the xml in the pom.xml file and map
it into a Properties object and assign it to systemProperties. Obviously
that code is buried deep down inside plexus where normal mortals can't
see.

A Properties object does implement Map and therefore potentially
supports objects, but the surefire code clearly doesn't support this
(and reasonably too):
   // 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 );
   }

In my case, it would be ok for the classpath to be mapped from a List to
a string that the unit tests can parse; I therefore tried
  ${project.classpathElements.toString()}
but unfortunately that didn't work either. Oddly, neither did
  ${project.artifactId.substring(8)} 
when used in the properties section, though that expression certainly
does work in other places in the pom. Scary; I thought that this
variable handling/injection was being managed by Plexus and therefore
would work consistently everywhere but that doesn't seem to be the case.


If it's not going to be possible to map the classpath into a string so
it can be passed as a system property, can anyone else suggest a way for
the unit tests to obtain the surefire test-classpath? The unit tests are
explicitly run in a custom classloader to isolate them, so even if there
is some singleton method that the unit tests could call to obtain a
reference to the project object or the surefire plugin object, I expect
they wouldn't be able to see it.

I see that the existing code explicitly sets "basedir" and
"localRepository" system properties so unit tests can retrieve these.
Maybe this could be generalised..


> 
> Moreover, I think that the expension done into the pom, and the things done
> in the plugin is different. So, there is maybe some differences. 

Isn't it all done by Plexus?

Regards,

Simon


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to