diff --git a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/util/ManifestUtils.java b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/util/ManifestUtils.java index f2b7db192e..b806a9c385 100644 --- a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/util/ManifestUtils.java +++ b/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/util/ManifestUtils.java @@ -13,11 +13,16 @@ *******************************************************************************/ package org.eclipse.pde.internal.core.util; +import static org.osgi.framework.namespace.ExecutionEnvironmentNamespace.CAPABILITY_VERSION_ATTRIBUTE; +import static org.osgi.framework.namespace.ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE; + import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.Writer; +import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.Hashtable; import java.util.LinkedList; @@ -25,6 +30,8 @@ import java.util.Map; import java.util.Map.Entry; import java.util.jar.JarFile; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -38,6 +45,8 @@ import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.launching.JavaRuntime; +import org.eclipse.jdt.launching.environments.IExecutionEnvironment; import org.eclipse.osgi.util.ManifestElement; import org.eclipse.osgi.util.NLS; import org.eclipse.pde.core.build.IBuild; @@ -50,6 +59,9 @@ import org.eclipse.pde.internal.core.project.PDEProject; import org.osgi.framework.BundleException; import org.osgi.framework.Constants; +import org.osgi.framework.Filter; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.InvalidSyntaxException; public class ManifestUtils { @@ -77,7 +89,7 @@ public class ManifestUtils { *
* If this method is being called from a dev mode workspace, the returned map * should be passed to {@link TargetWeaver#weaveManifest(Map, File)} so that the - * bundle classpath can be corrected. + * bundle classpath can be corrected. *
** This method is called by @@ -285,4 +297,61 @@ private static String splitOnComma(String value) { sb.append(values[values.length - 1]); return sb.toString(); } + + + // Simple filters are for example (&(version=17)(osgi.ee=JavaSE)) + private static final Pattern SIMPLE_EE_FILTER; + private static final int NAME_GROUP = 2; + private static final int VERSION_GROUP = 3; + static { + String nameSegment = "\\(" + EXECUTION_ENVIRONMENT_NAMESPACE + "=([\\w/]+)\\)"; //$NON-NLS-1$//$NON-NLS-2$ + String versionSegment = "\\(" + CAPABILITY_VERSION_ATTRIBUTE + "=([\\d\\.]+)\\)"; //$NON-NLS-1$ //$NON-NLS-2$ + SIMPLE_EE_FILTER = Pattern.compile("\\(&(" + nameSegment + ")|(" + versionSegment + ")\\)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } + + private static final List