Skip to content

Commit b5d7425

Browse files
committed
Add EMF-packages declared in MANIFEST.MF to EPackage-registry too
1 parent 4fb5fe9 commit b5d7425

File tree

8 files changed

+293
-25
lines changed

8 files changed

+293
-25
lines changed

features/org.eclipse.emf.ecore-feature/feature.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<feature
33
id="org.eclipse.emf.ecore"
44
label="%featureName"
5-
version="2.39.0.qualifier"
5+
version="2.40.0.qualifier"
66
provider-name="%providerName"
77
license-feature="org.eclipse.emf.license"
88
license-feature-version="2.11.0">

features/org.eclipse.emf.ecore-feature/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<groupId>org.eclipse.emf.features</groupId>
1414
<artifactId>org.eclipse.emf.ecore</artifactId>
15-
<version>2.39.0-SNAPSHOT</version>
15+
<version>2.40.0-SNAPSHOT</version>
1616
<packaging>eclipse-feature</packaging>
1717

1818
</project>

plugins/org.eclipse.emf.codegen.ecore/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.9.0,4.0.0)",
2323
org.eclipse.core.resources;bundle-version="[3.8.0,4.0.0)",
2424
org.eclipse.jdt.core;bundle-version="[3.9.0,4.0.0)",
2525
org.eclipse.jdt.launching;bundle-version="[3.5.0,4.0.0)",
26-
org.eclipse.emf.ecore;bundle-version="[2.38.0,3.0.0)";visibility:=reexport,
26+
org.eclipse.emf.ecore;bundle-version="[2.39.0,3.0.0)";visibility:=reexport,
2727
org.eclipse.emf.codegen;bundle-version="[2.25.0,3.0.0)";visibility:=reexport,
2828
org.eclipse.emf.ecore.xmi;bundle-version="[2.38.0,3.0.0)",
2929
org.eclipse.text;bundle-version="[3.5.0,4.0.0)"

plugins/org.eclipse.emf.ecore.xcore/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Bundle-SymbolicName: org.eclipse.emf.ecore.xcore;singleton:=true
99
Bundle-Activator: org.eclipse.emf.ecore.xcore.XcorePlugin$Implementation
1010
Bundle-ActivationPolicy: lazy
1111
Require-Bundle: org.eclipse.xtext;bundle-version="[2.13.0,3.0.0)";visibility:=reexport,
12-
org.eclipse.emf.ecore;bundle-version="[2.38.0,3.0.0)";visibility:=reexport,
12+
org.eclipse.emf.ecore;bundle-version="[2.39.0,3.0.0)";visibility:=reexport,
1313
org.eclipse.xtext.util;bundle-version="[2.18.0,3.0.0)",
1414
org.antlr.runtime;bundle-version="[3.2.0,3.2.1)",
1515
org.eclipse.xtext.xbase;bundle-version="[2.18.0,3.0.0)";visibility:=reexport,

plugins/org.eclipse.emf.ecore/META-INF/MANIFEST.MF

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,27 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: %pluginName
44
Bundle-SymbolicName: org.eclipse.emf.ecore;singleton:=true
5-
Bundle-Version: 2.38.0.qualifier
5+
Bundle-Version: 2.39.0.qualifier
66
Bundle-ClassPath: .
77
Bundle-Activator: org.eclipse.emf.ecore.plugin.EcorePlugin$Implementation$Activator
88
Bundle-Vendor: %providerName
99
Bundle-Localization: plugin
1010
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
11-
Export-Package: org.eclipse.emf.ecore;version="2.38.0",
12-
org.eclipse.emf.ecore.impl;version="2.38.0",
13-
org.eclipse.emf.ecore.plugin;version="2.38.0",
14-
org.eclipse.emf.ecore.resource;version="2.38.0",
15-
org.eclipse.emf.ecore.resource.impl;version="2.38.0",
16-
org.eclipse.emf.ecore.util;version="2.38.0",
17-
org.eclipse.emf.ecore.xml.namespace;version="2.38.0",
18-
org.eclipse.emf.ecore.xml.namespace.impl;version="2.38.0",
19-
org.eclipse.emf.ecore.xml.namespace.util;version="2.38.0",
20-
org.eclipse.emf.ecore.xml.type;version="2.38.0",
21-
org.eclipse.emf.ecore.xml.type.impl;version="2.38.0",
22-
org.eclipse.emf.ecore.xml.type.internal;version="2.38.0",
23-
org.eclipse.emf.ecore.xml.type.util;version="2.38.0"
11+
Export-Package: org.eclipse.emf.ecore;version="2.39.0",
12+
org.eclipse.emf.ecore.impl;version="2.39.0",
13+
org.eclipse.emf.ecore.plugin;version="2.39.0",
14+
org.eclipse.emf.ecore.resource;version="2.39.0",
15+
org.eclipse.emf.ecore.resource.impl;version="2.39.0",
16+
org.eclipse.emf.ecore.util;version="2.39.0",
17+
org.eclipse.emf.ecore.xml.namespace;version="2.39.0",
18+
org.eclipse.emf.ecore.xml.namespace.impl;version="2.39.0",
19+
org.eclipse.emf.ecore.xml.namespace.util;version="2.39.0",
20+
org.eclipse.emf.ecore.xml.type;version="2.39.0",
21+
org.eclipse.emf.ecore.xml.type.impl;version="2.39.0",
22+
org.eclipse.emf.ecore.xml.type.internal;version="2.39.0",
23+
org.eclipse.emf.ecore.xml.type.util;version="2.39.0"
2424
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.9.0,4.0.0)";resolution:=optional;x-installation:=greedy,
25-
org.eclipse.emf.common;bundle-version="[2.40.0,3.0.0)";visibility:=reexport,
25+
org.eclipse.emf.common;bundle-version="[2.41.0,3.0.0)";visibility:=reexport,
2626
org.eclipse.core.resources;bundle-version="[3.8.0,4.0.0)";resolution:=optional
2727
Provide-Capability: org.eclipse.emf.ecore.generated_package;uri="http://www.eclipse.org/emf/2002/Ecore";class=org.eclipse.emf.ecore.EcorePackage;genModel="model/Ecore.genmodel",
2828
org.eclipse.emf.ecore.generated_package;uri="http://www.w3.org/XML/1998/namespace";class=org.eclipse.emf.ecore.xml.namespace.XMLNamespacePackage;genModel="model/XMLNamespace.genmodel",

plugins/org.eclipse.emf.ecore/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<groupId>org.eclipse.emf</groupId>
1414
<artifactId>org.eclipse.emf.ecore</artifactId>
15-
<version>2.38.0-SNAPSHOT</version>
15+
<version>2.39.0-SNAPSHOT</version>
1616
<packaging>eclipse-plugin</packaging>
1717

1818
</project>

plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/plugin/EcorePlugin.java

Lines changed: 65 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@
5555
import org.eclipse.emf.ecore.EPackage;
5656
import org.eclipse.emf.ecore.impl.EPackageRegistryImpl;
5757
import org.eclipse.emf.ecore.resource.URIConverter;
58+
import org.osgi.framework.Bundle;
5859
import org.osgi.framework.BundleActivator;
5960
import org.osgi.framework.BundleContext;
61+
import org.osgi.framework.BundleException;
6062

6163

6264
/**
@@ -586,6 +588,7 @@ public static Map<String, URI> getEPackageNsURIToDynamicModelLocationMap(boolean
586588
*/
587589
static public class Implementation extends EclipsePlugin
588590
{
591+
private ManifestEPackageTracker ePackageTracker;
589592
/**
590593
* Creates the singleton instance.
591594
*/
@@ -658,6 +661,26 @@ public void start(BundleContext context) throws Exception
658661
super.start(context);
659662
ExtensionProcessor.internalProcessExtensions();
660663

664+
ePackageTracker = new ManifestEPackageTracker(context);
665+
ePackageTracker.open();
666+
667+
for (Bundle bundle : context.getBundles())
668+
{ // Ensure Manifest-declared EPackages are registered for all tracked bundles immediately (Bundle-tracker adds some asynchronously)
669+
if ((bundle.getState() & ManifestEPackageTracker.TRACKED_BUNDLE_STATES) != 0)
670+
{
671+
ManifestEPackageTracker.registerManifestEPackagesIfAbsent(bundle);
672+
}
673+
}
674+
}
675+
676+
@Override
677+
public void stop(BundleContext context) throws Exception
678+
{
679+
super.stop(context);
680+
if (ePackageTracker != null)
681+
{
682+
ePackageTracker.close();
683+
}
661684
}
662685

663686
/**
@@ -840,6 +863,8 @@ public IExtensionRegistry getRegistry()
840863
// Process the extension for the registry.
841864
//
842865
ExtensionProcessor.internalProcessExtensions();
866+
867+
ExtensionProcessor.internalProcessManifests(classLoader);
843868
}
844869
}
845870

@@ -910,12 +935,47 @@ protected boolean readElement(IConfigurationElement element)
910935
new ConversionDelegateFactoryRegistryReader().readRegistry();
911936
new AnnotationValidatorRegistryReader().readRegistry();
912937
}
938+
939+
private static void internalProcessManifests(ClassLoader classLoader)
940+
{
941+
if (!IS_OSGI_RUNNING)
942+
{ // not in a OSGi runtime, process raw MANIFEST.MF
943+
try
944+
{
945+
List<URI> manifests = getManifests(classLoader);
946+
for (URI manifest : manifests)
947+
{
948+
ManifestEPackageTracker.registerManifestEPackagesIfAbsent(manifest, classLoader);
949+
}
950+
}
951+
catch (IOException | BundleException e)
952+
{
953+
INSTANCE.log(e);
954+
}
955+
}
956+
}
913957
}
914958

915959
/**
916960
* Determine all the available plugin.xml resources.
917961
*/
918962
private static List<URI> getPluginXMLs(ClassLoader classLoader)
963+
{
964+
return getClasspathResource(classLoader, "plugin.xml");
965+
}
966+
967+
/**
968+
* Determine all the available {@code META-INF/MANIFEST.MF} resources.
969+
*/
970+
private static List<URI> getManifests(ClassLoader classLoader)
971+
{
972+
return getClasspathResource(classLoader, "META-INF/MANIFEST.MF");
973+
}
974+
975+
/**
976+
* Determine all the available plugin.xml resources.
977+
*/
978+
private static List<URI> getClasspathResource(ClassLoader classLoader, String resourcePath)
919979
{
920980
List<URI> result = new ArrayList<URI>();
921981

@@ -958,13 +1018,13 @@ private static List<URI> getPluginXMLs(ClassLoader classLoader)
9581018
{
9591019
// Determine if there is a plugin.xml at the root of the folder.
9601020
//
961-
File pluginXML = new File(file, "plugin.xml");
1021+
File pluginXML = new File(file, resourcePath);
9621022
if (!pluginXML.exists())
9631023
{
9641024
// If not, check if there is one in the parent folder.
9651025
//
9661026
File parentFile = file.getParentFile();
967-
pluginXML = new File(parentFile, "plugin.xml");
1027+
pluginXML = new File(parentFile, resourcePath);
9681028
if (pluginXML.isFile())
9691029
{
9701030
// If there is, then we have plugin.xml files that aren't on the classpath.
@@ -975,7 +1035,7 @@ else if (parentFile != null)
9751035
{
9761036
// The parent has a parent, check if there is one in the parent's parent folder.
9771037
//
978-
pluginXML = new File(parentFile.getParentFile(), "plugin.xml");
1038+
pluginXML = new File(parentFile.getParentFile(), resourcePath);
9791039
if (pluginXML.isFile())
9801040
{
9811041
// If there is, then we have plugin.xml files that aren't on the classpath.
@@ -1014,7 +1074,7 @@ else if (file.isFile())
10141074
// Look for a plugin.xml entry...
10151075
//
10161076
jarFile = new JarFile(classpathEntry);
1017-
ZipEntry entry = jarFile.getEntry("plugin.xml");
1077+
ZipEntry entry = jarFile.getEntry(resourcePath);
10181078
if (entry != null)
10191079
{
10201080
// If we find one, create a URI for it.
@@ -1052,7 +1112,7 @@ else if (file.isFile())
10521112
result.clear();
10531113
try
10541114
{
1055-
for (Enumeration<URL> resources = classLoader.getResources("plugin.xml"); resources.hasMoreElements(); )
1115+
for (Enumeration<URL> resources = classLoader.getResources(resourcePath); resources.hasMoreElements(); )
10561116
{
10571117
// Create a URI for each plugin.xml found by the class loader.
10581118
//

0 commit comments

Comments
 (0)