Skip to content

Commit 1a5255b

Browse files
committed
Allow configure initial values for new JUnit launches with preferences
Currently PDE creates a new JUnit launch with quite broad default settings that often lead to large launches and users has to adjust them after the first run to their own needs. This now adds new preference options to control these values chosen for new launch configurations and defaults to the smallest possible configuration that is only the test-plugin and include all requirements automatically.
1 parent 44e7af8 commit 1a5255b

15 files changed

Lines changed: 388 additions & 208 deletions

File tree

ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/ICoreConstants.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -352,12 +352,6 @@ public interface ICoreConstants {
352352
* build as background job
353353
*/
354354
String RUN_API_ANALYSIS_AS_JOB = "Preferences.MainPage.runAPIAnalysisAsJob";//$NON-NLS-1$
355-
/**
356-
* Boolean preference whether add
357-
* '-Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=true' to VM
358-
* arguments when creating a new launch configuration
359-
*/
360-
String ADD_SWT_NON_DISPOSAL_REPORTING = "Preferences.MainPage.addSwtNonDisposalReporting ";//$NON-NLS-1$
361355

362356
/**
363357
* Explicit preference value for {@link #WORKSPACE_TARGET_HANDLE} when the user chooses no

ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDEPreferencesManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ public void setValueOrRemove(String key, int value) {
350350
* @see #setToDefault(String)
351351
*/
352352
public void setValueOrRemove(String key, String value) {
353-
if (value.equals(getDefaultString(key))) {
353+
if (value == null || value.equals(getDefaultString(key))) {
354354
fInstanceScopePrefs.remove(key);
355355
} else {
356356
fInstanceScopePrefs.put(key, value);

ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PreferenceInitializer.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ public void initializeDefaultPreferences() {
7676
corePrefs.setDefault(ICoreConstants.WORKSPACE_PLUGINS_OVERRIDE_TARGET, true);
7777
corePrefs.setDefault(ICoreConstants.DISABLE_API_ANALYSIS_BUILDER, false);
7878
corePrefs.setDefault(ICoreConstants.RUN_API_ANALYSIS_AS_JOB, false);
79-
corePrefs.setDefault(ICoreConstants.ADD_SWT_NON_DISPOSAL_REPORTING, true);
8079
corePrefs.setDefault(ICoreConstants.TEST_PLUGIN_PATTERN, ICoreConstants.TEST_PLUGIN_PATTERN_DEFAULTVALUE);
8180
}
8281
}

ui/org.eclipse.pde.launching/src/org/eclipse/pde/internal/launching/ILaunchingPreferenceConstants.java

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,26 @@
2020
*/
2121
public interface ILaunchingPreferenceConstants {
2222

23+
public static final String VALUE_JUNIT_LAUNCH_WITH_TESTPLUGIN = "testPluginOnly"; //$NON-NLS-1$
24+
public static final String VALUE_JUNIT_LAUNCH_WITH_ALL = "allWorkspacePlugins"; //$NON-NLS-1$
25+
2326
// Main preference page
24-
public static final String PROP_AUTO_MANAGE = "Preferences.MainPage.automanageDependencies"; //$NON-NLS-1$
25-
public static final String PROP_RUNTIME_WORKSPACE_LOCATION = "Preferences.MainPage.runtimeWorkspaceLocation"; //$NON-NLS-1$
26-
public static final String PROP_RUNTIME_WORKSPACE_LOCATION_IS_CONTAINER = "Preferences.MainPage.runtimeWorkspaceLocationIsContainer"; //$NON-NLS-1$
27-
public static final String PROP_JUNIT_WORKSPACE_LOCATION = "Preferences.MainPage.junitWorkspaceLocation"; //$NON-NLS-1$
28-
public static final String PROP_JUNIT_WORKSPACE_LOCATION_IS_CONTAINER = "Preferences.MainPage.junitWorkspaceLocationIsContainer"; //$NON-NLS-1$
27+
public static final String PROP_AUTO_MANAGE = "Preferences.Launching.automanageDependencies"; //$NON-NLS-1$
28+
public static final String PROP_RUNTIME_WORKSPACE_LOCATION = "Preferences.Launching.runtimeWorkspaceLocation"; //$NON-NLS-1$
29+
public static final String PROP_RUNTIME_WORKSPACE_LOCATION_IS_CONTAINER = "Preferences.Launching.runtimeWorkspaceLocationIsContainer"; //$NON-NLS-1$
30+
public static final String PROP_JUNIT_WORKSPACE_LOCATION = "Preferences.Launching.junitWorkspaceLocation"; //$NON-NLS-1$
31+
public static final String PROP_JUNIT_LAUNCH_WITH = "Preferences.Launching.junitLaunchWith"; //$NON-NLS-1$
32+
public static final String PROP_JUNIT_AUTO_INCLUDE = "Preferences.Launching.junitAutoInclude"; //$NON-NLS-1$
33+
public static final String PROP_JUNIT_INCLUDE_OPTIONAL = "Preferences.Launching.junitIncludeOptional"; //$NON-NLS-1$
34+
public static final String PROP_JUNIT_ADD_NEW_WORKSPACE_PLUGINS = "Preferences.Launching.junitAddNewWorkspacePlugins"; //$NON-NLS-1$
35+
public static final String PROP_JUNIT_VALIDATE_LAUNCH = "Preferences.Launching.junitValidateLaunch"; //$NON-NLS-1$
36+
public static final String PROP_JUNIT_WORKSPACE_LOCATION_IS_CONTAINER = "Preferences.Launching.junitWorkspaceLocationIsContainer"; //$NON-NLS-1$
37+
/**
38+
* Boolean preference whether add
39+
* '-Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=true' to VM
40+
* arguments when creating a new launch configuration
41+
*/
42+
public static final String ADD_SWT_NON_DISPOSAL_REPORTING = "Preferences.Launching.addSwtNonDisposalReporting";//$NON-NLS-1$
2943

3044
// OSGi Frameworks
3145
public static final String DEFAULT_OSGI_FRAMEOWRK = "Preference.default.osgi.framework"; //$NON-NLS-1$

ui/org.eclipse.pde.launching/src/org/eclipse/pde/internal/launching/PreferenceInitializer.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ public void initializeDefaultPreferences() {
3030
prefs.putBoolean(ILaunchingPreferenceConstants.PROP_RUNTIME_WORKSPACE_LOCATION_IS_CONTAINER, true);
3131
prefs.put(ILaunchingPreferenceConstants.PROP_JUNIT_WORKSPACE_LOCATION, "${workspace_loc}/../junit-workspace"); //$NON-NLS-1$
3232
prefs.putBoolean(ILaunchingPreferenceConstants.PROP_JUNIT_WORKSPACE_LOCATION_IS_CONTAINER, false);
33+
prefs.put(ILaunchingPreferenceConstants.PROP_JUNIT_LAUNCH_WITH, ILaunchingPreferenceConstants.VALUE_JUNIT_LAUNCH_WITH_TESTPLUGIN);
34+
prefs.putBoolean(ILaunchingPreferenceConstants.PROP_JUNIT_AUTO_INCLUDE, true);
35+
prefs.putBoolean(ILaunchingPreferenceConstants.PROP_JUNIT_INCLUDE_OPTIONAL, true);
36+
prefs.putBoolean(ILaunchingPreferenceConstants.PROP_JUNIT_ADD_NEW_WORKSPACE_PLUGINS, false);
37+
prefs.putBoolean(ILaunchingPreferenceConstants.PROP_JUNIT_VALIDATE_LAUNCH, true);
38+
prefs.putBoolean(ILaunchingPreferenceConstants.ADD_SWT_NON_DISPOSAL_REPORTING, true);
3339

3440
// copy over instance scope prefs from UI plugin
3541
IEclipsePreferences oldInstancePrefs = InstanceScope.INSTANCE.getNode(IPDEConstants.UI_PLUGIN_ID);

ui/org.eclipse.pde.launching/src/org/eclipse/pde/internal/launching/launcher/LaunchArgumentsHelper.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
import org.eclipse.pde.core.plugin.TargetPlatform;
5050
import org.eclipse.pde.core.target.ITargetPlatformService;
5151
import org.eclipse.pde.internal.build.IPDEBuildConstants;
52-
import org.eclipse.pde.internal.core.ICoreConstants;
5352
import org.eclipse.pde.internal.core.PDECore;
5453
import org.eclipse.pde.internal.core.PDEPreferencesManager;
5554
import org.eclipse.pde.internal.core.TargetPlatformHelper;
@@ -440,8 +439,8 @@ public static String getDefaultJUnitConfigurationLocation() {
440439
* '-Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=true'
441440
*/
442441
public static boolean getAddSwtNonDisposalReportingPreference() {
443-
PDEPreferencesManager prefs = PDECore.getDefault().getPreferencesManager();
444-
return prefs.getBoolean(ICoreConstants.ADD_SWT_NON_DISPOSAL_REPORTING);
442+
PDEPreferencesManager launchingStore = PDELaunchingPlugin.getDefault().getPreferenceManager();
443+
return launchingStore.getBoolean(ILaunchingPreferenceConstants.ADD_SWT_NON_DISPOSAL_REPORTING);
445444
}
446445

447446
}

ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/LocalTargetDefinitionTests.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@
4343
import org.eclipse.pde.core.target.ITargetLocation;
4444
import org.eclipse.pde.core.target.NameVersionDescriptor;
4545
import org.eclipse.pde.core.target.TargetBundle;
46-
import org.eclipse.pde.internal.core.ICoreConstants;
4746
import org.eclipse.pde.internal.core.P2Utils;
48-
import org.eclipse.pde.internal.core.PDECore;
4947
import org.eclipse.pde.internal.core.PDEPreferencesManager;
5048
import org.eclipse.pde.internal.core.TargetPlatformHelper;
5149
import org.eclipse.pde.internal.core.target.TargetPlatformService;
50+
import org.eclipse.pde.internal.launching.ILaunchingPreferenceConstants;
51+
import org.eclipse.pde.internal.launching.PDELaunchingPlugin;
5252
import org.eclipse.pde.internal.launching.launcher.LaunchArgumentsHelper;
5353
import org.eclipse.pde.ui.tests.PDETestCase;
5454
import org.junit.Test;
@@ -549,7 +549,7 @@ public void testArguments() throws Exception {
549549
definition.setVMArguments(vmArgs);
550550
assertEquals(vmArgs, definition.getVMArguments());
551551

552-
PDEPreferencesManager prefs = PDECore.getDefault().getPreferencesManager();
552+
PDEPreferencesManager prefs = PDELaunchingPlugin.getDefault().getPreferenceManager();
553553
try {
554554
getTargetService().saveTargetDefinition(definition);
555555
setTargetPlatform(definition);
@@ -563,24 +563,24 @@ public void testArguments() throws Exception {
563563

564564
// Check that new launch configs will be prepopulated from target
565565
// along with ADD_SWT_NON_DISPOSAL_REPORTING == false
566-
prefs.setValue(ICoreConstants.ADD_SWT_NON_DISPOSAL_REPORTING, false);
566+
prefs.setValue(ILaunchingPreferenceConstants.ADD_SWT_NON_DISPOSAL_REPORTING, false);
567567
assertEquals(vmArgs, LaunchArgumentsHelper.getInitialVMArguments());
568568

569569
// Check that new launch configs will be prepopulated from target
570570
// along with ADD_SWT_NON_DISPOSAL_REPORTING == true
571-
prefs.setValue(ICoreConstants.ADD_SWT_NON_DISPOSAL_REPORTING, true);
571+
prefs.setValue(ILaunchingPreferenceConstants.ADD_SWT_NON_DISPOSAL_REPORTING, true);
572572
assertEquals(vmArgs + " -Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=true",
573573
LaunchArgumentsHelper.getInitialVMArguments());
574574

575575
// Check that new launch configs will be prepopulated from target
576576
// along with ADD_SWT_NON_DISPOSAL_REPORTING == true but the define
577577
// is already set in the target platform to false
578-
prefs.setValue(ICoreConstants.ADD_SWT_NON_DISPOSAL_REPORTING, true);
578+
prefs.setValue(ILaunchingPreferenceConstants.ADD_SWT_NON_DISPOSAL_REPORTING, true);
579579
vmArgs = "-testVMArgument -Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=false -testVMArgument2";
580580
definition.setVMArguments(vmArgs);
581581
assertEquals(vmArgs, LaunchArgumentsHelper.getInitialVMArguments());
582582
} finally {
583-
prefs.setToDefault(ICoreConstants.ADD_SWT_NON_DISPOSAL_REPORTING);
583+
prefs.setToDefault(ILaunchingPreferenceConstants.ADD_SWT_NON_DISPOSAL_REPORTING);
584584
getTargetService().deleteTarget(definition.getHandle());
585585
resetTargetPlatform();
586586
}

ui/org.eclipse.pde.ui/plugin.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@
9090
class="org.eclipse.pde.bnd.ui.preferences.ReposPreferencePage"
9191
id="org.eclipse.pde.bnd.ui.preferences.ReposPreferencePage">
9292
</page>
93+
<page
94+
category="org.eclipse.pde.ui.MainPreferencePage"
95+
class="org.eclipse.pde.internal.ui.preferences.LaunchingPreferencePage"
96+
id="org.eclipse.pde.ui.LaunchingPreferencePage"
97+
name="Launching">
98+
</page>
9399
</extension>
94100
<extension
95101
point="org.eclipse.ui.keywords">

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/IPreferenceConstants.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,6 @@ public interface IPreferenceConstants extends ILaunchingPreferenceConstants {
4444
* Boolean preference whether API analysis has been disabled
4545
*/
4646
public static final String DISABLE_API_ANALYSIS_BUILDER = "Preferences.MainPage.disableAPIAnalysisBuilder";//$NON-NLS-1$
47-
/**
48-
* Boolean preference whether add
49-
* '-Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=true' to VM
50-
* arguments when creating a new launch configuration
51-
*/
52-
public static final String ADD_SWT_NON_DISPOSAL_REPORTING = "Preferences.MainPage.addSwtNonDisposalReporting ";//$NON-NLS-1$
53-
5447

5548
// Editor Outline
5649
public static final String PROP_OUTLINE_SORTING = "PDEMultiPageContentOutline.SortingAction.isChecked"; //$NON-NLS-1$

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,8 @@ public class PDEUIMessages extends NLS {
594594
public static String MainPreferencePage_WorkspacePluginsOverrideTarget;
595595
public static String MainPreferencePage_WorkspacePluginsOverrideTargetTooltip;
596596
public static String MainPreferencePage_DisableAPIAnalysisBuilder;
597+
598+
public static String MainPreferencePage_optionTestPlugin;
597599
public static String MainPreferencePage_RunAPIAnalysisBuilderAsJob;
598600

599601
public static String MainPreferencePage_test_plugin_pattern_group;
@@ -2704,6 +2706,8 @@ public class PDEUIMessages extends NLS {
27042706

27052707
public static String LauncherUtils_title;
27062708

2709+
public static String LaunchingPreferencePage_description;
2710+
27072711
public static String RemoveLazyLoadingDirectiveResolution_remove;
27082712

27092713
public static String RemoveAutomaticModuleResolution_remove;

0 commit comments

Comments
 (0)