View | Details | Raw Unified | Return to bug 351526 | Differences between
and this patch

Collapse All | Expand All

(-)META-INF/MANIFEST.MF (-1 / +5 lines)
Lines 26-31 Link Here
26
 org.eclipse.pde.internal.core.feature;x-friends:="org.eclipse.pde.ui",
26
 org.eclipse.pde.internal.core.feature;x-friends:="org.eclipse.pde.ui",
27
 org.eclipse.pde.internal.core.ibundle;x-friends:="org.eclipse.pde.ui,org.eclipse.pde.api.tools.ui",
27
 org.eclipse.pde.internal.core.ibundle;x-friends:="org.eclipse.pde.ui,org.eclipse.pde.api.tools.ui",
28
 org.eclipse.pde.internal.core.ifeature;x-friends:="org.eclipse.pde.ui,org.eclipse.pde.launching",
28
 org.eclipse.pde.internal.core.ifeature;x-friends:="org.eclipse.pde.ui,org.eclipse.pde.launching",
29
 org.eclipse.pde.internal.core.importing;x-friends:="org.eclipse.pde.ui",
30
 org.eclipse.pde.internal.core.importing.provisional;x-friends:="org.eclipse.pde.ui",
29
 org.eclipse.pde.internal.core.iproduct;x-friends:="org.eclipse.pde.ui",
31
 org.eclipse.pde.internal.core.iproduct;x-friends:="org.eclipse.pde.ui",
30
 org.eclipse.pde.internal.core.ischema;x-friends:="org.eclipse.pde.ui",
32
 org.eclipse.pde.internal.core.ischema;x-friends:="org.eclipse.pde.ui",
31
 org.eclipse.pde.internal.core.isite;x-friends:="org.eclipse.pde.ui",
33
 org.eclipse.pde.internal.core.isite;x-friends:="org.eclipse.pde.ui",
Lines 76-82 Link Here
76
 org.eclipse.equinox.p2.repository;bundle-version="[2.0.0,3.0.0]",
78
 org.eclipse.equinox.p2.repository;bundle-version="[2.0.0,3.0.0]",
77
 org.eclipse.equinox.p2.metadata.repository;bundle-version="[1.0.100,2.0.0)",
79
 org.eclipse.equinox.p2.metadata.repository;bundle-version="[1.0.100,2.0.0)",
78
 org.eclipse.equinox.p2.garbagecollector;bundle-version="[1.0.100,2.0.0)",
80
 org.eclipse.equinox.p2.garbagecollector;bundle-version="[1.0.100,2.0.0)",
79
 org.eclipse.equinox.p2.touchpoint.eclipse;bundle-version="[2.0.0,3.0.0)"
81
 org.eclipse.equinox.p2.touchpoint.eclipse;bundle-version="[2.0.0,3.0.0)",
82
 org.eclipse.core.filesystem;bundle-version="[1.0.0,2.0.0)",
83
 org.eclipse.equinox.p2.repository.tools;bundle-version="[2.0.100,3.0.0)"
80
Eclipse-LazyStart: true
84
Eclipse-LazyStart: true
81
Bundle-RequiredExecutionEnvironment: J2SE-1.4
85
Bundle-RequiredExecutionEnvironment: J2SE-1.4
82
Import-Package: com.ibm.icu.util
86
Import-Package: com.ibm.icu.util
(-)src/org/eclipse/pde/internal/core/PDECoreMessages.java (-1 / +10 lines)
Lines 99-105 Link Here
99
		NLS.initializeMessages(BUNDLE_NAME, PDECoreMessages.class);
99
		NLS.initializeMessages(BUNDLE_NAME, PDECoreMessages.class);
100
	}
100
	}
101
101
102
	// Builders and natures 
102
	// Builders and natures
103
	public static String Builders_updating;
103
	public static String Builders_updating;
104
	public static String Builders_verifying;
104
	public static String Builders_verifying;
105
105
Lines 334-337 Link Here
334
334
335
	public static String VMHelper_noJreForExecEnv;
335
	public static String VMHelper_noJreForExecEnv;
336
336
337
	// Target Export ########################################
338
	public static String ExportTargetDefinition_task;
339
	public static String ExportTargetDeleteOldData;
340
	public static String ExportTargetExportFeatures;
341
	public static String ExportTargetExportPlugins;
342
343
	public static String ExportTargetJob_ConfiguringDestination;
344
	public static String ExportTargetJob_ExportingTargetContents;
345
337
}
346
}
(-)src/org/eclipse/pde/internal/core/pderesources.properties (-6 / +14 lines)
Lines 87-93 Link Here
87
Builders_Manifest_non_ext_element = The content for element ''{0}'' is not externalized.  The content must begin with %
87
Builders_Manifest_non_ext_element = The content for element ''{0}'' is not externalized.  The content must begin with %
88
Builders_Manifest_deprecated_attribute = Attribute ''{0}'' is deprecated
88
Builders_Manifest_deprecated_attribute = Attribute ''{0}'' is deprecated
89
Builders_Manifest_deprecated_element = Element ''{0}'' is deprecated
89
Builders_Manifest_deprecated_element = Element ''{0}'' is deprecated
90
Builders_Manifest_internal_rootElement = Access to extension point ''{0}'' is discouraged 
90
Builders_Manifest_internal_rootElement = Access to extension point ''{0}'' is discouraged
91
BuildErrorReporter_binIncludesMissing=An entry for {0} is required in bin.includes
91
BuildErrorReporter_binIncludesMissing=An entry for {0} is required in bin.includes
92
BuildErrorReporter_buildEntryInvalidWhenNoProjectSettings=The ''{0}'' build entry should not be set when there are no project specific compiler settings
92
BuildErrorReporter_buildEntryInvalidWhenNoProjectSettings=The ''{0}'' build entry should not be set when there are no project specific compiler settings
93
BuildErrorReporter_buildEntryMissingProjectSpecificSettings=The ''{0}'' build entry should be set when there are project specific compiler settings
93
BuildErrorReporter_buildEntryMissingProjectSpecificSettings=The ''{0}'' build entry should be set when there are project specific compiler settings
Lines 227-233 Link Here
227
PluginModelManager_1=Updating plug-in dependencies
227
PluginModelManager_1=Updating plug-in dependencies
228
PluginParser_EclipseConverterMissingAttribute=Error parsing {0} manifest. Missing attribute "{1}" in element "{2}".
228
PluginParser_EclipseConverterMissingAttribute=Error parsing {0} manifest. Missing attribute "{1}" in element "{2}".
229
229
230
# {0} will be a product id, this string will be the name of a p2 repository 
230
# {0} will be a product id, this string will be the name of a p2 repository
231
ProductExportOperation_0={0} Repository
231
ProductExportOperation_0={0} Repository
232
232
233
PropertiesTextChangeListener_editNames_remove=Remove "{0}" property
233
PropertiesTextChangeListener_editNames_remove=Remove "{0}" property
Lines 252-267 Link Here
252
SourceEntryErrorReporter_9=Default encoding ({0}) should be specified for library "{1}" to match workspace settings.
252
SourceEntryErrorReporter_9=Default encoding ({0}) should be specified for library "{1}" to match workspace settings.
253
253
254
SourceEntryErrorReporter_DifferentTargetLibrary=Source folders ''{0}'' share the same output folder but are targeted to different libraries.
254
SourceEntryErrorReporter_DifferentTargetLibrary=Source folders ''{0}'' share the same output folder but are targeted to different libraries.
255
SourceEntryErrorReporter_DupeOutputFolder=Multiple entries for output folder ''{0}'' in build entry ''{1}''. 
255
SourceEntryErrorReporter_DupeOutputFolder=Multiple entries for output folder ''{0}'' in build entry ''{1}''.
256
SourceEntryErrorReporter_DupeSourceFolder=Multiple entries for source folder ''{0}'' in build entry ''{1}''.
256
SourceEntryErrorReporter_DupeSourceFolder=Multiple entries for source folder ''{0}'' in build entry ''{1}''.
257
SourceEntryErrorReporter_ExtraOutputFolder=Redundant entry for output folder ''{0}''. It does not correspond to any source folder in ''{1}'' entry. 
257
SourceEntryErrorReporter_ExtraOutputFolder=Redundant entry for output folder ''{0}''. It does not correspond to any source folder in ''{1}'' entry.
258
SourceEntryErrorReporter_InvalidOutputFolder=''{0}'' is not an output folder.
258
SourceEntryErrorReporter_InvalidOutputFolder=''{0}'' is not an output folder.
259
SourceEntryErrorReporter_InvalidSourceFolder=''{0}'' is not a source folder.
259
SourceEntryErrorReporter_InvalidSourceFolder=''{0}'' is not a source folder.
260
SourceEntryErrorReporter_MissingLibrary=The library ''{0}'' has not been specified on the bundle classpath.
260
SourceEntryErrorReporter_MissingLibrary=The library ''{0}'' has not been specified on the bundle classpath.
261
SourceEntryErrorReporter_MissingOutputEntry=Source folder ''{0}'' does not have the output folder in corresponding output entry ''{1}''.  
261
SourceEntryErrorReporter_MissingOutputEntry=Source folder ''{0}'' does not have the output folder in corresponding output entry ''{1}''.
262
SourceEntryErrorReporter_MissingOutputLibForClassFolder=The class folder ''{0}'' is not associated to any output library entry.
262
SourceEntryErrorReporter_MissingOutputLibForClassFolder=The class folder ''{0}'' is not associated to any output library entry.
263
263
264
SourceLocationManager_problemProcessingBundleManifestSourceHeader=Problem processing bundle manifest source header in plug-in {0} version {1} found at {2}
264
SourceLocationManager_problemProcessingBundleManifestSourceHeader=Problem processing bundle manifest source header in plug-in {0} version {1} found at {2}
265
UpdateSiteBuilder_0=Cleaning {0}
265
UpdateSiteBuilder_0=Cleaning {0}
266
267
VMHelper_noJreForExecEnv=No installed JREs satisfy this Execution Environment: "{0}". Launch aborted.
266
268
267
VMHelper_noJreForExecEnv=No installed JREs satisfy this Execution Environment: "{0}". Launch aborted.
269
######### Target Export Wizard ###################################33
270
ExportTargetDefinition_task = Exporting current target definition...
271
ExportTargetDeleteOldData = Deleting old data...
272
ExportTargetExportFeatures = Exporting features...
273
ExportTargetExportPlugins = Exporting plugins...
274
ExportTargetJob_ConfiguringDestination=Configuring destination
275
ExportTargetJob_ExportingTargetContents=Exporting target contents
(-)src/org/eclipse/pde/internal/core/target/ExportTargetJob.java (+233 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 EclipseSource Inc. and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     EclipseSource Inc. - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.core.target;
12
13
import java.net.URI;
14
import java.util.*;
15
import org.eclipse.core.filesystem.*;
16
import org.eclipse.core.runtime.*;
17
import org.eclipse.core.runtime.jobs.Job;
18
import org.eclipse.equinox.p2.internal.repository.tools.Repo2Runnable;
19
import org.eclipse.equinox.p2.internal.repository.tools.RepositoryDescriptor;
20
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
21
import org.eclipse.equinox.p2.metadata.IProvidedCapability;
22
import org.eclipse.equinox.p2.query.IQueryResult;
23
import org.eclipse.pde.internal.core.PDECore;
24
import org.eclipse.pde.internal.core.PDECoreMessages;
25
import org.eclipse.pde.internal.core.feature.ExternalFeatureModel;
26
import org.eclipse.pde.internal.core.ifeature.IFeatureModel;
27
import org.eclipse.pde.internal.core.target.provisional.*;
28
29
/**
30
 * This job exports the bundles and features that make up your target.
31
 */
32
public class ExportTargetJob extends Job {
33
34
	private URI fDestination;
35
	private boolean fclearDestinationDirectory = true;
36
	private IFileStore featureDir;
37
	private IFileStore pluginDir;
38
	private IFileSystem fileSystem;
39
	private Map filter;
40
	private ITargetDefinition fTarget;
41
42
	public ExportTargetJob(ITargetDefinition target, URI destination, boolean clearDestinationDirectory) {
43
		super("Export Current Target Definition Job"); //$NON-NLS-1$
44
		fTarget = target;
45
		fDestination = destination;
46
		fclearDestinationDirectory = clearDestinationDirectory;
47
	}
48
49
	protected IStatus run(IProgressMonitor monitor) {
50
		try {
51
			constructFilter(fTarget);
52
			IBundleContainer[] containers = fTarget.getBundleContainers();
53
			int totalWork = containers.length;
54
			monitor.beginTask(PDECoreMessages.ExportTargetDefinition_task, totalWork);
55
56
			monitor.subTask(PDECoreMessages.ExportTargetJob_ConfiguringDestination);
57
			setupDestination(monitor);
58
59
			monitor.subTask(PDECoreMessages.ExportTargetJob_ExportingTargetContents);
60
			for (int i = 0; i < containers.length; i++) {
61
				IBundleContainer container = containers[i];
62
				container.resolve(fTarget, monitor);
63
				if (!(container instanceof IUBundleContainer))
64
					exportContainer(container, fTarget, featureDir, pluginDir, fileSystem, monitor);
65
			}
66
			exportProfile(fTarget, fDestination, monitor);
67
		} catch (CoreException e) {
68
			return new Status(IStatus.ERROR, PDECore.PLUGIN_ID, "Failed to export the target", e); //$NON-NLS-1$
69
		} finally {
70
			monitor.done();
71
		}
72
		return Status.OK_STATUS;
73
	}
74
75
	private void constructFilter(ITargetDefinition target) {
76
		NameVersionDescriptor[] included = target.getIncluded();
77
		if (included == null)
78
			return;
79
		filter = new HashMap();
80
		for (int i = 0; i < included.length; i++) {
81
			NameVersionDescriptor inclusion = included[i];
82
			NameVersionDescriptor[] versions = (NameVersionDescriptor[]) filter.get(inclusion.getId());
83
			if (versions == null)
84
				filter.put(inclusion.getId(), new NameVersionDescriptor[] {inclusion});
85
			else {
86
				NameVersionDescriptor[] versions2 = new NameVersionDescriptor[versions.length + 1];
87
				System.arraycopy(versions, 0, versions2, 0, versions.length);
88
				versions2[versions.length] = inclusion;
89
				filter.put(inclusion.getId(), versions2);
90
			}
91
		}
92
	}
93
94
	private void setupDestination(IProgressMonitor monitor) throws CoreException {
95
		fileSystem = EFS.getLocalFileSystem();
96
		if (!fileSystem.canWrite()) {
97
			throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, "Destination directory not writable.")); //$NON-NLS-1$
98
		}
99
		IFileStore destination = fileSystem.getStore(fDestination);
100
		featureDir = destination.getChild("features"); //$NON-NLS-1$
101
		pluginDir = destination.getChild("plugins"); //$NON-NLS-1$
102
		if (fclearDestinationDirectory) {
103
			monitor.subTask(PDECoreMessages.ExportTargetDeleteOldData); //Deleting old data...
104
			featureDir.delete(EFS.NONE, null);
105
			pluginDir.delete(EFS.NONE, null);
106
		}
107
		featureDir.mkdir(EFS.NONE, null);
108
		pluginDir.mkdir(EFS.NONE, null);
109
	}
110
111
	private boolean shouldExport(NameVersionDescriptor descriptor) {
112
		// currently PDE does not selectively include/exclude features
113
		if (filter == null || descriptor.getType().equals(NameVersionDescriptor.TYPE_FEATURE))
114
			return true;
115
		NameVersionDescriptor[] versions = (NameVersionDescriptor[]) filter.get(descriptor.getId());
116
		if (versions == null)
117
			return false;
118
		for (int i = 0; i < versions.length; i++) {
119
			String version = versions[i].getVersion();
120
			if ((version == null || version.equals(descriptor.getVersion())) && descriptor.getType().equals(versions[i].getType()))
121
				return true;
122
		}
123
		return false;
124
	}
125
126
	private boolean shouldExport(IFeatureModel feature) {
127
		if (filter == null)
128
			return true;
129
		if (!feature.isEnabled() || !(feature instanceof ExternalFeatureModel))
130
			return false;
131
		NameVersionDescriptor descriptor = new NameVersionDescriptor(feature.getFeature().getId(), feature.getFeature().getVersion(), NameVersionDescriptor.TYPE_FEATURE);
132
		return shouldExport(descriptor);
133
	}
134
135
	private boolean shouldExport(IResolvedBundle bundle) {
136
		if (filter == null)
137
			return true;
138
		NameVersionDescriptor descriptor = new NameVersionDescriptor(bundle.getBundleInfo().getSymbolicName(), bundle.getBundleInfo().getVersion(), NameVersionDescriptor.TYPE_PLUGIN);
139
		return shouldExport(descriptor);
140
	}
141
142
	private boolean shouldExport(IInstallableUnit iu) {
143
		if (filter == null)
144
			return true;
145
		NameVersionDescriptor descriptor = null;
146
		String feature = getCapability(iu, "org.eclipse.update.feature"); //$NON-NLS-1$
147
		if (feature != null) {
148
			descriptor = new NameVersionDescriptor(feature, iu.getVersion().toString(), NameVersionDescriptor.TYPE_FEATURE);
149
		} else if (iu.getId().endsWith(".feature.group")) { //$NON-NLS-1$
150
			descriptor = new NameVersionDescriptor(iu.getId(), iu.getVersion().toString(), NameVersionDescriptor.TYPE_FEATURE);
151
		} else if ("bundle".equalsIgnoreCase(getCapability(iu, "org.eclipse.equinox.p2.eclipse.type"))) { //$NON-NLS-1$ //$NON-NLS-2$
152
			descriptor = new NameVersionDescriptor(iu.getId(), iu.getVersion().toString(), NameVersionDescriptor.TYPE_PLUGIN);
153
		} else if ("source".equalsIgnoreCase(getCapability(iu, "org.eclipse.equinox.p2.eclipse.type"))) { //$NON-NLS-1$ //$NON-NLS-2$
154
			descriptor = new NameVersionDescriptor(iu.getId(), iu.getVersion().toString(), NameVersionDescriptor.TYPE_PLUGIN);
155
		}
156
		// default to true unless we know otherwise. This ensures that random metadata bits
157
		// are moved over to the target as they might be needed in a future provisioning operation.
158
		// We could move only unknown IUs that do NOT have artifacts... Have to think about that.
159
		return descriptor == null ? true : shouldExport(descriptor);
160
	}
161
162
	private String getCapability(IInstallableUnit iu, String namespace) {
163
		for (Iterator i = iu.getProvidedCapabilities().iterator(); i.hasNext();) {
164
			IProvidedCapability capability = (IProvidedCapability) i.next();
165
			if (capability.getNamespace().equals(namespace))
166
				return capability.getName();
167
		}
168
		return null;
169
	}
170
171
	private void exportContainer(IBundleContainer container, ITargetDefinition target, IFileStore featureDir, IFileStore pluginDir, IFileSystem fileSystem, IProgressMonitor monitor) throws CoreException {
172
		IFeatureModel[] features = container.getFeatures();
173
		if (features != null) {
174
			monitor.subTask(PDECoreMessages.ExportTargetExportFeatures);
175
			for (int i = 0; i < features.length; i++) {
176
				if (shouldExport(features[i]))
177
					copy(features[i].getInstallLocation(), featureDir, fileSystem, monitor);
178
			}
179
		}
180
181
		IResolvedBundle[] bundles = container.getBundles();
182
		if (bundles != null) {
183
			monitor.subTask(PDECoreMessages.ExportTargetExportPlugins);
184
			for (int i = 0; i < bundles.length; i++) {
185
				if (shouldExport(bundles[i]))
186
					copy(bundles[i].getBundleInfo().getLocation().getPath(), pluginDir, fileSystem, monitor);
187
			}
188
		}
189
	}
190
191
	private IStatus copy(String src, IFileStore destinationParent, IFileSystem fileSystem, IProgressMonitor monitor) throws CoreException {
192
		Path srcPath = new Path(src);
193
		IFileStore source = fileSystem.getStore(srcPath);
194
		String elementName = srcPath.segment(srcPath.segmentCount() - 1);
195
		IFileStore destination = destinationParent.getChild(elementName);
196
		if (destination.fetchInfo().exists()) {
197
			monitor.worked(1);
198
			return Status.OK_STATUS;
199
		}
200
		if (source.fetchInfo().isDirectory()) {
201
			destination.mkdir(EFS.NONE, new NullProgressMonitor());
202
		}
203
		source.copy(destination, EFS.OVERWRITE, new SubProgressMonitor(monitor, 1));
204
		return Status.OK_STATUS;
205
	}
206
207
	private RepositoryDescriptor createRepoDescriptor(URI location, String name, String kind) {
208
		RepositoryDescriptor result = new RepositoryDescriptor();
209
		result.setLocation(location);
210
		result.setKind(kind);
211
		result.setName(name);
212
		if (fclearDestinationDirectory)
213
			result.setAppend(false);
214
		return result;
215
	}
216
217
	private void exportProfile(ITargetDefinition target, URI destination, IProgressMonitor monitor) throws CoreException {
218
		Repo2Runnable exporter = new Repo2Runnable();
219
		exporter.addDestination(createRepoDescriptor(destination, P2TargetUtils.getProfileId(target), RepositoryDescriptor.KIND_METADATA));
220
		exporter.addDestination(createRepoDescriptor(destination, P2TargetUtils.getProfileId(target), RepositoryDescriptor.KIND_ARTIFACT));
221
		exporter.addSource(createRepoDescriptor(P2TargetUtils.getBundlePool().getLocation(), null, RepositoryDescriptor.KIND_ARTIFACT));
222
223
		IQueryResult ius = P2TargetUtils.getIUs(target, monitor);
224
		ArrayList toExport = new ArrayList();
225
		for (Iterator i = ius.iterator(); i.hasNext();) {
226
			IInstallableUnit iu = (IInstallableUnit) i.next();
227
			if (shouldExport(iu))
228
				toExport.add(iu);
229
		}
230
		exporter.setSourceIUs(toExport);
231
		exporter.run(monitor);
232
	}
233
}
(-)src/org/eclipse/pde/internal/ui/PDEUIMessages.java (-10 / +2 lines)
Lines 1737-1760 Link Here
1737
	public static String CategorySection_newCategoryLabel;
1737
	public static String CategorySection_newCategoryLabel;
1738
1738
1739
	// Target Export ########################################
1739
	// Target Export ########################################
1740
	public static String ExportTargetDefinition_task;
1741
	public static String ExportTargetDeleteOldData;
1742
	public static String ExportTargetExportFeatures;
1743
	public static String ExportTargetExportPlugins;
1744
	public static String ExportActiveTargetDefinition;
1740
	public static String ExportActiveTargetDefinition;
1745
	public static String ExportActiveTargetDefinition_message;
1741
	public static String ExportActiveTargetDefinition_message;
1742
	public static String ExportTargetError_ChooseDestination;
1743
	public static String ExportTargetError_validPath;
1746
	public static String ExportTargetCurrentTarget;
1744
	public static String ExportTargetCurrentTarget;
1747
	public static String ExportTargetChooseFolder;
1745
	public static String ExportTargetChooseFolder;
1748
	public static String ExportTargetBrowse;
1746
	public static String ExportTargetBrowse;
1749
	public static String ExportTargetSelectDestination;
1747
	public static String ExportTargetSelectDestination;
1750
	public static String ExportTargetSpecifyDestination;
1748
	public static String ExportTargetSpecifyDestination;
1751
	public static String ExportTargetClearDestination;
1749
	public static String ExportTargetClearDestination;
1752
	public static String ExportTargetError_ChooseDestination;
1753
	public static String ExportTargetError_validPath;
1754
1755
	public static String ExportTargetJob_ConfiguringDestination;
1756
1757
	public static String ExportTargetJob_ExportingTargetContents;
1758
1750
1759
	public static String CategoryDetails_title;
1751
	public static String CategoryDetails_title;
1760
	public static String CategoryDetails_sectionDescription;
1752
	public static String CategoryDetails_sectionDescription;
(-)src/org/eclipse/pde/internal/ui/pderesources.properties (-14 / +8 lines)
Lines 664-670 Link Here
664
ExternalizeStringsWizardPage_subKey=Substitution Key
664
ExternalizeStringsWizardPage_subKey=Substitution Key
665
ExternalizeStringsResolution_label=Open Externalize Strings Wizard...
665
ExternalizeStringsResolution_label=Open Externalize Strings Wizard...
666
ExternalizeStringsWizardPage_keyDuplicateError=New key may not be a duplicate of another key
666
ExternalizeStringsWizardPage_keyDuplicateError=New key may not be a duplicate of another key
667
ExternalizeStringsWizardPage_keySuggested=\n\tsuggested key value: 
667
ExternalizeStringsWizardPage_keySuggested=\n\tsuggested key value:
668
668
669
Preferences_TargetEnvironmentPage_os = &Operating System:
669
Preferences_TargetEnvironmentPage_os = &Operating System:
670
Preferences_TargetEnvironmentPage_ws = &Windowing System:
670
Preferences_TargetEnvironmentPage_ws = &Windowing System:
Lines 1011-1017 Link Here
1011
1011
1012
NewSchemaFileMainPage_missingPluginID = Specify a valid plug-in ID.  No Plug-in ID specified.
1012
NewSchemaFileMainPage_missingPluginID = Specify a valid plug-in ID.  No Plug-in ID specified.
1013
NewSchemaFileMainPage_nonExistingPluginID = Specify a valid plug-in ID.  Specified plug-in ID does not exist.
1013
NewSchemaFileMainPage_nonExistingPluginID = Specify a valid plug-in ID.  Specified plug-in ID does not exist.
1014
NewSchemaFileMainPage_externalPluginID = Specify a valid plug-in ID.  Specified plug-in ID is external to the workspace. 
1014
NewSchemaFileMainPage_externalPluginID = Specify a valid plug-in ID.  Specified plug-in ID is external to the workspace.
1015
NewSchemaFileMainPage_missingContainer = Specify a valid container.  No container specified.
1015
NewSchemaFileMainPage_missingContainer = Specify a valid container.  No container specified.
1016
NewSchemaFileMainPage_invalidContainer = Specify a valid container.  Specified container is not a valid project or folder.
1016
NewSchemaFileMainPage_invalidContainer = Specify a valid container.  Specified container is not a valid project or folder.
1017
NewSchemaFileMainPage_nonExistingContainer = Specify a valid container.  Specified container does not exist.
1017
NewSchemaFileMainPage_nonExistingContainer = Specify a valid container.  Specified container does not exist.
Lines 1241-1247 Link Here
1241
EditorUtilities_noImageData=The specified file contains no image data
1241
EditorUtilities_noImageData=The specified file contains no image data
1242
EditorPreferencePage_tag=Tags
1242
EditorPreferencePage_tag=Tags
1243
EditorPreferencePage_xml=&XML Highlighting
1243
EditorPreferencePage_xml=&XML Highlighting
1244
EditorUtilities_icoError=The specified ICO file is missing images: 
1244
EditorUtilities_icoError=The specified ICO file is missing images:
1245
EditorPreferencePage_comment=Comments
1245
EditorPreferencePage_comment=Comments
1246
EditorPreferencePage_manifest=&Manifest Highlighting
1246
EditorPreferencePage_manifest=&Manifest Highlighting
1247
EditorUtilities_incorrectSize=The specified image is not the correct size: {0}.
1247
EditorUtilities_incorrectSize=The specified image is not the correct size: {0}.
Lines 1487-1493 Link Here
1487
compilers_p_not_externalized_att = Usage of non-externali&zed strings:
1487
compilers_p_not_externalized_att = Usage of non-externali&zed strings:
1488
compilers_p_deprecated = Usage of deprecated attributes and &elements:
1488
compilers_p_deprecated = Usage of deprecated attributes and &elements:
1489
compilers_p_internal = Usage o&f internal extension points:
1489
compilers_p_internal = Usage o&f internal extension points:
1490
compilers_p_exported_pkgs = Missing exported pac&kages: 
1490
compilers_p_exported_pkgs = Missing exported pac&kages:
1491
compilers_p_missing_exp_pkg = Missing versions on exported packages:
1491
compilers_p_missing_exp_pkg = Missing versions on exported packages:
1492
compilers_p_missing_imp_pkg = Missing versions on imported packages:
1492
compilers_p_missing_imp_pkg = Missing versions on imported packages:
1493
compilers_p_missing_require_bundle = Missing versions on required bundles:
1493
compilers_p_missing_require_bundle = Missing versions on required bundles:
Lines 1593-1605 Link Here
1593
CategorySection_newCategoryLabel = New Category {0}
1593
CategorySection_newCategoryLabel = New Category {0}
1594
1594
1595
######### Target Export Wizard ###################################33
1595
######### Target Export Wizard ###################################33
1596
ExportTargetDefinition_task = Exporting current target definition...
1597
ExportTargetDeleteOldData = Deleting old data...
1598
ExportTargetExportFeatures = Exporting features...
1599
ExportTargetExportPlugins = Exporting plugins...
1600
ExportActiveTargetDefinition = Exporting Target Definition
1596
ExportActiveTargetDefinition = Exporting Target Definition
1601
ExportActiveTargetDefinition_message = Please choose a destination directory to export all target content
1597
ExportActiveTargetDefinition_message = Please choose a destination directory to export all target content
1602
ExportTargetCurrentTarget = Active &Target: 
1598
ExportTargetCurrentTarget = Active &Target:
1603
ExportTargetChooseFolder = &Destination:
1599
ExportTargetChooseFolder = &Destination:
1604
ExportTargetBrowse = &Browse...
1600
ExportTargetBrowse = &Browse...
1605
ExportTargetSelectDestination = Select Destination
1601
ExportTargetSelectDestination = Select Destination
Lines 1607-1614 Link Here
1607
ExportTargetClearDestination = &Clear destination directory before exporting
1603
ExportTargetClearDestination = &Clear destination directory before exporting
1608
ExportTargetError_ChooseDestination = Please choose a destination directory
1604
ExportTargetError_ChooseDestination = Please choose a destination directory
1609
ExportTargetError_validPath = Destination directory must be a valid path
1605
ExportTargetError_validPath = Destination directory must be a valid path
1610
ExportTargetJob_ConfiguringDestination=Configuring destination
1611
ExportTargetJob_ExportingTargetContents=Exporting target contents
1612
1606
1613
1607
1614
CategoryDetails_title = Category Properties
1608
CategoryDetails_title = Category Properties
Lines 2074-2080 Link Here
2074
InternationalizeWizard_LocalePage_availableList = Available locales:
2068
InternationalizeWizard_LocalePage_availableList = Available locales:
2075
InternationalizeWizard_LocalePage_filter = Filter available locales:
2069
InternationalizeWizard_LocalePage_filter = Filter available locales:
2076
InternationalizeWizard_LocalePage_selectionError=At least one locale must be selected.
2070
InternationalizeWizard_LocalePage_selectionError=At least one locale must be selected.
2077
InternationalizeWizard_NLSFragmentGenerator_overwriteTitle = Confirm Overwrite 
2071
InternationalizeWizard_NLSFragmentGenerator_overwriteTitle = Confirm Overwrite
2078
InternationalizeWizard_NLSFragmentGenerator_overwriteMessage = A fragment project with the name "{0}" already exists. Overwrite?
2072
InternationalizeWizard_NLSFragmentGenerator_overwriteMessage = A fragment project with the name "{0}" already exists. Overwrite?
2079
InternationalizeWizard_NLSFragmentGenerator_errorMessage = An error occured while generating an NL Fragment.
2073
InternationalizeWizard_NLSFragmentGenerator_errorMessage = An error occured while generating an NL Fragment.
2080
2074
Lines 2137-2143 Link Here
2137
OrganizeManifestsWizardPage_errorMsg=This function works only on plug-ins containing a MANIFEST.MF
2131
OrganizeManifestsWizardPage_errorMsg=This function works only on plug-ins containing a MANIFEST.MF
2138
OrganizeManifestsWizardPage_prefixNL=&Prefix icon paths in plug-in extensions with an $nl$ segment
2132
OrganizeManifestsWizardPage_prefixNL=&Prefix icon paths in plug-in extensions with an $nl$ segment
2139
OrganizeManifestsOperation_nlIconPath=checking icon paths for missing $nl$ segments... {0}
2133
OrganizeManifestsOperation_nlIconPath=checking icon paths for missing $nl$ segments... {0}
2140
OrganizeManifestsOperation_unusedKeys=checking for unused keys... {0} 
2134
OrganizeManifestsOperation_unusedKeys=checking for unused keys... {0}
2141
OrganizeManifestsWizardPage_addMissing=&Ensure that all packages appear in the MANIFEST.MF
2135
OrganizeManifestsWizardPage_addMissing=&Ensure that all packages appear in the MANIFEST.MF
2142
OrganizeManifestsProcessor_rootMessage=Organize Manifest for {0}
2136
OrganizeManifestsProcessor_rootMessage=Organize Manifest for {0}
2143
OrganizeManifestsWizardPage_lazyStart=Remove unnecessary lazy activation headers
2137
OrganizeManifestsWizardPage_lazyStart=Remove unnecessary lazy activation headers
Lines 2319-2325 Link Here
2319
RemoveSplashHandlerBindingAction_msgProgressRemoveProductBindings=Removing product bindings from extension ''{0}'' ...
2313
RemoveSplashHandlerBindingAction_msgProgressRemoveProductBindings=Removing product bindings from extension ''{0}'' ...
2320
StateViewPage_requiredBundles=Required Plug-ins
2314
StateViewPage_requiredBundles=Required Plug-ins
2321
StateViewPage_importedPackages=Imported Packages
2315
StateViewPage_importedPackages=Imported Packages
2322
StateViewPage_suppliedBy=\ - supplied by: 
2316
StateViewPage_suppliedBy=\ - supplied by:
2323
StateViewPage_suppliedByJRE=\ - supplied by the JRE
2317
StateViewPage_suppliedByJRE=\ - supplied by the JRE
2324
StateViewPage_showLeaves=Show leaf plug-ins
2318
StateViewPage_showLeaves=Show leaf plug-ins
2325
StateViewPage_openItem=Open
2319
StateViewPage_openItem=Open
(-)src/org/eclipse/pde/internal/ui/wizards/exports/ExportTargetJob.java (-235 lines)
Lines 1-235 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 EclipseSource Inc. and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     EclipseSource Inc. - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.wizards.exports;
12
13
import java.net.URI;
14
import java.util.*;
15
import org.eclipse.core.filesystem.*;
16
import org.eclipse.core.runtime.*;
17
import org.eclipse.core.runtime.jobs.Job;
18
import org.eclipse.equinox.p2.internal.repository.tools.Repo2Runnable;
19
import org.eclipse.equinox.p2.internal.repository.tools.RepositoryDescriptor;
20
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
21
import org.eclipse.equinox.p2.metadata.IProvidedCapability;
22
import org.eclipse.equinox.p2.query.IQueryResult;
23
import org.eclipse.pde.internal.core.feature.ExternalFeatureModel;
24
import org.eclipse.pde.internal.core.ifeature.IFeatureModel;
25
import org.eclipse.pde.internal.core.target.IUBundleContainer;
26
import org.eclipse.pde.internal.core.target.P2TargetUtils;
27
import org.eclipse.pde.internal.core.target.provisional.*;
28
import org.eclipse.pde.internal.ui.PDEPlugin;
29
import org.eclipse.pde.internal.ui.PDEUIMessages;
30
31
/**
32
 * This job exports the bundles and features that make up your target. 
33
 */
34
public class ExportTargetJob extends Job {
35
36
	private URI fDestination;
37
	private boolean fclearDestinationDirectory = true;
38
	private IFileStore featureDir;
39
	private IFileStore pluginDir;
40
	private IFileSystem fileSystem;
41
	private Map filter;
42
	private ITargetDefinition fTarget;
43
44
	public ExportTargetJob(ITargetDefinition target, URI destination, boolean clearDestinationDirectory) {
45
		super("Export Current Target Definition Job"); //$NON-NLS-1$
46
		fTarget = target;
47
		fDestination = destination;
48
		fclearDestinationDirectory = clearDestinationDirectory;
49
	}
50
51
	protected IStatus run(IProgressMonitor monitor) {
52
		try {
53
			constructFilter(fTarget);
54
			IBundleContainer[] containers = fTarget.getBundleContainers();
55
			int totalWork = containers.length;
56
			monitor.beginTask(PDEUIMessages.ExportTargetDefinition_task, totalWork);
57
58
			monitor.subTask(PDEUIMessages.ExportTargetJob_ConfiguringDestination);
59
			setupDestination(monitor);
60
61
			monitor.subTask(PDEUIMessages.ExportTargetJob_ExportingTargetContents);
62
			for (int i = 0; i < containers.length; i++) {
63
				IBundleContainer container = containers[i];
64
				container.resolve(fTarget, monitor);
65
				if (!(container instanceof IUBundleContainer))
66
					exportContainer(container, fTarget, featureDir, pluginDir, fileSystem, monitor);
67
			}
68
			exportProfile(fTarget, fDestination, monitor);
69
		} catch (CoreException e) {
70
			return new Status(IStatus.ERROR, PDEPlugin.getPluginId(), "Failed to export the target", e); //$NON-NLS-1$ 
71
		} finally {
72
			monitor.done();
73
		}
74
		return Status.OK_STATUS;
75
	}
76
77
	private void constructFilter(ITargetDefinition target) {
78
		NameVersionDescriptor[] included = target.getIncluded();
79
		if (included == null)
80
			return;
81
		filter = new HashMap();
82
		for (int i = 0; i < included.length; i++) {
83
			NameVersionDescriptor inclusion = included[i];
84
			NameVersionDescriptor[] versions = (NameVersionDescriptor[]) filter.get(inclusion.getId());
85
			if (versions == null)
86
				filter.put(inclusion.getId(), new NameVersionDescriptor[] {inclusion});
87
			else {
88
				NameVersionDescriptor[] versions2 = new NameVersionDescriptor[versions.length + 1];
89
				System.arraycopy(versions, 0, versions2, 0, versions.length);
90
				versions2[versions.length] = inclusion;
91
				filter.put(inclusion.getId(), versions2);
92
			}
93
		}
94
	}
95
96
	private void setupDestination(IProgressMonitor monitor) throws CoreException {
97
		fileSystem = EFS.getLocalFileSystem();
98
		if (!fileSystem.canWrite()) {
99
			throw new CoreException(new Status(IStatus.ERROR, PDEPlugin.getPluginId(), "Destination directory not writable.")); //$NON-NLS-1$ 
100
		}
101
		IFileStore destination = fileSystem.getStore(fDestination);
102
		featureDir = destination.getChild("features"); //$NON-NLS-1$
103
		pluginDir = destination.getChild("plugins"); //$NON-NLS-1$
104
		if (fclearDestinationDirectory) {
105
			monitor.subTask(PDEUIMessages.ExportTargetDeleteOldData); //Deleting old data...
106
			featureDir.delete(EFS.NONE, null);
107
			pluginDir.delete(EFS.NONE, null);
108
		}
109
		featureDir.mkdir(EFS.NONE, null);
110
		pluginDir.mkdir(EFS.NONE, null);
111
	}
112
113
	private boolean shouldExport(NameVersionDescriptor descriptor) {
114
		// currently PDE does not selectively include/exclude features
115
		if (filter == null || descriptor.getType().equals(NameVersionDescriptor.TYPE_FEATURE))
116
			return true;
117
		NameVersionDescriptor[] versions = (NameVersionDescriptor[]) filter.get(descriptor.getId());
118
		if (versions == null)
119
			return false;
120
		for (int i = 0; i < versions.length; i++) {
121
			String version = versions[i].getVersion();
122
			if ((version == null || version.equals(descriptor.getVersion())) && descriptor.getType().equals(versions[i].getType()))
123
				return true;
124
		}
125
		return false;
126
	}
127
128
	private boolean shouldExport(IFeatureModel feature) {
129
		if (filter == null)
130
			return true;
131
		if (!feature.isEnabled() || !(feature instanceof ExternalFeatureModel))
132
			return false;
133
		NameVersionDescriptor descriptor = new NameVersionDescriptor(feature.getFeature().getId(), feature.getFeature().getVersion(), NameVersionDescriptor.TYPE_FEATURE);
134
		return shouldExport(descriptor);
135
	}
136
137
	private boolean shouldExport(IResolvedBundle bundle) {
138
		if (filter == null)
139
			return true;
140
		NameVersionDescriptor descriptor = new NameVersionDescriptor(bundle.getBundleInfo().getSymbolicName(), bundle.getBundleInfo().getVersion(), NameVersionDescriptor.TYPE_PLUGIN);
141
		return shouldExport(descriptor);
142
	}
143
144
	private boolean shouldExport(IInstallableUnit iu) {
145
		if (filter == null)
146
			return true;
147
		NameVersionDescriptor descriptor = null;
148
		String feature = getCapability(iu, "org.eclipse.update.feature"); //$NON-NLS-1$
149
		if (feature != null) {
150
			descriptor = new NameVersionDescriptor(feature, iu.getVersion().toString(), NameVersionDescriptor.TYPE_FEATURE);
151
		} else if (iu.getId().endsWith(".feature.group")) { //$NON-NLS-1$
152
			descriptor = new NameVersionDescriptor(iu.getId(), iu.getVersion().toString(), NameVersionDescriptor.TYPE_FEATURE);
153
		} else if ("bundle".equalsIgnoreCase(getCapability(iu, "org.eclipse.equinox.p2.eclipse.type"))) { //$NON-NLS-1$ //$NON-NLS-2$
154
			descriptor = new NameVersionDescriptor(iu.getId(), iu.getVersion().toString(), NameVersionDescriptor.TYPE_PLUGIN);
155
		} else if ("source".equalsIgnoreCase(getCapability(iu, "org.eclipse.equinox.p2.eclipse.type"))) { //$NON-NLS-1$ //$NON-NLS-2$
156
			descriptor = new NameVersionDescriptor(iu.getId(), iu.getVersion().toString(), NameVersionDescriptor.TYPE_PLUGIN);
157
		}
158
		// default to true unless we know otherwise. This ensures that random metadata bits
159
		// are moved over to the target as they might be needed in a future provisioning operation.
160
		// We could move only unknown IUs that do NOT have artifacts... Have to think about that.
161
		return descriptor == null ? true : shouldExport(descriptor);
162
	}
163
164
	private String getCapability(IInstallableUnit iu, String namespace) {
165
		for (Iterator i = iu.getProvidedCapabilities().iterator(); i.hasNext();) {
166
			IProvidedCapability capability = (IProvidedCapability) i.next();
167
			if (capability.getNamespace().equals(namespace))
168
				return capability.getName();
169
		}
170
		return null;
171
	}
172
173
	private void exportContainer(IBundleContainer container, ITargetDefinition target, IFileStore featureDir, IFileStore pluginDir, IFileSystem fileSystem, IProgressMonitor monitor) throws CoreException {
174
		IFeatureModel[] features = container.getFeatures();
175
		if (features != null) {
176
			monitor.subTask(PDEUIMessages.ExportTargetExportFeatures);
177
			for (int i = 0; i < features.length; i++) {
178
				if (shouldExport(features[i]))
179
					copy(features[i].getInstallLocation(), featureDir, fileSystem, monitor);
180
			}
181
		}
182
183
		IResolvedBundle[] bundles = container.getBundles();
184
		if (bundles != null) {
185
			monitor.subTask(PDEUIMessages.ExportTargetExportPlugins);
186
			for (int i = 0; i < bundles.length; i++) {
187
				if (shouldExport(bundles[i]))
188
					copy(bundles[i].getBundleInfo().getLocation().getPath(), pluginDir, fileSystem, monitor);
189
			}
190
		}
191
	}
192
193
	private IStatus copy(String src, IFileStore destinationParent, IFileSystem fileSystem, IProgressMonitor monitor) throws CoreException {
194
		Path srcPath = new Path(src);
195
		IFileStore source = fileSystem.getStore(srcPath);
196
		String elementName = srcPath.segment(srcPath.segmentCount() - 1);
197
		IFileStore destination = destinationParent.getChild(elementName);
198
		if (destination.fetchInfo().exists()) {
199
			monitor.worked(1);
200
			return Status.OK_STATUS;
201
		}
202
		if (source.fetchInfo().isDirectory()) {
203
			destination.mkdir(EFS.NONE, new NullProgressMonitor());
204
		}
205
		source.copy(destination, EFS.OVERWRITE, new SubProgressMonitor(monitor, 1));
206
		return Status.OK_STATUS;
207
	}
208
209
	private RepositoryDescriptor createRepoDescriptor(URI location, String name, String kind) {
210
		RepositoryDescriptor result = new RepositoryDescriptor();
211
		result.setLocation(location);
212
		result.setKind(kind);
213
		result.setName(name);
214
		if (fclearDestinationDirectory)
215
			result.setAppend(false);
216
		return result;
217
	}
218
219
	private void exportProfile(ITargetDefinition target, URI destination, IProgressMonitor monitor) throws CoreException {
220
		Repo2Runnable exporter = new Repo2Runnable();
221
		exporter.addDestination(createRepoDescriptor(destination, P2TargetUtils.getProfileId(target), RepositoryDescriptor.KIND_METADATA));
222
		exporter.addDestination(createRepoDescriptor(destination, P2TargetUtils.getProfileId(target), RepositoryDescriptor.KIND_ARTIFACT));
223
		exporter.addSource(createRepoDescriptor(P2TargetUtils.getBundlePool().getLocation(), null, RepositoryDescriptor.KIND_ARTIFACT));
224
225
		IQueryResult ius = P2TargetUtils.getIUs(target, monitor);
226
		ArrayList toExport = new ArrayList();
227
		for (Iterator i = ius.iterator(); i.hasNext();) {
228
			IInstallableUnit iu = (IInstallableUnit) i.next();
229
			if (shouldExport(iu))
230
				toExport.add(iu);
231
		}
232
		exporter.setSourceIUs(toExport);
233
		exporter.run(monitor);
234
	}
235
}
(-)src/org/eclipse/pde/internal/ui/wizards/exports/TargetDefinitionExportWizard.java (+2 lines)
Lines 11-16 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.pde.internal.ui.wizards.exports;
12
package org.eclipse.pde.internal.ui.wizards.exports;
13
13
14
import org.eclipse.pde.internal.core.target.ExportTargetJob;
15
14
import java.io.File;
16
import java.io.File;
15
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.jobs.Job;
18
import org.eclipse.core.runtime.jobs.Job;

Return to bug 351526