Modelant publishes a Maven plugin that compares two models written in MOF 1.4. The regular practice is to use such models as metamodels - definitions of other modeling languages. Thus, changes in the MOF 1.4 metamodels define the changes in the modeling languages. As an example, the differences between UML 1.3 and UML 1.4 metamodels, define the UML 1.4 language changes since UML 1.3.
The goal compare-mof14-metamodels of the net.mdatools:modelant.mof14.maven:3.1.0 plugin compares two models and reports the differences, that are needed to convert the source model into the target one.
Below are provided two usage scenarios
Both MOF 1.4 models are provided in as files. The simplest way to compare them is just to provide the path to them. The plugin will report the detected changes in a basic form:
<plugin> <groupId>net.mdatools</groupId> <artifactId>modelant.mof14.maven.plugin</artifactId> <version>3.3.0</version> <executions> <execution> <phase>compile</phase> <goals> <goal>compare-mof14-metamodels</goal> </goals> <configuration> <sourceMetamodel>src/resource/01-12-02_Diff_modelant.xml</sourceMetamodel> <targetMetamodel>src/resource/01-02-15_Diff_modelant.xml</targetMetamodel> </configuration> </execution> </executions> </plugin>
where:
Compare the UML 1.4 and UML 1.4 found as local files (see the plugin test):
<build> <plugins> <plugin> <groupId>net.mdatools</groupId> <artifactId>modelant.mof14.maven.plugin</artifactId> <version>3.3.0</version> <executions> <execution> <phase>compile</phase> <goals> <goal>compare-mof14-metamodels</goal> </goals> <configuration> <sourceMetamodel>src/resource/01-12-02_Diff_modelant.xml</sourceMetamodel> <targetMetamodel>src/resource/01-02-15_Diff_modelant.xml</targetMetamodel> <export implementation="net.mdatools.modelant.core.operation.model.export.StructuredTextExport"/> </configuration> </execution> </executions> </plugin> </plugins> </build>
As a result, a huge number of changes from UML 1.3 to UML 1.4 is reported. It reveals that some UML 1.3 components are just moved or renamed in UML 1.4, so the comparison algorithm may benefit from pre-defined correspondence of some model elements.
In this example the MOF 1.4 ModelElement in the source model with name “Data_Types”, found in the ModelElement with name “Foundation” (as a namespace) corresponds to the MOF 1.4 ModelElement in the target model, named “Data_Types”. The resported outcome is in a JSON-like format.
<build> <plugins> <plugin> <groupId>net.mdatools</groupId> <artifactId>modelant.mof14.maven.plugin</artifactId> <version>${revision}</version> <executions> <execution> <phase>compile</phase> <goals> <goal>compare-metamodels</goal> </goals> <configuration> <sourceMetamodel>...</sourceMetamodel> <targetMetamodel>...</targetMetamodel> <equals> <equal> <source>Foundation::Data_Types</source> <target>Data_Types</target> </equal> ... <export implementation="net.mdatools.modelant.core.operation.model.export.StructuredTextExport"/> </equals> </configuration> </execution> </executions> </plugin> </plugins> </build>
The outcome of model comparison formatted by net.mdatools.modelant.core.operation.model.export.StructuredTextExport is like:
{ deleted = {list of source model elements, that do not exist in the target model}, added = {list of target model elements, that do not exist in the source model}, changed = {list of pairs of corresponding source and target model elements, that have some of the attributes or associations changed}, exactMatch = {list of pairs of corresponding source and target model elements, that match exactly} }
Based on the report above, the changes from UML 1.3 to UML 1.4 are identified.