[generator] get rid of hard dependency to org.eclipse.xtext.ecore

This commit is contained in:
Sven Efftinge 2016-05-13 10:41:09 +02:00
parent 937f675950
commit 6d3c086477
2 changed files with 9 additions and 3 deletions

View file

@ -11,7 +11,6 @@ Require-Bundle: org.eclipse.xtext;x-installation:=greedy,
org.eclipse.xtext.util;x-installation:=greedy,
org.eclipse.xtext.xbase.lib;visibility:=reexport;x-installation:=greedy,
org.eclipse.xtend.lib,
org.eclipse.xtext.ecore,
org.eclipse.emf.codegen.ecore;bundle-version="2.10.2";visibility:=reexport;x-installation:=greedy,
org.eclipse.emf.ecore;bundle-version="2.10.2",
org.eclipse.emf.common;bundle-version="2.10.1",

View file

@ -16,7 +16,6 @@ import org.eclipse.emf.ecore.EPackage
import org.eclipse.emf.ecore.resource.ResourceSet
import org.eclipse.emf.mwe.utils.GenModelHelper
import org.eclipse.emf.mwe.utils.StandaloneSetup
import org.eclipse.xtext.ecore.EcoreSupportStandaloneSetup
import org.eclipse.xtext.resource.IResourceServiceProvider
import org.eclipse.xtext.util.internal.Log
import org.eclipse.emf.ecore.EcorePackage
@ -65,7 +64,15 @@ class XtextGeneratorResourceSetInitializer {
case 'ecore': {
val resourceServiceProvider = IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(loadedResource)
if (resourceServiceProvider === null) {
EcoreSupportStandaloneSetup.setup()
try {
val xcore = Class.forName('org.eclipse.xtext.ecore.EcoreSupportStandaloneSetup')
xcore.getDeclaredMethod('doSetup', #[]).invoke(null)
} catch (ClassNotFoundException e) {
LOG.error("Couldn't initialize Ecore support. Is 'org.eclipse.xtext.ecore' on the classpath?")
LOG.debug(e.getMessage(), e)
} catch (Exception e) {
LOG.error("Couldn't initialize Ecore support.", e)
}
}
}
case 'xcore': {