Accessing Run/Debug Configuration from a plugin
I found this forum and believe it is the more appropriate place for the question I posed at https://devnet.jetbrains.com/thread/460610?tstart=0 Bottom line is my plugin wants to alter the default settings of the JUnit configuration. I spent quite a bit of time yesterday playing with code, researching other plugins and browsing the internet and forums to no avail.I do know that the settings are persisted in the project.ipr file, but modifying that file directly does not seem to be the 'right' way to handle this.Is there a way from within my plugin to modify the JUnit default configuration settings so that they take effect immediately?
请先登录再写评论。
Indeed there is a dedicated possibility to modify jUnit run parameters "on-the-fly" using com.intellij.execution.JUnitPatcher
AFAIU your original thread this should suit your request perfectly.
I spent a couple of hours this evening exploring JUnitPatcher. If it is capable of modifying the default JUnit configuration I've been unable to discover how. Looking at sample code it appears that I would have to implement the patchJavaParameters method to update the parameters. However the class does not seem to give me access to the JUnit runner.
The class appears to be more useful when I am providing patching ability to my own plugin.
I searched through CommunityEdition, and it appears that what I want is the JUnitConfiguration class in com.intellij.execution.junit. It appears to have set methods for all the values I wish to set.
Is it possible to get an instance of that class from the Application object? If so, where would I find it?
Thanks again.
What parameters exactly do you want to preset with your defaults?
For this particular issue I need to change the environment variables and VM options.
You should be able to access these via passed in JavaParameters parameter:
com.intellij.execution.configurations.SimpleProgramParameters#getEnv and all other ...Env methods
com.intellij.execution.configurations.SimpleJavaParameters#getVMParametersList
You can find examples in IntelliJ Community sources (jetbrains.org), e.g. org.jetbrains.idea.devkit.run.JUnitDevKitPatcher