-
Notifications
You must be signed in to change notification settings - Fork 54
Including LearnLib in your Maven Build
If you are developing an application or library that uses LearnLib, we highly recommend you use Apache Maven as your build system. The following instructions show you how to tell Maven to automatically include LearnLib dependencies in your build.
Note: If you are using a different build system capable of handling Maven dependencies (such as Apache Ivy or Gradle), it should be easily possible to apply the following to your configuration.
We assume that you already have an existing Maven project in which you want to include LearnLib. If you don't, check out this article.
We generally recommend that you set the LearnLib version in the properties
section of your POM. Even though you only have to type it once, it is generally nicer to have all the dependency versions in one place. However, it is also possible to skip this step and include it directly in the dependency
entry.
Open your POM, and go to the <properties>
section. If your POM does not have any properties set yet, create a new <properties>
section (it is recommended to place it after your POM coordinates such as name, description etc., and before the <build>
section). Add the following property.
<properties>
<!-- ... other properties ... -->
<learnlib.version>0.9.1</learnlib.version>
<!-- ... more other properties ... -->
</properties>
The most convenient way of telling Maven about the LearnLib artifacts you might want to use is by using managed dependencies. You can easily import all <dependency>
descriptors for all modules of LearnLib plus their dependent libraries. If you are also using artifacts from libraries LearnLib depends on (such as AutomataLib or Guava), you can omit the <version>
tag in your dependency descriptor. This greatly reduces the risk of accidentially causing problems due to version mismatches.
Go to the <dependencyManagement>
section of your POM (or create one, it should go right after your <build>
section) and paste the following. If you are creating a multi-module build, you should put this in the <dependencyManagement>
of your parent POM, regardless of which modules are actually using LearnLib artifacts.
<dependencyManagement>
<dependencies>
<!-- ... other dependencies ... -->
<dependency>
<groupId>de.learnlib</groupId>
<artifactId>learnlib-parent</artifactId>
<version>${learnlib.version}</version> <!-- or directly set the version number here -->
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- ... dependencies ... -->
</dependencies>
</dependencyManagement>
This will tell maven to import all dependencies defined in the <dependencyManagement>
section of the LearnLib Parent POM to your POM dependency management.
Finally, include dependencies to concrete LearnLib artifacts (see List of LearnLib Artifacts) in the POM of your project (or the POM of the respective submodule). You can also add dependencies to artifacts LearnLib depends on, such as AutomataLib artifacts or Guava. Maven will automatically use the same dependency version as used by LearnLib (unless this is overridden by you in the <dependencyManagement>
section).
<dependencies>
<!-- ... other dependencies ... -->
<!-- LearnLib core dependencies -->
<dependency>
<groupId>de.learnlib</groupId>
<artifactId>learnlib-api</artifactId>
<!-- Note: no version specification required! -->
</dependency>
...
<!-- Example: AutomataLib Core dependency -->
<dependency>
<groupId>net.automatalib</groupId>
<artifactId>automata-core</artifactId>
</dependency>
<!-- Example: Guava dependency -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<!-- ... more other dependencies ... -->
</dependencies>