Default configuration for Eclipse plugin test - eclipse

I'm working on a project developing an Eclipse-based application. Running a JUnit plug-in test requires the run configuration for it to have a bunch of parameters set. This means that if I want to run a single test class or method, as far as I can tell I have to create a new configuration or edit one that I reuse. More annoyingly I can't use the convenience of Alt+Shift+X, P.
Is there a way to tell Eclipse that a bunch of parameters are the defaults for an implicitly created run configuration of a given type to use it when it's automagically creating one?

If you are using a custom target platform (which you should use anyway), you can specify Program arguments and VM arguments on the Environment tab of the target platform editor.
They will be used as default values for PDE launch configurations.

Related

eclipse how to set run configuration default for a specific project

have several java servlet projects. Each one uses a different configuration file. The servlet use and environment variable to find the config file. I have several different run time configurations. One for each project.
Is there a way to set the default run time configuration for each project. I loose a lot of time because I try to debug and accidentally select the wrong profile
Kind regards
Andy

How to turn off debugging on a project in eclipse?

My situation demands I have two copies of the same project. One is for development, the other is for debugging, testing and single stepping to understand the existing workflow.
As a consequence I have two copies of the same project. I would like both copies to behave exactly the same way except that the first project should not take part in debugging. All the JDWP [Java Debug Wire Protocol] attempts to connect and debug the remote Java process should be with respect to the untouched dedicated copy of the project that was checked out recently.
Is there a way to accomplish this?
You can create multiple debug/run configuration for the same or different projects in Eclipse.
Assume that you have a single Java project and you want to
Test your application with some VM arguments and
Without any VM arguments.
Then Go to Debug->Debug Configuration and select Java application. Create debug(launch) configuration for your project and select main class of your Java project.
For 1 go to Arguments tab in the VM text area add the arguments
For 2. Leave this blank
Thus you can debug single Java project with multiple debug configuration.
In your case you MUST create debug configuration ONLY for that project you want to debug.

How do I set a system property for compiling in Eclipse?

When I build my project from the command line with Maven, I can pass in a property using
-Dsomeproperty=true
For example:
mvn clean package -Dsomeproperty=true
How do I do the same when building in Eclipse?
You have to do the following steps (and sorry, I have no environment to prove it, just from documentation):
Create a maven build by choosing on the selected pom of your project Run > Maven...
Enter the relevant goal, and press add in the arguments table.
Enter there your system property as name: someproperty and value: true.
Then start your maven build by pressing Run.
See the following resources for details:
Creating a Java application launch configuration
Set System Property for JUnit Runner (Eclipse) to test a Spring Web App
After having access to an Eclipse again, here are some screenshots:
The first shows how to configure an existing build (in Eclipse named a run configuration) with the relevant property. and the second shows the command that is then triggered (with the include -Dsomeproperty=true).
I do not know if there is an easy way to configure the default run configuration. You may provide an empty one, enter there the parameter, and copy then that run configuration adding the additional parameters later. The copy button is on the left top the second one (with the red rectangle marking it).

Add headless capability to existing eclipse plugin

I have an existing Eclipse plugin which run as a regular IDE plugin, receiving commands from the GUI and returning output in custom views.
I want to add an ability to also be able to run that plugin in headless mode, with the input received from the command-line and the output going to some file. Is there some way of modifying the existing plugin to support that mode of execution in addition to the existing regular execution, or do I have to create a new headless plugin and just use code from the first one?
It depends on how you plan to use this plugin and the main question: is there a case, where your UI dependencies will not be available, i.e. whether there is a bundle configuration without SWT and RCP bundles?
No UI available
In this case, you'll need to extract the headless part of your plugin into new plugin, which then registers the headless entry point to it. The UI part of the plugin will depend on the new plugin and just delegate UI requests to the appropriate API in the headless part.
In order to provide headless application, you should take a look at org.eclipse.equinox.app.IApplication interface and respectively org.eclipse.equinox.applications extension point. When you've defined the application, you launch it by simply invoking:
eclipse -application <app-id> <app-param>
More information can be found in Eclipse Help.
UI available
The simpler case. Only the headless entry point needs to be specified and everything will work as previously.
My experience, however, shows that sooner or later, the case arise where the plugin needs to be split and depending on its complexity it might cause more trouble than it would have been if it was split earlier.

How to share a common customBuildCallbacks script between multiple Eclipse plug-ins

I am trying to avoid duplicating customBuildCallbacks.xml for all my plug-ins, when called from either PDE's headless build or the Eclipse GUI. I have in customBuildCallbacks.xml steps to generate code or modify the plug-in packaging that I:
obviously want to run with the headless build
would also like to run either when I export this plug-in from the GUI or from an external builder watching specific files in my plug-in
The headless build runs in a well defined environment, so I can set customBuildCallbacks.buildpath or even use a relative path in each plug-in's build.properties to point at my common customBuildCallbacks.xml. However, this is trickier from the GUI: that path is different for every developers since we do not have sources in the Eclipse workspace (we import projects from various locations due to our internal build process). I was hoping for every project to have an associated ant property holding its path on disk, similar to the ${workspace} variables exposed in various dialogs. I couldn't find anything useful though.
Does anyone have any experience doing this kind of things?
Thanks,
Romain