Usually, when deploying a code for a given metamodel, we deploy this metamodel in a EMF plugin that contains the generated java code for this metamodel. When using this, Eclipse takes care of registering the EPackage in its registry.
If for some reason you don't want to deploy the java version of the metamodel, you can also manually register it directly from an ecore file.
In the graphical interface, this will be done by
right click on the ecore file > EPackage registration > Register EPackage into repository
.
If you need to add an ecore file into the registry programmatically, you can do it in two ways:
In kermeta, use the registerEcoreFile
(fileUri
: String) operation provided by
kermeta::persistence::EMFRepository
kermeta::persistence::EMFRepository.new.registerEcoreFile("MyMetamodel.ecore")
In java, use the API provided by the org.eclipse.emf.ecoretools.registration
plugin.
import org.eclipse.emf.ecoretools.registration.EcoreRegistering; // ... EcoreRegistering.registerPackages(anEcoreIFile);
Note | |
---|---|
despite the name of this plugin, it is provided by kermeta team, this was an attempt to contribute to ecore tools project, but this contribution is still in the pipeline in Eclipse :-( |