Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 260831 | Differences between
and this patch

Collapse All | Expand All

(-)src/java/org/eclipse/buckminster/core/materializer/PlatformIndependentFeature.java (-8 / +1 lines)
Lines 23-38 Link Here
23
 *         An {@link IFeature} that ignores platform specific information. Thus installs even non matching platform
23
 *         An {@link IFeature} that ignores platform specific information. Thus installs even non matching platform
24
 *         specific bundles.
24
 *         specific bundles.
25
 */
25
 */
26
public class PlatformIgnoringFeature extends Feature
26
public class PlatformIndependentFeature extends Feature
27
{
27
{
28
28
29
	private MaterializationContext context;
30
31
	public PlatformIgnoringFeature(MaterializationContext aContext)
32
	{
33
		context = aContext;
34
	}
35
36
	/*
29
	/*
37
	 * (non-Javadoc)
30
	 * (non-Javadoc)
38
	 * 
31
	 * 
(-)plugin.xml (+10 lines)
Lines 302-305 Link Here
302
          priority="0">
302
          priority="0">
303
    </targetPlatform>
303
    </targetPlatform>
304
 </extension>
304
 </extension>
305
 <extension
306
       point="org.eclipse.core.runtime.adapters">
307
    <factory
308
          adaptableType="org.eclipse.update.core.Feature"
309
          class="org.eclipse.buckminster.core.internal.FeatureAdapterFactory">
310
       <adapter
311
             type="org.eclipse.buckminster.core.materializer.PlatformIndependentFeature">
312
       </adapter>
313
    </factory>
314
 </extension>
305
</plugin>
315
</plugin>
(-)src/java/org/eclipse/buckminster/core/materializer/TargetPlatformMaterializer.java (-43 / +1 lines)
Lines 74-121 Link Here
74
		return installSite.getSite();
74
		return installSite.getSite();
75
	}
75
	}
76
76
77
	/**
78
	 * @param aFeature
79
	 *            The feature to convert into a new IFeature instance that treats platform specific bundles as regular
80
	 *            ones. Thus installs even non matching bundles.
81
	 * @param context
82
	 * @return
83
	 * @throws CoreException
84
	 */
85
	private IFeature convertFeature(IFeature aFeature, MaterializationContext context) throws CoreException
86
	{
87
		// A shallow copy should be sufficient
88
		IFeature piFeature = new PlatformIgnoringFeature(context);
89
		try
90
		{
91
			Class<?> clazz = aFeature.getClass();
92
			while(clazz != null)
93
			{
94
				Field[] fields = clazz.getDeclaredFields();
95
				for(int i = 0; i < fields.length; i++)
96
				{
97
					Field field = fields[i];
98
					if(!(Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers()))
99
							|| field.isEnumConstant())
100
					{
101
						field.setAccessible(true);
102
						field.set(piFeature, field.get(aFeature));
103
					}
104
				}
105
				clazz = clazz.getSuperclass();
106
			}
107
		}
108
		catch(IllegalArgumentException e)
109
		{
110
			throw BuckminsterException.wrap(e);
111
		}
112
		catch(IllegalAccessException e)
113
		{
114
			throw BuckminsterException.wrap(e);
115
		}
116
		return piFeature;
117
	}
118
119
	@Override
77
	@Override
120
	public IPath getDefaultInstallRoot(MaterializationContext context, Resolution resolution) throws CoreException
78
	public IPath getDefaultInstallRoot(MaterializationContext context, Resolution resolution) throws CoreException
121
	{
79
	{
Lines 215-221 Link Here
215
			for(ISiteFeatureReference featureRef : featureRefs)
173
			for(ISiteFeatureReference featureRef : featureRefs)
216
			{
174
			{
217
				IFeature feature = featureRef.getFeature(MonitorUtils.subMonitor(monitor, 50));
175
				IFeature feature = featureRef.getFeature(MonitorUtils.subMonitor(monitor, 50));
218
				IFeature platformIngoringFeature = convertFeature(feature, context);
176
				IFeature platformIngoringFeature = (IFeature)feature.getAdapter(PlatformIndependentFeature.class);
219
				destinationSite.install(platformIngoringFeature, null, MonitorUtils.subMonitor(monitor, 50));
177
				destinationSite.install(platformIngoringFeature, null, MonitorUtils.subMonitor(monitor, 50));
220
			}
178
			}
221
		}
179
		}
(-)src/java/org/eclipse/buckminster/core/materializer/PlatformIgnoringFeature.java (-64 lines)
Lines 1-64 Link Here
1
/*******************************************************************
2
 * Copyright (c) 2009, Versant GmbH.
3
 * The code, documentation and other materials contained herein
4
 * are the sole and exclusive property of Versant GmbH. and may
5
 * not be disclosed, used, modified, copied or distributed without
6
 * prior written consent or license from Versant GmbH.
7
 ******************************************************************/
8
9
package org.eclipse.buckminster.core.materializer;
10
11
import java.util.ArrayList;
12
import java.util.List;
13
14
import org.eclipse.core.runtime.PluginVersionIdentifier;
15
import org.eclipse.update.core.Feature;
16
import org.eclipse.update.core.IFeature;
17
import org.eclipse.update.core.IPluginEntry;
18
import org.eclipse.update.core.VersionedIdentifier;
19
20
/**
21
 * @author Markus Alexander Kuppe <buckminster-dev_eclipse.org at lemmster dot de>
22
 * 
23
 *         An {@link IFeature} that ignores platform specific information. Thus installs even non matching platform
24
 *         specific bundles.
25
 */
26
public class PlatformIgnoringFeature extends Feature
27
{
28
29
	private MaterializationContext context;
30
31
	public PlatformIgnoringFeature(MaterializationContext aContext)
32
	{
33
		context = aContext;
34
	}
35
36
	/*
37
	 * (non-Javadoc)
38
	 * 
39
	 * @see org.eclipse.update.core.Feature#getPluginEntries()
40
	 */
41
	@Override
42
	public IPluginEntry[] getPluginEntries()
43
	{
44
		IPluginEntry[] pluginEntries = getRawPluginEntries();
45
46
		// normally this could simply return pluginEntries, but because of https://bugs.eclipse.org/213437 it filters
47
		List<IPluginEntry> result = new ArrayList<IPluginEntry>();
48
		for(int i = 0; i < pluginEntries.length; i++)
49
		{
50
			IPluginEntry iPluginEntry = pluginEntries[i];
51
			VersionedIdentifier versionedIdentifier = iPluginEntry.getVersionedIdentifier();
52
			String identifier = versionedIdentifier.getIdentifier();
53
			PluginVersionIdentifier version = versionedIdentifier.getVersion();
54
			if((identifier.startsWith("org.eclipse.swt.") || identifier.startsWith("org.eclipse.equinox.launcher."))
55
					&& (version.getMajorComponent() == 0 && version.getMinorComponent() == 0 && version
56
							.getServiceComponent() == 0))
57
			{
58
				continue;
59
			}
60
			result.add(iPluginEntry);
61
		}
62
		return result.toArray(new IPluginEntry[result.size()]);
63
	}
64
}
(-)src/java/org/eclipse/buckminster/core/internal/FeatureAdapterFactory.java (+88 lines)
Line 0 Link Here
1
/*******************************************************************
2
 * Copyright (c) 2009, Versant GmbH.
3
 * The code, documentation and other materials contained herein
4
 * are the sole and exclusive property of Versant GmbH. and may
5
 * not be disclosed, used, modified, copied or distributed without
6
 * prior written consent or license from Versant GmbH.
7
 ******************************************************************/
8
9
package org.eclipse.buckminster.core.internal;
10
11
import java.lang.reflect.Field;
12
import java.lang.reflect.Modifier;
13
14
import org.eclipse.buckminster.core.materializer.PlatformIndependentFeature;
15
import org.eclipse.core.runtime.IAdapterFactory;
16
import org.eclipse.update.core.Feature;
17
import org.eclipse.update.core.IFeature;
18
19
/**
20
 * @author Markus Alexander Kuppe <buckminster-dev_eclipse.org at lemmster dot de>
21
 * 
22
 */
23
public class FeatureAdapterFactory implements IAdapterFactory
24
{
25
26
	/**
27
	 * @param aFeature
28
	 *            The feature to convert into a new IFeature instance that treats platform specific bundles as regular
29
	 *            ones. Thus installs even non matching bundles.
30
	 */
31
	private IFeature convertFeature(Feature aFeature)
32
	{
33
		// A shallow copy should be sufficient
34
		IFeature piFeature = new PlatformIndependentFeature();
35
		try
36
		{
37
			Class<?> clazz = aFeature.getClass();
38
			while(clazz != null)
39
			{
40
				Field[] fields = clazz.getDeclaredFields();
41
				for(int i = 0; i < fields.length; i++)
42
				{
43
					Field field = fields[i];
44
					if(!(Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers()))
45
							|| field.isEnumConstant())
46
					{
47
						field.setAccessible(true);
48
						field.set(piFeature, field.get(aFeature));
49
					}
50
				}
51
				clazz = clazz.getSuperclass();
52
			}
53
		}
54
		catch(IllegalArgumentException e)
55
		{
56
			return aFeature;
57
		}
58
		catch(IllegalAccessException e)
59
		{
60
			return aFeature;
61
		}
62
		return piFeature;
63
	}
64
65
	/*
66
	 * (non-Javadoc)
67
	 * 
68
	 * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
69
	 */
70
	public Object getAdapter(Object adaptableObject, Class adapterType)
71
	{
72
		if(adaptableObject instanceof Feature && adapterType == PlatformIndependentFeature.class)
73
		{
74
			return convertFeature((Feature)adaptableObject);
75
		}
76
		return adaptableObject;
77
	}
78
79
	/*
80
	 * (non-Javadoc)
81
	 * 
82
	 * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
83
	 */
84
	public Class[] getAdapterList()
85
	{
86
		return new Class[] { IFeature.class };
87
	}
88
}

Return to bug 260831