I want to compare two models which are compliant to a given ecore metamodel like this:
public void compare() {
URI uri1 = URI.createFileURI("file1.xmi");
URI uri2 = URI.createFileURI("file2.xmi");
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl());
ResourceSet resourceSet1 = new ResourceSetImpl();
ResourceSet resourceSet2 = new ResourceSetImpl();
resourceSet1.getResource(uri1, true);
resourceSet2.getResource(uri2, true);
IComparisonScope scope = new DefaultComparisonScope(resourceSet1, resourceSet2, null);
Comparison comparison = EMFCompare.builder().build().compare(scope);
List<Diff> differences = comparison.getDifferences();
// Let's merge every single diff
IMerger.Registry mergerRegistry = new IMerger.RegistryImpl();
IBatchMerger merger = new BatchMerger(mergerRegistry);
merger.copyAllLeftToRight(differences, new BasicMonitor());
}
If I run this code I get the error Package with uri '/uri/of/the/package' not found
, which is the URI of the metamodel. I tried to register the ecore model via right-click and then Register EPackages
, but it didn't worked out. What am I doing wrong?`How can I register the package (I prefer statically but dynamically would also work).