diff options
11 files changed, 85 insertions, 48 deletions
diff --git a/ui/org.eclipse.pde.core/.options b/ui/org.eclipse.pde.core/.options index 9acdbfbb70..aad8810890 100644 --- a/ui/org.eclipse.pde.core/.options +++ b/ui/org.eclipse.pde.core/.options @@ -1,6 +1,11 @@ -# prints the time taken to read/write registry cache. org.eclipse.pde.core/debug=true +# prints the time taken to read/write registry cache. org.eclipse.pde.core/cache=false +# trace for the classpath container and classpath computer org.eclipse.pde.core/classpath=false -org.eclipse.pde.core/validation=false -org.eclipse.pde.core/target/profile=false
\ No newline at end of file +# prints the time taken to create the PDE plug-in models +org.eclipse.pde.core/model=false +# trace for creating targets using a p2 profile +org.eclipse.pde.core/target/profile=false +# trace when validating plugin.xml contents +org.eclipse.pde.core/validation=false
\ No newline at end of file diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/MinimalState.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/MinimalState.java index 1eb5a93691..40323a9df3 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/MinimalState.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/MinimalState.java @@ -35,8 +35,6 @@ public class MinimalState { private boolean fNoProfile; - protected static boolean DEBUG = false; - protected static StateObjectFactory stateObjectFactory; protected static String DIR; @@ -44,7 +42,6 @@ public class MinimalState { protected String fSystemBundle = IPDEBuildConstants.BUNDLE_OSGI; static { - DEBUG = PDECore.getDefault().isDebugging() && "true".equals(Platform.getDebugOption("org.eclipse.pde.core/cache")); //$NON-NLS-1$ //$NON-NLS-2$ DIR = PDECore.getDefault().getStateLocation().toOSString(); stateObjectFactory = Platform.getPlatformAdmin().getFactory(); } @@ -247,7 +244,7 @@ public class MinimalState { if (!all[i].isResolved()) { VersionConstraint[] unsatisfiedConstraints = helper.getUnsatisfiedConstraints(all[i]); if (unsatisfiedConstraints.length == 0) { - if (DEBUG) { + if (PDECore.DEBUG_CACHE) { BundleDescription activeBundle = findActiveBundle(all[i].getSymbolicName()); String message = "Plug-in located at \"" + all[i].getLocation() + "\" was disabled because plug-in located at \"" + activeBundle.getLocation() + "\" was selected."; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ System.out.print(message); diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDECore.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDECore.java index 2d6bc6570a..a541a58b3d 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDECore.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDECore.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2012 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,6 +17,8 @@ import java.util.Hashtable; import org.eclipse.core.resources.*; import org.eclipse.core.runtime.*; import org.eclipse.jdt.launching.JavaRuntime; +import org.eclipse.osgi.service.debug.DebugOptions; +import org.eclipse.osgi.service.debug.DebugOptionsListener; import org.eclipse.pde.core.IBundleClasspathResolver; import org.eclipse.pde.core.plugin.IPluginModelBase; import org.eclipse.pde.core.project.IBundleProjectService; @@ -30,7 +32,7 @@ import org.eclipse.pde.internal.core.target.TargetPlatformService; import org.eclipse.update.configurator.ConfiguratorUtils; import org.osgi.framework.*; -public class PDECore extends Plugin { +public class PDECore extends Plugin implements DebugOptionsListener { public static final String PLUGIN_ID = "org.eclipse.pde.core"; //$NON-NLS-1$ public static final IPath REQUIRED_PLUGINS_CONTAINER_PATH = new Path(PLUGIN_ID + ".requiredPlugins"); //$NON-NLS-1$ @@ -45,6 +47,19 @@ public class PDECore extends Plugin { public static final QualifiedName SCHEMA_PREVIEW_FILE = new QualifiedName(PLUGIN_ID, "SCHEMA_PREVIEW_FILE"); //$NON-NLS-1$ + private static boolean DEBUG = false; + public static boolean DEBUG_CACHE = false; + public static boolean DEBUG_CLASSPATH = false; + public static boolean DEBUG_MODEL = false; + public static boolean DEBUG_TARGET_PROFILE = false; + public static boolean DEBUG_VALIDATION = false; + private static final String DEBUG_FLAG = PLUGIN_ID + "/debug"; //$NON-NLS-1$ + private static final String CACHE_DEBUG = PLUGIN_ID + "/cache"; //$NON-NLS-1$ + private static final String CLASSPATH_DEBUG = PLUGIN_ID + "/classpath"; //$NON-NLS-1$ + private static final String MODEL_DEBUG = PLUGIN_ID + "/model"; //$NON-NLS-1$ + private static final String TARGET_PROFILE_DEBUG = PLUGIN_ID + "/target/profile"; //$NON-NLS-1$ + private static final String VALIDATION_DEBUG = PLUGIN_ID + "/validation"; //$NON-NLS-1$ + // Shared instance private static PDECore inst; @@ -268,6 +283,11 @@ public class PDECore extends Plugin { fTargetPlatformService = context.registerService(ITargetPlatformService.class.getName(), TargetPlatformService.getDefault(), new Hashtable<String, Object>()); fBundleProjectService = context.registerService(IBundleProjectService.class.getName(), BundleProjectService.getDefault(), new Hashtable<String, Object>()); + // Register the debug options listener service (tracing) + Hashtable<String, String> props = new Hashtable<String, String>(2); + props.put(org.eclipse.osgi.service.debug.DebugOptions.LISTENER_SYMBOLICNAME, PDECore.PLUGIN_ID); + context.registerService(DebugOptionsListener.class.getName(), this, props); + // use save participant to clean orphaned profiles. ResourcesPlugin.getWorkspace().addSaveParticipant(PLUGIN_ID, new ISaveParticipant() { public void saving(ISaveContext saveContext) throws CoreException { @@ -365,4 +385,16 @@ public class PDECore extends Plugin { } return service; } + + /* (non-Javadoc) + * @see org.eclipse.osgi.service.debug.DebugOptionsListener#optionsChanged(org.eclipse.osgi.service.debug.DebugOptions) + */ + public void optionsChanged(DebugOptions options) { + DEBUG = options.getBooleanOption(DEBUG_FLAG, false); + DEBUG_CACHE = DEBUG && options.getBooleanOption(CACHE_DEBUG, false); + DEBUG_CLASSPATH = DEBUG && options.getBooleanOption(CLASSPATH_DEBUG, false); + DEBUG_MODEL = DEBUG && options.getBooleanOption(MODEL_DEBUG, false); + DEBUG_TARGET_PROFILE = DEBUG && options.getBooleanOption(TARGET_PROFILE_DEBUG, false); + DEBUG_VALIDATION = DEBUG && options.getBooleanOption(VALIDATION_DEBUG, false); + } } diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDEState.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDEState.java index 3e0a9521ec..2e6fc90d4e 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDEState.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PDEState.java @@ -111,24 +111,24 @@ public class PDEState extends MinimalState { if (resolve && workspace.length > 0 && !fNewState && !"true".equals(System.getProperty("pde.nocache"))) //$NON-NLS-1$ //$NON-NLS-2$ readWorkspaceState(workspace); - if (DEBUG) + if (PDECore.DEBUG_CACHE) System.out.println("Time to create state: " + (System.currentTimeMillis() - start) + " ms"); //$NON-NLS-1$ //$NON-NLS-2$ } private void readTargetState(URL[] urls, IProgressMonitor monitor) { fTargetTimestamp = computeTimestamp(urls); - if (DEBUG) { + if (PDECore.DEBUG_CACHE) { System.out.println("Timestamp of " + urls.length + " target URLS: " + fTargetTimestamp); //$NON-NLS-1$ //$NON-NLS-2$ } File dir = new File(DIR, Long.toString(fTargetTimestamp) + ".target"); //$NON-NLS-1$ if ((fState = readStateCache(dir)) == null || !fAuxiliaryState.readPluginInfoCache(dir)) { - if (DEBUG) { + if (PDECore.DEBUG_CACHE) { System.out.println("Creating new state, persisted state did not exist"); //$NON-NLS-1$ } createNewTargetState(true, urls, monitor); resolveState(false); } else { - if (DEBUG) { + if (PDECore.DEBUG_CACHE) { System.out.println("Restored previously persisted state"); //$NON-NLS-1$ } // get the system bundle from the State @@ -369,7 +369,7 @@ public class PDEState extends MinimalState { try { urls[i] = new File(models[i].getInstallLocation()).toURL(); } catch (MalformedURLException e) { - if (DEBUG) { + if (PDECore.DEBUG_CACHE) { System.out.println("FAILED to save external state due to MalformedURLException"); //$NON-NLS-1$ } return; @@ -383,7 +383,7 @@ public class PDEState extends MinimalState { if (!osgiStateExists || !auxStateExists) { if (!dir.exists()) dir.mkdirs(); - if (DEBUG) { + if (PDECore.DEBUG_CACHE) { System.out.println("Saving external state of " + urls.length + " bundles to: " + dir.getAbsolutePath()); //$NON-NLS-1$ //$NON-NLS-2$ } State state = stateObjectFactory.createState(false); @@ -394,7 +394,7 @@ public class PDEState extends MinimalState { } fAuxiliaryState.savePluginInfo(dir); saveState(state, dir); - } else if (DEBUG) { + } else if (PDECore.DEBUG_CACHE) { System.out.println("External state unchanged, save skipped."); //$NON-NLS-1$ } } @@ -409,7 +409,7 @@ public class PDEState extends MinimalState { if (!"true".equals(System.getProperty("pde.nocache")) && shouldSaveState(models)) { //$NON-NLS-1$ //$NON-NLS-2$ timestamp = computeTimestamp(models); File dir = new File(DIR, Long.toString(timestamp) + ".workspace"); //$NON-NLS-1$ - if (DEBUG) { + if (PDECore.DEBUG_CACHE) { System.out.println("Saving workspace state to: " + dir.getAbsolutePath()); //$NON-NLS-1$ } State state = stateObjectFactory.createState(false); diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PluginModelManager.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PluginModelManager.java index d8eba2f394..fc751afc9e 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PluginModelManager.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/PluginModelManager.java @@ -504,6 +504,8 @@ public class PluginModelManager implements IModelProviderListener { if (fEntries != null) return; + long startTime = System.currentTimeMillis(); + // Cannot assign to fEntries here - will create a race condition with isInitialized() Map<String, LocalModelEntry> entries = Collections.synchronizedMap(new TreeMap<String, LocalModelEntry>()); @@ -575,6 +577,11 @@ public class PluginModelManager implements IModelProviderListener { } } } + + if (PDECore.DEBUG_MODEL) { + long time = System.currentTimeMillis() - startTime; + System.out.println("PDE plug-in model initialization complete: " + time + " ms"); //$NON-NLS-1$//$NON-NLS-2$ + } } /** diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/RequiredPluginsClasspathContainer.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/RequiredPluginsClasspathContainer.java index a9020207bb..e5fb5f3afe 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/RequiredPluginsClasspathContainer.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/RequiredPluginsClasspathContainer.java @@ -29,8 +29,6 @@ public class RequiredPluginsClasspathContainer extends PDEClasspathContainer imp private IPluginModelBase fModel; private IBuild fBuild; - private static boolean DEBUG = false; - private IClasspathEntry[] fEntries = null; /** @@ -39,10 +37,6 @@ public class RequiredPluginsClasspathContainer extends PDEClasspathContainer imp */ private static List<IClasspathContributor> fClasspathContributors = null; - static { - DEBUG = PDECore.getDefault().isDebugging() && "true".equals(Platform.getDebugOption("org.eclipse.pde.core/classpath")); //$NON-NLS-1$ //$NON-NLS-2$ - } - /** * Constructor for RequiredPluginsClasspathContainer. */ @@ -85,7 +79,7 @@ public class RequiredPluginsClasspathContainer extends PDEClasspathContainer imp */ public IClasspathEntry[] getClasspathEntries() { if (fModel == null) { - if (DEBUG) { + if (PDECore.DEBUG_CLASSPATH) { System.out.println("********Returned an empty container"); //$NON-NLS-1$ System.out.println(); } @@ -94,7 +88,7 @@ public class RequiredPluginsClasspathContainer extends PDEClasspathContainer imp if (fEntries == null) { fEntries = computePluginEntries(); } - if (DEBUG) { + if (PDECore.DEBUG_CLASSPATH) { System.out.println("Dependencies for plugin '" + fModel.getPluginBase().getId() + "':"); //$NON-NLS-1$ //$NON-NLS-2$ for (int i = 0; i < fEntries.length; i++) { System.out.println(fEntries[i]); diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/ManifestConsistencyChecker.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/ManifestConsistencyChecker.java index 859900bd9d..bbfd0431ef 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/ManifestConsistencyChecker.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/ManifestConsistencyChecker.java @@ -28,13 +28,8 @@ public class ManifestConsistencyChecker extends IncrementalProjectBuilder { private int BUILD = 0x4; private int STRUCTURE = 0x8; - private static boolean DEBUG = false; private static IProject[] EMPTY_LIST = new IProject[0]; - static { - DEBUG = PDECore.getDefault().isDebugging() && "true".equals(Platform.getDebugOption("org.eclipse.pde.core/validation")); //$NON-NLS-1$ //$NON-NLS-2$ - } - private SelfVisitor fSelfVisitor = new SelfVisitor(); private ClassChangeVisitor fClassFileVisitor = new ClassChangeVisitor(); @@ -83,7 +78,7 @@ public class ManifestConsistencyChecker extends IncrementalProjectBuilder { int kind = delta.getKind(); if (kind == IResourceDelta.ADDED || kind == IResourceDelta.REMOVED) { type = MANIFEST | EXTENSIONS | BUILD | STRUCTURE; - if (DEBUG) { + if (PDECore.DEBUG_VALIDATION) { System.out.print("Needs to rebuild project [" + getProject().getName() + "]: "); //$NON-NLS-1$ //$NON-NLS-2$ System.out.print(delta.getResource().getProjectRelativePath().toString()); System.out.print(" - "); //$NON-NLS-1$ @@ -101,28 +96,28 @@ public class ManifestConsistencyChecker extends IncrementalProjectBuilder { String name = resource.getName(); if (isLocalizationFile(resource)) { type |= MANIFEST | EXTENSIONS; - if (DEBUG) { + if (PDECore.DEBUG_VALIDATION) { System.out.print("Needs to rebuild manifest and extensions in project [" + getProject().getName() + "]: "); //$NON-NLS-1$ //$NON-NLS-2$ System.out.print(delta.getResource().getProjectRelativePath().toString()); System.out.println(" - changed"); //$NON-NLS-1$ } } else if (file.equals(PDEProject.getManifest(project))) { type |= MANIFEST | EXTENSIONS | BUILD; - if (DEBUG) { + if (PDECore.DEBUG_VALIDATION) { System.out.print("Needs to rebuild project [" + getProject().getName() + "]: "); //$NON-NLS-1$ //$NON-NLS-2$ System.out.print(delta.getResource().getProjectRelativePath().toString()); System.out.println(" - changed"); //$NON-NLS-1$ } } else if (name.endsWith(".exsd") || file.equals(PDEProject.getPluginXml(project)) || file.equals(PDEProject.getFragmentXml(project))) { //$NON-NLS-1$ type |= EXTENSIONS; - if (DEBUG) { + if (PDECore.DEBUG_VALIDATION) { System.out.print("Needs to rebuild extensions in project [" + getProject().getName() + "]: "); //$NON-NLS-1$ //$NON-NLS-2$ System.out.print(delta.getResource().getProjectRelativePath().toString()); System.out.println(" - changed"); //$NON-NLS-1$ } } else if (file.equals(PDEProject.getBuildProperties(project))) { type |= BUILD; - if (DEBUG) { + if (PDECore.DEBUG_VALIDATION) { System.out.print("Needs to rebuild build.properties in project [" + getProject().getName() + "]: "); //$NON-NLS-1$ //$NON-NLS-2$ System.out.print(delta.getResource().getProjectRelativePath().toString()); System.out.println(" - changed"); //$NON-NLS-1$ @@ -165,7 +160,7 @@ public class ManifestConsistencyChecker extends IncrementalProjectBuilder { // always do a build of the project if a full build or an unspecified change has occurred if (delta == null) { - if (DEBUG) { + if (PDECore.DEBUG_VALIDATION) { System.out.println("Project [" + getProject().getName() + "] - full build"); //$NON-NLS-1$ //$NON-NLS-2$ } return MANIFEST | EXTENSIONS | BUILD | STRUCTURE; @@ -176,7 +171,7 @@ public class ManifestConsistencyChecker extends IncrementalProjectBuilder { // has changed and a StateDelta was fired if (Boolean.TRUE.equals(project.getSessionProperty(PDECore.TOUCH_PROJECT))) { project.setSessionProperty(PDECore.TOUCH_PROJECT, null); - if (DEBUG) { + if (PDECore.DEBUG_VALIDATION) { System.out.println("Dependencies Changed: Project [" + getProject().getName() + "] - full build"); //$NON-NLS-1$ //$NON-NLS-2$ } return MANIFEST | EXTENSIONS | BUILD; @@ -200,7 +195,7 @@ public class ManifestConsistencyChecker extends IncrementalProjectBuilder { delta.accept(fClassFileVisitor); if (fClassFileVisitor.hasChanged()) { type |= MANIFEST | EXTENSIONS | BUILD; - if (DEBUG) { + if (PDECore.DEBUG_VALIDATION) { System.out.println("Class files changed due to dependency changes: Project [" + getProject().getName() + "] - rebuild manifest and properties files"); //$NON-NLS-1$ //$NON-NLS-2$ } } diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/IUBundleContainer.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/IUBundleContainer.java index b9d4ba75f6..259fe1d86c 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/IUBundleContainer.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/target/IUBundleContainer.java @@ -115,12 +115,6 @@ public class IUBundleContainer extends AbstractBundleContainer { */ private ITargetDefinition fTarget; - private static final boolean DEBUG_PROFILE; - - static { - DEBUG_PROFILE = PDECore.getDefault().isDebugging() && "true".equals(Platform.getDebugOption("org.eclipse.pde.core/target/profile")); //$NON-NLS-1$ //$NON-NLS-2$ - } - /** * Constructs a installable unit bundle container for the specified units. * @@ -299,7 +293,7 @@ public class IUBundleContainer extends AbstractBundleContainer { try { artifacts = P2TargetUtils.getBundlePool(); } catch (CoreException e) { - if (DEBUG_PROFILE) { + if (PDECore.DEBUG_TARGET_PROFILE) { System.out.println("Bundle pool repository could not be loaded"); //$NON-NLS-1$ } return fBundles = null; @@ -307,7 +301,7 @@ public class IUBundleContainer extends AbstractBundleContainer { Map<BundleInfo, TargetBundle> bundles = generateResolvedBundles(slice, metadata, artifacts); if (bundles.isEmpty()) { - if (DEBUG_PROFILE) { + if (PDECore.DEBUG_TARGET_PROFILE) { System.out.println("Profile does not contain any bundles or artifacts were missing"); //$NON-NLS-1$ } if (slicer.getStatus().getSeverity() == IStatus.WARNING) { diff --git a/ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF index 2bf8e5e1c2..84a716e217 100644 --- a/ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF +++ b/ui/org.eclipse.pde.ui/META-INF/MANIFEST.MF @@ -116,7 +116,8 @@ Require-Bundle: org.eclipse.team.ui;bundle-version="[3.6.100,4.0.0)", org.eclipse.help;bundle-version="[3.4.0,4.0.0)", org.eclipse.core.resources;bundle-version="[3.5.0,4.0.0)", - org.eclipse.debug.core;bundle-version="[3.6.0,4.0.0)" + org.eclipse.debug.core;bundle-version="[3.6.0,4.0.0)", + org.eclipse.ui.trace;bundle-version="[1.0.0,2.0.0)" Eclipse-LazyStart: true Import-Package: com.ibm.icu.text, org.eclipse.jdt.debug.core diff --git a/ui/org.eclipse.pde.ui/plugin.properties b/ui/org.eclipse.pde.ui/plugin.properties index 70dbc787be..725b181f54 100644 --- a/ui/org.eclipse.pde.ui/plugin.properties +++ b/ui/org.eclipse.pde.ui/plugin.properties @@ -288,4 +288,5 @@ targetLocationProvider.IU.description=Download plug-ins from a software site suc view.imagebrowser.name = Plug-in Image Browser command.saveImageToWorkspace.description = Save the selected image into a project in the workspace command.saveImageToWorkspace.name = Save Image -command.saveImageToWorkspace.label = Save Image
\ No newline at end of file +command.saveImageToWorkspace.label = Save Image +traceComponent.label = PDE
\ No newline at end of file diff --git a/ui/org.eclipse.pde.ui/plugin.xml b/ui/org.eclipse.pde.ui/plugin.xml index 9135d79983..67fe6829e1 100644 --- a/ui/org.eclipse.pde.ui/plugin.xml +++ b/ui/org.eclipse.pde.ui/plugin.xml @@ -2232,4 +2232,15 @@ type="org.eclipse.pde.internal.ui.views.imagebrowser.ImageElement"> </propertyTester> </extension> + <extension + point="org.eclipse.ui.trace.traceComponents"> + <component + id="org.eclipse.pde.traceComponent" + label="%traceComponent.label"> + <bundle + consumed="true" + name="org.eclipse.pde.core"> + </bundle> + </component> + </extension> </plugin> |