Hi,

I am currently trying to write a custom plugin that does two things

1. Attach a java agent to the JVM when the tests are running, causing
   some instrumentation to be logged
2. Analyze the logged instrumentation and report back to the user

I have the second part working, but I'm completely stumped by the first part. My understanding is that applying JVM arguments during tests is the responsibility of surefire, using the argLine configuration parameters - so I am trying to write a mojo that will add those parameters on the fly if they are not already there.

As it stands, I have written a mojo (InjectAgentMojo) that does the following:

 * Get the project from a parameter
 * Look up the surefire plugin using
   project.getPlugin(org.apache.maven.plugins:maven-surefire-plugin)
 * Create a configuration with the required elements, and attach it
   using setConfiguration

However, this does not seem to have any effect, and the configuration is not being used. I am calling the mojo in the INITIALIZE phase of my test project, but it seems that the configuration has already been set elsewhere by then.

Does anyone have any ideas that would make this possible? Specifically:

 * Is there a way for maven plugins to set the configuration of other
   plugins at runtime?
 * Is there another way this could be done - writing a plugin for
   surefire or something?

After a couple of days of experimenting/googling, I appear to have hit a brick wall.

Thanks in advance for any help.

James Owen

Reply via email to