-
-
Save xseignard/1253288 to your computer and use it in GitHub Desktop.
Headless EMF compare on Xtext models
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Launcher of this application. | |
* | |
* @param args | |
* Arguments of the launch. | |
*/ | |
public static void main(String[] args) { | |
// Models paths | |
String model1 = "path/to/my/model1.ext"; | |
String model2 = "path/to/my/model2.ext"; | |
// Creates the resourceSets where we'll load the models | |
final ResourceSet resourceSet1 = new ResourceSetImpl(); | |
final ResourceSet resourceSet2 = new ResourceSetImpl(); | |
// Register extensions through xtext setup. | |
MyStandaloneSetup.doSetup(); | |
// For each resourceSet, add the metamodel Package to the registry. | |
resourceSet1.getPackageRegistry().put(PodmlPackage.eNS_URI, PodmlPackage.eINSTANCE); | |
resourceSet2.getPackageRegistry().put(PodmlPackage.eNS_URI, PodmlPackage.eINSTANCE); | |
try { | |
System.out.println("Loading resources.\n"); //$NON-NLS-1$ | |
// Loads the two models | |
final EObject model1 = ModelUtils.load(new File(scrum1), resourceSet1); | |
final EObject model2 = ModelUtils.load(new File(scrum2), resourceSet2); | |
// Creates the match then the diff model for those two models | |
System.out.println("Matching models.\n"); //$NON-NLS-1$ | |
final MatchModel match = MatchService.doMatch(model2, model1, Collections | |
.<String, Object> emptyMap()); | |
System.out.println("Differencing models.\n"); //$NON-NLS-1$ | |
final DiffModel diff = DiffService.doDiff(match, false); | |
// Then print the diffs | |
for (DiffElement diffElement : diff.getDifferences()) { | |
System.out.println(diffElement); | |
} | |
} catch (final IOException e) { | |
// shouldn't be thrown | |
e.printStackTrace(); | |
} catch (final InterruptedException e) { | |
e.printStackTrace(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment