This is an example project illustrating how the Context Mapper DSL (CML) language can be used as standalone library outside the Eclipse IDE.
The Context Mapper DSL library releases are available via the Maven central repository and can therefore be integrated within your Maven or Gradle builds.
Gradle:
implementation 'org.contextmapper:context-mapper-dsl:6.8.0'
Maven:
<dependency>
<groupId>org.contextmapper</groupId>
<artifactId>context-mapper-dsl</artifactId>
<version>6.8.0</version>
</dependency>
If you want to use our SNAPSHOT's built from the master branch (context-mapper-dsl) you have to use the following repository: https://oss.sonatype.org/content/repositories/snapshots
This example project is built with Gradle. Have a look at build.gradle how it is configured. With the Xtext builder plugin you ensure that your CML files are compiled at build time.
The CML models are configured to be in the source folder src/main/cml (see build.gradle). This example project contains the insurance example model (./src/main/cml/Insurance-Example-Model.cml) which can also be found in our examples repository.
This example project contains the following example classes written in Java which illustrate how to use CML models and our generators:
- ReadingModelExample: Example how to read the CML model
- ChangingModelExample: Illustrates how a model can be changed an then unparsed back to the CML file.
- PlantUMLGeneratorExample: Shows how you can read your CML model and generate the PlantUML diagrams out of it easily.
- MDSLGeneratorExample: Shows how to generate the MDSL contracts out of the CML model.
- GenericGeneratorExample: Illustrates how you can use Freemarker templates to generate arbitrary textual files out of your Context Map.
For details about the generators and the CML language please consult our online documentation (currently we have no further documentation how to use the tools on code level in standalone applications). If you have questions how to use specific features within your standalone Java application don't hesitate to create an issue or contact us.
This example project also contains a jar
that can be used from a CLI. To use it, you can build the project using any IDE, and use the generated jar
. The available arguments are:
-f,--file <arg> CML file
-o,--output <arg> output folder
-p,--template <arg> freemarker template
-t,--type <arg> type of generator
The file
and type
arguments are mandatory. If you don't specify an output
it uses src-gen
folder.
The type
of generators available are:
contextmap
generic
mdsl
plantuml
As example, to run from a command line:
java -jar context-mapper-standalone-example-1.0.0-SNAPSHOT.jar -f Insurance-Example-Model.cml -t contextmap
Contribution is always welcome! Here are some ways how you can contribute:
- Create Github issues if you find bugs or just want to give suggestions for improvements.
- This is an open source project: if you want to code, create pull requests from forks of this repository. Please refer to a Github issue if you contribute this way.
- If you want to contribute to our documentation and user guides on our website https://contextmapper.org/, create pull requests from forks of the corresponding page repo https://github.com/ContextMapper/contextmapper.github.io or create issues there.
ContextMapper is released under the Apache License, Version 2.0.