Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 199316 Details for
Bug 351526
[patch] Ant task for provisioning a target definition
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch which moves TargetExportJob into pde.core
Moved+Target+export+job+into+PDE+core.patch (text/plain), 34.98 KB, created by
Gunnar Wagenknecht
on 2011-07-08 04:50:42 EDT
(
hide
)
Description:
patch which moves TargetExportJob into pde.core
Filename:
MIME Type:
Creator:
Gunnar Wagenknecht
Created:
2011-07-08 04:50:42 EDT
Size:
34.98 KB
patch
obsolete
>diff --git META-INF/MANIFEST.MF META-INF/MANIFEST.MF >index b4cb703..aff2bf0 100644 >--- META-INF/MANIFEST.MF >+++ META-INF/MANIFEST.MF >@@ -26,6 +26,8 @@ > org.eclipse.pde.internal.core.feature;x-friends:="org.eclipse.pde.ui", > org.eclipse.pde.internal.core.ibundle;x-friends:="org.eclipse.pde.ui,org.eclipse.pde.api.tools.ui", > org.eclipse.pde.internal.core.ifeature;x-friends:="org.eclipse.pde.ui,org.eclipse.pde.launching", >+ org.eclipse.pde.internal.core.importing;x-friends:="org.eclipse.pde.ui", >+ org.eclipse.pde.internal.core.importing.provisional;x-friends:="org.eclipse.pde.ui", > org.eclipse.pde.internal.core.iproduct;x-friends:="org.eclipse.pde.ui", > org.eclipse.pde.internal.core.ischema;x-friends:="org.eclipse.pde.ui", > org.eclipse.pde.internal.core.isite;x-friends:="org.eclipse.pde.ui", >@@ -76,7 +78,9 @@ > org.eclipse.equinox.p2.repository;bundle-version="[2.0.0,3.0.0]", > org.eclipse.equinox.p2.metadata.repository;bundle-version="[1.0.100,2.0.0)", > org.eclipse.equinox.p2.garbagecollector;bundle-version="[1.0.100,2.0.0)", >- org.eclipse.equinox.p2.touchpoint.eclipse;bundle-version="[2.0.0,3.0.0)" >+ org.eclipse.equinox.p2.touchpoint.eclipse;bundle-version="[2.0.0,3.0.0)", >+ org.eclipse.core.filesystem;bundle-version="[1.0.0,2.0.0)", >+ org.eclipse.equinox.p2.repository.tools;bundle-version="[2.0.100,3.0.0)" > Eclipse-LazyStart: true > Bundle-RequiredExecutionEnvironment: J2SE-1.4 > Import-Package: com.ibm.icu.util >diff --git src/org/eclipse/pde/internal/core/PDECoreMessages.java src/org/eclipse/pde/internal/core/PDECoreMessages.java >index 2f649e5..acee29b 100644 >--- src/org/eclipse/pde/internal/core/PDECoreMessages.java >+++ src/org/eclipse/pde/internal/core/PDECoreMessages.java >@@ -99,7 +99,7 @@ > NLS.initializeMessages(BUNDLE_NAME, PDECoreMessages.class); > } > >- // Builders and natures >+ // Builders and natures > public static String Builders_updating; > public static String Builders_verifying; > >@@ -334,4 +334,13 @@ > > public static String VMHelper_noJreForExecEnv; > >+ // Target Export ######################################## >+ public static String ExportTargetDefinition_task; >+ public static String ExportTargetDeleteOldData; >+ public static String ExportTargetExportFeatures; >+ public static String ExportTargetExportPlugins; >+ >+ public static String ExportTargetJob_ConfiguringDestination; >+ public static String ExportTargetJob_ExportingTargetContents; >+ > } >diff --git src/org/eclipse/pde/internal/core/pderesources.properties src/org/eclipse/pde/internal/core/pderesources.properties >index c131f26..400721d 100644 >--- src/org/eclipse/pde/internal/core/pderesources.properties >+++ src/org/eclipse/pde/internal/core/pderesources.properties >@@ -87,7 +87,7 @@ > Builders_Manifest_non_ext_element = The content for element ''{0}'' is not externalized. The content must begin with % > Builders_Manifest_deprecated_attribute = Attribute ''{0}'' is deprecated > Builders_Manifest_deprecated_element = Element ''{0}'' is deprecated >-Builders_Manifest_internal_rootElement = Access to extension point ''{0}'' is discouraged >+Builders_Manifest_internal_rootElement = Access to extension point ''{0}'' is discouraged > BuildErrorReporter_binIncludesMissing=An entry for {0} is required in bin.includes > BuildErrorReporter_buildEntryInvalidWhenNoProjectSettings=The ''{0}'' build entry should not be set when there are no project specific compiler settings > BuildErrorReporter_buildEntryMissingProjectSpecificSettings=The ''{0}'' build entry should be set when there are project specific compiler settings >@@ -227,7 +227,7 @@ > PluginModelManager_1=Updating plug-in dependencies > PluginParser_EclipseConverterMissingAttribute=Error parsing {0} manifest. Missing attribute "{1}" in element "{2}". > >-# {0} will be a product id, this string will be the name of a p2 repository >+# {0} will be a product id, this string will be the name of a p2 repository > ProductExportOperation_0={0} Repository > > PropertiesTextChangeListener_editNames_remove=Remove "{0}" property >@@ -252,16 +252,24 @@ > SourceEntryErrorReporter_9=Default encoding ({0}) should be specified for library "{1}" to match workspace settings. > > SourceEntryErrorReporter_DifferentTargetLibrary=Source folders ''{0}'' share the same output folder but are targeted to different libraries. >-SourceEntryErrorReporter_DupeOutputFolder=Multiple entries for output folder ''{0}'' in build entry ''{1}''. >+SourceEntryErrorReporter_DupeOutputFolder=Multiple entries for output folder ''{0}'' in build entry ''{1}''. > SourceEntryErrorReporter_DupeSourceFolder=Multiple entries for source folder ''{0}'' in build entry ''{1}''. >-SourceEntryErrorReporter_ExtraOutputFolder=Redundant entry for output folder ''{0}''. It does not correspond to any source folder in ''{1}'' entry. >+SourceEntryErrorReporter_ExtraOutputFolder=Redundant entry for output folder ''{0}''. It does not correspond to any source folder in ''{1}'' entry. > SourceEntryErrorReporter_InvalidOutputFolder=''{0}'' is not an output folder. > SourceEntryErrorReporter_InvalidSourceFolder=''{0}'' is not a source folder. > SourceEntryErrorReporter_MissingLibrary=The library ''{0}'' has not been specified on the bundle classpath. >-SourceEntryErrorReporter_MissingOutputEntry=Source folder ''{0}'' does not have the output folder in corresponding output entry ''{1}''. >+SourceEntryErrorReporter_MissingOutputEntry=Source folder ''{0}'' does not have the output folder in corresponding output entry ''{1}''. > SourceEntryErrorReporter_MissingOutputLibForClassFolder=The class folder ''{0}'' is not associated to any output library entry. > > SourceLocationManager_problemProcessingBundleManifestSourceHeader=Problem processing bundle manifest source header in plug-in {0} version {1} found at {2} > UpdateSiteBuilder_0=Cleaning {0} >+ >+VMHelper_noJreForExecEnv=No installed JREs satisfy this Execution Environment: "{0}". Launch aborted. > >-VMHelper_noJreForExecEnv=No installed JREs satisfy this Execution Environment: "{0}". Launch aborted. >\ No newline at end of file >+######### Target Export Wizard ###################################33 >+ExportTargetDefinition_task = Exporting current target definition... >+ExportTargetDeleteOldData = Deleting old data... >+ExportTargetExportFeatures = Exporting features... >+ExportTargetExportPlugins = Exporting plugins... >+ExportTargetJob_ConfiguringDestination=Configuring destination >+ExportTargetJob_ExportingTargetContents=Exporting target contents >diff --git src/org/eclipse/pde/internal/core/target/ExportTargetJob.java src/org/eclipse/pde/internal/core/target/ExportTargetJob.java >new file mode 0 >index 0000000..86fa521 0 >--- /dev/null >+++ src/org/eclipse/pde/internal/core/target/ExportTargetJob.java >@@ -0,0 +1,233 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 EclipseSource Inc. 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * EclipseSource Inc. - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.core.target; >+ >+import java.net.URI; >+import java.util.*; >+import org.eclipse.core.filesystem.*; >+import org.eclipse.core.runtime.*; >+import org.eclipse.core.runtime.jobs.Job; >+import org.eclipse.equinox.p2.internal.repository.tools.Repo2Runnable; >+import org.eclipse.equinox.p2.internal.repository.tools.RepositoryDescriptor; >+import org.eclipse.equinox.p2.metadata.IInstallableUnit; >+import org.eclipse.equinox.p2.metadata.IProvidedCapability; >+import org.eclipse.equinox.p2.query.IQueryResult; >+import org.eclipse.pde.internal.core.PDECore; >+import org.eclipse.pde.internal.core.PDECoreMessages; >+import org.eclipse.pde.internal.core.feature.ExternalFeatureModel; >+import org.eclipse.pde.internal.core.ifeature.IFeatureModel; >+import org.eclipse.pde.internal.core.target.provisional.*; >+ >+/** >+ * This job exports the bundles and features that make up your target. >+ */ >+public class ExportTargetJob extends Job { >+ >+ private URI fDestination; >+ private boolean fclearDestinationDirectory = true; >+ private IFileStore featureDir; >+ private IFileStore pluginDir; >+ private IFileSystem fileSystem; >+ private Map filter; >+ private ITargetDefinition fTarget; >+ >+ public ExportTargetJob(ITargetDefinition target, URI destination, boolean clearDestinationDirectory) { >+ super("Export Current Target Definition Job"); //$NON-NLS-1$ >+ fTarget = target; >+ fDestination = destination; >+ fclearDestinationDirectory = clearDestinationDirectory; >+ } >+ >+ protected IStatus run(IProgressMonitor monitor) { >+ try { >+ constructFilter(fTarget); >+ IBundleContainer[] containers = fTarget.getBundleContainers(); >+ int totalWork = containers.length; >+ monitor.beginTask(PDECoreMessages.ExportTargetDefinition_task, totalWork); >+ >+ monitor.subTask(PDECoreMessages.ExportTargetJob_ConfiguringDestination); >+ setupDestination(monitor); >+ >+ monitor.subTask(PDECoreMessages.ExportTargetJob_ExportingTargetContents); >+ for (int i = 0; i < containers.length; i++) { >+ IBundleContainer container = containers[i]; >+ container.resolve(fTarget, monitor); >+ if (!(container instanceof IUBundleContainer)) >+ exportContainer(container, fTarget, featureDir, pluginDir, fileSystem, monitor); >+ } >+ exportProfile(fTarget, fDestination, monitor); >+ } catch (CoreException e) { >+ return new Status(IStatus.ERROR, PDECore.PLUGIN_ID, "Failed to export the target", e); //$NON-NLS-1$ >+ } finally { >+ monitor.done(); >+ } >+ return Status.OK_STATUS; >+ } >+ >+ private void constructFilter(ITargetDefinition target) { >+ NameVersionDescriptor[] included = target.getIncluded(); >+ if (included == null) >+ return; >+ filter = new HashMap(); >+ for (int i = 0; i < included.length; i++) { >+ NameVersionDescriptor inclusion = included[i]; >+ NameVersionDescriptor[] versions = (NameVersionDescriptor[]) filter.get(inclusion.getId()); >+ if (versions == null) >+ filter.put(inclusion.getId(), new NameVersionDescriptor[] {inclusion}); >+ else { >+ NameVersionDescriptor[] versions2 = new NameVersionDescriptor[versions.length + 1]; >+ System.arraycopy(versions, 0, versions2, 0, versions.length); >+ versions2[versions.length] = inclusion; >+ filter.put(inclusion.getId(), versions2); >+ } >+ } >+ } >+ >+ private void setupDestination(IProgressMonitor monitor) throws CoreException { >+ fileSystem = EFS.getLocalFileSystem(); >+ if (!fileSystem.canWrite()) { >+ throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, "Destination directory not writable.")); //$NON-NLS-1$ >+ } >+ IFileStore destination = fileSystem.getStore(fDestination); >+ featureDir = destination.getChild("features"); //$NON-NLS-1$ >+ pluginDir = destination.getChild("plugins"); //$NON-NLS-1$ >+ if (fclearDestinationDirectory) { >+ monitor.subTask(PDECoreMessages.ExportTargetDeleteOldData); //Deleting old data... >+ featureDir.delete(EFS.NONE, null); >+ pluginDir.delete(EFS.NONE, null); >+ } >+ featureDir.mkdir(EFS.NONE, null); >+ pluginDir.mkdir(EFS.NONE, null); >+ } >+ >+ private boolean shouldExport(NameVersionDescriptor descriptor) { >+ // currently PDE does not selectively include/exclude features >+ if (filter == null || descriptor.getType().equals(NameVersionDescriptor.TYPE_FEATURE)) >+ return true; >+ NameVersionDescriptor[] versions = (NameVersionDescriptor[]) filter.get(descriptor.getId()); >+ if (versions == null) >+ return false; >+ for (int i = 0; i < versions.length; i++) { >+ String version = versions[i].getVersion(); >+ if ((version == null || version.equals(descriptor.getVersion())) && descriptor.getType().equals(versions[i].getType())) >+ return true; >+ } >+ return false; >+ } >+ >+ private boolean shouldExport(IFeatureModel feature) { >+ if (filter == null) >+ return true; >+ if (!feature.isEnabled() || !(feature instanceof ExternalFeatureModel)) >+ return false; >+ NameVersionDescriptor descriptor = new NameVersionDescriptor(feature.getFeature().getId(), feature.getFeature().getVersion(), NameVersionDescriptor.TYPE_FEATURE); >+ return shouldExport(descriptor); >+ } >+ >+ private boolean shouldExport(IResolvedBundle bundle) { >+ if (filter == null) >+ return true; >+ NameVersionDescriptor descriptor = new NameVersionDescriptor(bundle.getBundleInfo().getSymbolicName(), bundle.getBundleInfo().getVersion(), NameVersionDescriptor.TYPE_PLUGIN); >+ return shouldExport(descriptor); >+ } >+ >+ private boolean shouldExport(IInstallableUnit iu) { >+ if (filter == null) >+ return true; >+ NameVersionDescriptor descriptor = null; >+ String feature = getCapability(iu, "org.eclipse.update.feature"); //$NON-NLS-1$ >+ if (feature != null) { >+ descriptor = new NameVersionDescriptor(feature, iu.getVersion().toString(), NameVersionDescriptor.TYPE_FEATURE); >+ } else if (iu.getId().endsWith(".feature.group")) { //$NON-NLS-1$ >+ descriptor = new NameVersionDescriptor(iu.getId(), iu.getVersion().toString(), NameVersionDescriptor.TYPE_FEATURE); >+ } else if ("bundle".equalsIgnoreCase(getCapability(iu, "org.eclipse.equinox.p2.eclipse.type"))) { //$NON-NLS-1$ //$NON-NLS-2$ >+ descriptor = new NameVersionDescriptor(iu.getId(), iu.getVersion().toString(), NameVersionDescriptor.TYPE_PLUGIN); >+ } else if ("source".equalsIgnoreCase(getCapability(iu, "org.eclipse.equinox.p2.eclipse.type"))) { //$NON-NLS-1$ //$NON-NLS-2$ >+ descriptor = new NameVersionDescriptor(iu.getId(), iu.getVersion().toString(), NameVersionDescriptor.TYPE_PLUGIN); >+ } >+ // default to true unless we know otherwise. This ensures that random metadata bits >+ // are moved over to the target as they might be needed in a future provisioning operation. >+ // We could move only unknown IUs that do NOT have artifacts... Have to think about that. >+ return descriptor == null ? true : shouldExport(descriptor); >+ } >+ >+ private String getCapability(IInstallableUnit iu, String namespace) { >+ for (Iterator i = iu.getProvidedCapabilities().iterator(); i.hasNext();) { >+ IProvidedCapability capability = (IProvidedCapability) i.next(); >+ if (capability.getNamespace().equals(namespace)) >+ return capability.getName(); >+ } >+ return null; >+ } >+ >+ private void exportContainer(IBundleContainer container, ITargetDefinition target, IFileStore featureDir, IFileStore pluginDir, IFileSystem fileSystem, IProgressMonitor monitor) throws CoreException { >+ IFeatureModel[] features = container.getFeatures(); >+ if (features != null) { >+ monitor.subTask(PDECoreMessages.ExportTargetExportFeatures); >+ for (int i = 0; i < features.length; i++) { >+ if (shouldExport(features[i])) >+ copy(features[i].getInstallLocation(), featureDir, fileSystem, monitor); >+ } >+ } >+ >+ IResolvedBundle[] bundles = container.getBundles(); >+ if (bundles != null) { >+ monitor.subTask(PDECoreMessages.ExportTargetExportPlugins); >+ for (int i = 0; i < bundles.length; i++) { >+ if (shouldExport(bundles[i])) >+ copy(bundles[i].getBundleInfo().getLocation().getPath(), pluginDir, fileSystem, monitor); >+ } >+ } >+ } >+ >+ private IStatus copy(String src, IFileStore destinationParent, IFileSystem fileSystem, IProgressMonitor monitor) throws CoreException { >+ Path srcPath = new Path(src); >+ IFileStore source = fileSystem.getStore(srcPath); >+ String elementName = srcPath.segment(srcPath.segmentCount() - 1); >+ IFileStore destination = destinationParent.getChild(elementName); >+ if (destination.fetchInfo().exists()) { >+ monitor.worked(1); >+ return Status.OK_STATUS; >+ } >+ if (source.fetchInfo().isDirectory()) { >+ destination.mkdir(EFS.NONE, new NullProgressMonitor()); >+ } >+ source.copy(destination, EFS.OVERWRITE, new SubProgressMonitor(monitor, 1)); >+ return Status.OK_STATUS; >+ } >+ >+ private RepositoryDescriptor createRepoDescriptor(URI location, String name, String kind) { >+ RepositoryDescriptor result = new RepositoryDescriptor(); >+ result.setLocation(location); >+ result.setKind(kind); >+ result.setName(name); >+ if (fclearDestinationDirectory) >+ result.setAppend(false); >+ return result; >+ } >+ >+ private void exportProfile(ITargetDefinition target, URI destination, IProgressMonitor monitor) throws CoreException { >+ Repo2Runnable exporter = new Repo2Runnable(); >+ exporter.addDestination(createRepoDescriptor(destination, P2TargetUtils.getProfileId(target), RepositoryDescriptor.KIND_METADATA)); >+ exporter.addDestination(createRepoDescriptor(destination, P2TargetUtils.getProfileId(target), RepositoryDescriptor.KIND_ARTIFACT)); >+ exporter.addSource(createRepoDescriptor(P2TargetUtils.getBundlePool().getLocation(), null, RepositoryDescriptor.KIND_ARTIFACT)); >+ >+ IQueryResult ius = P2TargetUtils.getIUs(target, monitor); >+ ArrayList toExport = new ArrayList(); >+ for (Iterator i = ius.iterator(); i.hasNext();) { >+ IInstallableUnit iu = (IInstallableUnit) i.next(); >+ if (shouldExport(iu)) >+ toExport.add(iu); >+ } >+ exporter.setSourceIUs(toExport); >+ exporter.run(monitor); >+ } >+} >diff --git src/org/eclipse/pde/internal/ui/PDEUIMessages.java src/org/eclipse/pde/internal/ui/PDEUIMessages.java >index 46b0f19..f1355ea 100644 >--- src/org/eclipse/pde/internal/ui/PDEUIMessages.java >+++ src/org/eclipse/pde/internal/ui/PDEUIMessages.java >@@ -1737,24 +1737,16 @@ > public static String CategorySection_newCategoryLabel; > > // Target Export ######################################## >- public static String ExportTargetDefinition_task; >- public static String ExportTargetDeleteOldData; >- public static String ExportTargetExportFeatures; >- public static String ExportTargetExportPlugins; > public static String ExportActiveTargetDefinition; > public static String ExportActiveTargetDefinition_message; >+ public static String ExportTargetError_ChooseDestination; >+ public static String ExportTargetError_validPath; > public static String ExportTargetCurrentTarget; > public static String ExportTargetChooseFolder; > public static String ExportTargetBrowse; > public static String ExportTargetSelectDestination; > public static String ExportTargetSpecifyDestination; > public static String ExportTargetClearDestination; >- public static String ExportTargetError_ChooseDestination; >- public static String ExportTargetError_validPath; >- >- public static String ExportTargetJob_ConfiguringDestination; >- >- public static String ExportTargetJob_ExportingTargetContents; > > public static String CategoryDetails_title; > public static String CategoryDetails_sectionDescription; >diff --git src/org/eclipse/pde/internal/ui/pderesources.properties src/org/eclipse/pde/internal/ui/pderesources.properties >index 601cfb7..08b25da 100644 >--- src/org/eclipse/pde/internal/ui/pderesources.properties >+++ src/org/eclipse/pde/internal/ui/pderesources.properties >@@ -664,7 +664,7 @@ > ExternalizeStringsWizardPage_subKey=Substitution Key > ExternalizeStringsResolution_label=Open Externalize Strings Wizard... > ExternalizeStringsWizardPage_keyDuplicateError=New key may not be a duplicate of another key >-ExternalizeStringsWizardPage_keySuggested=\n\tsuggested key value: >+ExternalizeStringsWizardPage_keySuggested=\n\tsuggested key value: > > Preferences_TargetEnvironmentPage_os = &Operating System: > Preferences_TargetEnvironmentPage_ws = &Windowing System: >@@ -1011,7 +1011,7 @@ > > NewSchemaFileMainPage_missingPluginID = Specify a valid plug-in ID. No Plug-in ID specified. > NewSchemaFileMainPage_nonExistingPluginID = Specify a valid plug-in ID. Specified plug-in ID does not exist. >-NewSchemaFileMainPage_externalPluginID = Specify a valid plug-in ID. Specified plug-in ID is external to the workspace. >+NewSchemaFileMainPage_externalPluginID = Specify a valid plug-in ID. Specified plug-in ID is external to the workspace. > NewSchemaFileMainPage_missingContainer = Specify a valid container. No container specified. > NewSchemaFileMainPage_invalidContainer = Specify a valid container. Specified container is not a valid project or folder. > NewSchemaFileMainPage_nonExistingContainer = Specify a valid container. Specified container does not exist. >@@ -1241,7 +1241,7 @@ > EditorUtilities_noImageData=The specified file contains no image data > EditorPreferencePage_tag=Tags > EditorPreferencePage_xml=&XML Highlighting >-EditorUtilities_icoError=The specified ICO file is missing images: >+EditorUtilities_icoError=The specified ICO file is missing images: > EditorPreferencePage_comment=Comments > EditorPreferencePage_manifest=&Manifest Highlighting > EditorUtilities_incorrectSize=The specified image is not the correct size: {0}. >@@ -1487,7 +1487,7 @@ > compilers_p_not_externalized_att = Usage of non-externali&zed strings: > compilers_p_deprecated = Usage of deprecated attributes and &elements: > compilers_p_internal = Usage o&f internal extension points: >-compilers_p_exported_pkgs = Missing exported pac&kages: >+compilers_p_exported_pkgs = Missing exported pac&kages: > compilers_p_missing_exp_pkg = Missing versions on exported packages: > compilers_p_missing_imp_pkg = Missing versions on imported packages: > compilers_p_missing_require_bundle = Missing versions on required bundles: >@@ -1593,13 +1593,9 @@ > CategorySection_newCategoryLabel = New Category {0} > > ######### Target Export Wizard ###################################33 >-ExportTargetDefinition_task = Exporting current target definition... >-ExportTargetDeleteOldData = Deleting old data... >-ExportTargetExportFeatures = Exporting features... >-ExportTargetExportPlugins = Exporting plugins... > ExportActiveTargetDefinition = Exporting Target Definition > ExportActiveTargetDefinition_message = Please choose a destination directory to export all target content >-ExportTargetCurrentTarget = Active &Target: >+ExportTargetCurrentTarget = Active &Target: > ExportTargetChooseFolder = &Destination: > ExportTargetBrowse = &Browse... > ExportTargetSelectDestination = Select Destination >@@ -1607,8 +1603,6 @@ > ExportTargetClearDestination = &Clear destination directory before exporting > ExportTargetError_ChooseDestination = Please choose a destination directory > ExportTargetError_validPath = Destination directory must be a valid path >-ExportTargetJob_ConfiguringDestination=Configuring destination >-ExportTargetJob_ExportingTargetContents=Exporting target contents > > > CategoryDetails_title = Category Properties >@@ -2074,7 +2068,7 @@ > InternationalizeWizard_LocalePage_availableList = Available locales: > InternationalizeWizard_LocalePage_filter = Filter available locales: > InternationalizeWizard_LocalePage_selectionError=At least one locale must be selected. >-InternationalizeWizard_NLSFragmentGenerator_overwriteTitle = Confirm Overwrite >+InternationalizeWizard_NLSFragmentGenerator_overwriteTitle = Confirm Overwrite > InternationalizeWizard_NLSFragmentGenerator_overwriteMessage = A fragment project with the name "{0}" already exists. Overwrite? > InternationalizeWizard_NLSFragmentGenerator_errorMessage = An error occured while generating an NL Fragment. > >@@ -2137,7 +2131,7 @@ > OrganizeManifestsWizardPage_errorMsg=This function works only on plug-ins containing a MANIFEST.MF > OrganizeManifestsWizardPage_prefixNL=&Prefix icon paths in plug-in extensions with an $nl$ segment > OrganizeManifestsOperation_nlIconPath=checking icon paths for missing $nl$ segments... {0} >-OrganizeManifestsOperation_unusedKeys=checking for unused keys... {0} >+OrganizeManifestsOperation_unusedKeys=checking for unused keys... {0} > OrganizeManifestsWizardPage_addMissing=&Ensure that all packages appear in the MANIFEST.MF > OrganizeManifestsProcessor_rootMessage=Organize Manifest for {0} > OrganizeManifestsWizardPage_lazyStart=Remove unnecessary lazy activation headers >@@ -2319,7 +2313,7 @@ > RemoveSplashHandlerBindingAction_msgProgressRemoveProductBindings=Removing product bindings from extension ''{0}'' ... > StateViewPage_requiredBundles=Required Plug-ins > StateViewPage_importedPackages=Imported Packages >-StateViewPage_suppliedBy=\ - supplied by: >+StateViewPage_suppliedBy=\ - supplied by: > StateViewPage_suppliedByJRE=\ - supplied by the JRE > StateViewPage_showLeaves=Show leaf plug-ins > StateViewPage_openItem=Open >diff --git src/org/eclipse/pde/internal/ui/wizards/exports/ExportTargetJob.java src/org/eclipse/pde/internal/ui/wizards/exports/ExportTargetJob.java >deleted file mode 100644 >index 95677a2..0000000 100644 >--- src/org/eclipse/pde/internal/ui/wizards/exports/ExportTargetJob.java >+++ /dev/null >@@ -1,235 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2010 EclipseSource Inc. 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 >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * EclipseSource Inc. - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.pde.internal.ui.wizards.exports; >- >-import java.net.URI; >-import java.util.*; >-import org.eclipse.core.filesystem.*; >-import org.eclipse.core.runtime.*; >-import org.eclipse.core.runtime.jobs.Job; >-import org.eclipse.equinox.p2.internal.repository.tools.Repo2Runnable; >-import org.eclipse.equinox.p2.internal.repository.tools.RepositoryDescriptor; >-import org.eclipse.equinox.p2.metadata.IInstallableUnit; >-import org.eclipse.equinox.p2.metadata.IProvidedCapability; >-import org.eclipse.equinox.p2.query.IQueryResult; >-import org.eclipse.pde.internal.core.feature.ExternalFeatureModel; >-import org.eclipse.pde.internal.core.ifeature.IFeatureModel; >-import org.eclipse.pde.internal.core.target.IUBundleContainer; >-import org.eclipse.pde.internal.core.target.P2TargetUtils; >-import org.eclipse.pde.internal.core.target.provisional.*; >-import org.eclipse.pde.internal.ui.PDEPlugin; >-import org.eclipse.pde.internal.ui.PDEUIMessages; >- >-/** >- * This job exports the bundles and features that make up your target. >- */ >-public class ExportTargetJob extends Job { >- >- private URI fDestination; >- private boolean fclearDestinationDirectory = true; >- private IFileStore featureDir; >- private IFileStore pluginDir; >- private IFileSystem fileSystem; >- private Map filter; >- private ITargetDefinition fTarget; >- >- public ExportTargetJob(ITargetDefinition target, URI destination, boolean clearDestinationDirectory) { >- super("Export Current Target Definition Job"); //$NON-NLS-1$ >- fTarget = target; >- fDestination = destination; >- fclearDestinationDirectory = clearDestinationDirectory; >- } >- >- protected IStatus run(IProgressMonitor monitor) { >- try { >- constructFilter(fTarget); >- IBundleContainer[] containers = fTarget.getBundleContainers(); >- int totalWork = containers.length; >- monitor.beginTask(PDEUIMessages.ExportTargetDefinition_task, totalWork); >- >- monitor.subTask(PDEUIMessages.ExportTargetJob_ConfiguringDestination); >- setupDestination(monitor); >- >- monitor.subTask(PDEUIMessages.ExportTargetJob_ExportingTargetContents); >- for (int i = 0; i < containers.length; i++) { >- IBundleContainer container = containers[i]; >- container.resolve(fTarget, monitor); >- if (!(container instanceof IUBundleContainer)) >- exportContainer(container, fTarget, featureDir, pluginDir, fileSystem, monitor); >- } >- exportProfile(fTarget, fDestination, monitor); >- } catch (CoreException e) { >- return new Status(IStatus.ERROR, PDEPlugin.getPluginId(), "Failed to export the target", e); //$NON-NLS-1$ >- } finally { >- monitor.done(); >- } >- return Status.OK_STATUS; >- } >- >- private void constructFilter(ITargetDefinition target) { >- NameVersionDescriptor[] included = target.getIncluded(); >- if (included == null) >- return; >- filter = new HashMap(); >- for (int i = 0; i < included.length; i++) { >- NameVersionDescriptor inclusion = included[i]; >- NameVersionDescriptor[] versions = (NameVersionDescriptor[]) filter.get(inclusion.getId()); >- if (versions == null) >- filter.put(inclusion.getId(), new NameVersionDescriptor[] {inclusion}); >- else { >- NameVersionDescriptor[] versions2 = new NameVersionDescriptor[versions.length + 1]; >- System.arraycopy(versions, 0, versions2, 0, versions.length); >- versions2[versions.length] = inclusion; >- filter.put(inclusion.getId(), versions2); >- } >- } >- } >- >- private void setupDestination(IProgressMonitor monitor) throws CoreException { >- fileSystem = EFS.getLocalFileSystem(); >- if (!fileSystem.canWrite()) { >- throw new CoreException(new Status(IStatus.ERROR, PDEPlugin.getPluginId(), "Destination directory not writable.")); //$NON-NLS-1$ >- } >- IFileStore destination = fileSystem.getStore(fDestination); >- featureDir = destination.getChild("features"); //$NON-NLS-1$ >- pluginDir = destination.getChild("plugins"); //$NON-NLS-1$ >- if (fclearDestinationDirectory) { >- monitor.subTask(PDEUIMessages.ExportTargetDeleteOldData); //Deleting old data... >- featureDir.delete(EFS.NONE, null); >- pluginDir.delete(EFS.NONE, null); >- } >- featureDir.mkdir(EFS.NONE, null); >- pluginDir.mkdir(EFS.NONE, null); >- } >- >- private boolean shouldExport(NameVersionDescriptor descriptor) { >- // currently PDE does not selectively include/exclude features >- if (filter == null || descriptor.getType().equals(NameVersionDescriptor.TYPE_FEATURE)) >- return true; >- NameVersionDescriptor[] versions = (NameVersionDescriptor[]) filter.get(descriptor.getId()); >- if (versions == null) >- return false; >- for (int i = 0; i < versions.length; i++) { >- String version = versions[i].getVersion(); >- if ((version == null || version.equals(descriptor.getVersion())) && descriptor.getType().equals(versions[i].getType())) >- return true; >- } >- return false; >- } >- >- private boolean shouldExport(IFeatureModel feature) { >- if (filter == null) >- return true; >- if (!feature.isEnabled() || !(feature instanceof ExternalFeatureModel)) >- return false; >- NameVersionDescriptor descriptor = new NameVersionDescriptor(feature.getFeature().getId(), feature.getFeature().getVersion(), NameVersionDescriptor.TYPE_FEATURE); >- return shouldExport(descriptor); >- } >- >- private boolean shouldExport(IResolvedBundle bundle) { >- if (filter == null) >- return true; >- NameVersionDescriptor descriptor = new NameVersionDescriptor(bundle.getBundleInfo().getSymbolicName(), bundle.getBundleInfo().getVersion(), NameVersionDescriptor.TYPE_PLUGIN); >- return shouldExport(descriptor); >- } >- >- private boolean shouldExport(IInstallableUnit iu) { >- if (filter == null) >- return true; >- NameVersionDescriptor descriptor = null; >- String feature = getCapability(iu, "org.eclipse.update.feature"); //$NON-NLS-1$ >- if (feature != null) { >- descriptor = new NameVersionDescriptor(feature, iu.getVersion().toString(), NameVersionDescriptor.TYPE_FEATURE); >- } else if (iu.getId().endsWith(".feature.group")) { //$NON-NLS-1$ >- descriptor = new NameVersionDescriptor(iu.getId(), iu.getVersion().toString(), NameVersionDescriptor.TYPE_FEATURE); >- } else if ("bundle".equalsIgnoreCase(getCapability(iu, "org.eclipse.equinox.p2.eclipse.type"))) { //$NON-NLS-1$ //$NON-NLS-2$ >- descriptor = new NameVersionDescriptor(iu.getId(), iu.getVersion().toString(), NameVersionDescriptor.TYPE_PLUGIN); >- } else if ("source".equalsIgnoreCase(getCapability(iu, "org.eclipse.equinox.p2.eclipse.type"))) { //$NON-NLS-1$ //$NON-NLS-2$ >- descriptor = new NameVersionDescriptor(iu.getId(), iu.getVersion().toString(), NameVersionDescriptor.TYPE_PLUGIN); >- } >- // default to true unless we know otherwise. This ensures that random metadata bits >- // are moved over to the target as they might be needed in a future provisioning operation. >- // We could move only unknown IUs that do NOT have artifacts... Have to think about that. >- return descriptor == null ? true : shouldExport(descriptor); >- } >- >- private String getCapability(IInstallableUnit iu, String namespace) { >- for (Iterator i = iu.getProvidedCapabilities().iterator(); i.hasNext();) { >- IProvidedCapability capability = (IProvidedCapability) i.next(); >- if (capability.getNamespace().equals(namespace)) >- return capability.getName(); >- } >- return null; >- } >- >- private void exportContainer(IBundleContainer container, ITargetDefinition target, IFileStore featureDir, IFileStore pluginDir, IFileSystem fileSystem, IProgressMonitor monitor) throws CoreException { >- IFeatureModel[] features = container.getFeatures(); >- if (features != null) { >- monitor.subTask(PDEUIMessages.ExportTargetExportFeatures); >- for (int i = 0; i < features.length; i++) { >- if (shouldExport(features[i])) >- copy(features[i].getInstallLocation(), featureDir, fileSystem, monitor); >- } >- } >- >- IResolvedBundle[] bundles = container.getBundles(); >- if (bundles != null) { >- monitor.subTask(PDEUIMessages.ExportTargetExportPlugins); >- for (int i = 0; i < bundles.length; i++) { >- if (shouldExport(bundles[i])) >- copy(bundles[i].getBundleInfo().getLocation().getPath(), pluginDir, fileSystem, monitor); >- } >- } >- } >- >- private IStatus copy(String src, IFileStore destinationParent, IFileSystem fileSystem, IProgressMonitor monitor) throws CoreException { >- Path srcPath = new Path(src); >- IFileStore source = fileSystem.getStore(srcPath); >- String elementName = srcPath.segment(srcPath.segmentCount() - 1); >- IFileStore destination = destinationParent.getChild(elementName); >- if (destination.fetchInfo().exists()) { >- monitor.worked(1); >- return Status.OK_STATUS; >- } >- if (source.fetchInfo().isDirectory()) { >- destination.mkdir(EFS.NONE, new NullProgressMonitor()); >- } >- source.copy(destination, EFS.OVERWRITE, new SubProgressMonitor(monitor, 1)); >- return Status.OK_STATUS; >- } >- >- private RepositoryDescriptor createRepoDescriptor(URI location, String name, String kind) { >- RepositoryDescriptor result = new RepositoryDescriptor(); >- result.setLocation(location); >- result.setKind(kind); >- result.setName(name); >- if (fclearDestinationDirectory) >- result.setAppend(false); >- return result; >- } >- >- private void exportProfile(ITargetDefinition target, URI destination, IProgressMonitor monitor) throws CoreException { >- Repo2Runnable exporter = new Repo2Runnable(); >- exporter.addDestination(createRepoDescriptor(destination, P2TargetUtils.getProfileId(target), RepositoryDescriptor.KIND_METADATA)); >- exporter.addDestination(createRepoDescriptor(destination, P2TargetUtils.getProfileId(target), RepositoryDescriptor.KIND_ARTIFACT)); >- exporter.addSource(createRepoDescriptor(P2TargetUtils.getBundlePool().getLocation(), null, RepositoryDescriptor.KIND_ARTIFACT)); >- >- IQueryResult ius = P2TargetUtils.getIUs(target, monitor); >- ArrayList toExport = new ArrayList(); >- for (Iterator i = ius.iterator(); i.hasNext();) { >- IInstallableUnit iu = (IInstallableUnit) i.next(); >- if (shouldExport(iu)) >- toExport.add(iu); >- } >- exporter.setSourceIUs(toExport); >- exporter.run(monitor); >- } >-} >diff --git src/org/eclipse/pde/internal/ui/wizards/exports/TargetDefinitionExportWizard.java src/org/eclipse/pde/internal/ui/wizards/exports/TargetDefinitionExportWizard.java >index 3d6dd77..40179e4 100644 >--- src/org/eclipse/pde/internal/ui/wizards/exports/TargetDefinitionExportWizard.java >+++ src/org/eclipse/pde/internal/ui/wizards/exports/TargetDefinitionExportWizard.java >@@ -11,6 +11,8 @@ > *******************************************************************************/ > package org.eclipse.pde.internal.ui.wizards.exports; > >+import org.eclipse.pde.internal.core.target.ExportTargetJob; >+ > import java.io.File; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.jobs.Job;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 351526
: 199316 |
199317