-
Notifications
You must be signed in to change notification settings - Fork 54
Getting Started Building Your Own Project
LearnLib uses Apache Maven as the build management tool, and we strongly advise you to do the same for your projects using LearnLib. Most importantly, Maven significantly eases dependency management, which can become quite a hassle especially with very modular projects such as LearnLib. This short article will help you getting started in just a few steps.
Maven can be obtained from this page. We recommend using the most recent stable version.
A very simple way to set up a new project is using the archetype plugin. Just enter the following command on the command line:
mvn archetype:generate -DarchetypeGroupId=de.learnlib.archetypes -DarchetypeArtifactId=typical
This will start the interactive process of generating a new project. You will be prompted for the following information:
- Archetype version (possibly omitted): You will see a list of available versions, enter the corresponding number or just hit enter to select the default (most recent) version of the archetype.
- Value for
groupId
: This serves as the group identifier of your Maven project, it should be in a form similar to Java packages, such asorg.examples
- Value for
artifactId
: This serves as the group-local identifier of your Maven project. It should be in a very simple, all-lowercase form, such asmy-project
. - Value for
version
: The (initial) version of your project. The default is1.0-SNAPSHOT
. - Value for
package
: The name of your root package. The default is thegroupId
you entered before.
Your command prompt might then look similar to the following:
Define value for property 'groupId': : org.example
Define value for property 'artifactId': : my-project
Define value for property 'version': 1.0-SNAPSHOT: :
Define value for property 'package': org.example: :
[INFO] Using property: learnlibVersion = 0.9-SNAPSHOT
Confirm properties configuration:
groupId: org.example
artifactId: my-project
version: 1.0-SNAPSHOT
package: org.example
learnlibVersion: 0.9-SNAPSHOT
Y: :
You will notice the INFO
message about the property learnlibVersion
. This controls which version of LearnLib will be used for your project. If you want to change this version (which is not recommended, as the archetypes are only guaranteed to work properly with the respective version of LearnLib they are shipped with), enter N
now. You will have to re-enter the information, but in addition will be given the opportunity to also specify the learnlibVersion
property. If the displayed settings finally are correct, just hit enter in the Y: :
prompt.
Y: : N
Define value for property 'groupId': : org.example
Define value for property 'artifactId': : my-project
Define value for property 'version': 1.0-SNAPSHOT: :
Define value for property 'package': org.example: :
Define value for property 'learnlibVersion': 0.9-SNAPSHOT: :
Confirm properties configuration:
groupId: org.example
artifactId: my-project
version: 1.0-SNAPSHOT
package: org.example
learnlibVersion: 0.9-SNAPSHOT
Y: :
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: typical:0.9-SNAPSHOT
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: org.example
[INFO] Parameter: artifactId, Value: my-project
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: org.example
[INFO] Parameter: packageInPathFormat, Value: org/example
[INFO] Parameter: package, Value: org.example
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: groupId, Value: org.example
[INFO] Parameter: learnlibVersion, Value: 0.9-SNAPSHOT
[INFO] Parameter: artifactId, Value: my-project
[INFO] project created from Archetype in dir: .../my-projectt
The directory specified in the last line (which is the subdirectory named as the artifactId
of the current working directory) will then contain your new Maven project. The NetBeans and IntelliJ IDEA IDEs natively support Maven projects in their more recent versions. For Eclipse, a Maven plugin is available. Alternatively, you can generate an Eclipse project from your Maven project by running
mvn eclipse:eclipse
in the root directory of your project, and then importing it into Eclipse as an existing project.
The archetype plugin can also be used in non-interactive mode, specifying all required (and possibly optional) options directly on the command line:
mvn archetype:generate \
-DinteractiveMode=false \ # non-interactive mode
-DarchetypeGroupId=de.learnlib.archetypes \
-DarchetypeArtifactId=typical \
-DarchetypeVersion=0.9-SNAPSHOT \ # optional
-DgroupId=org.example \
-DartifactId=my-project \
-Dversion=1.0-SNAPSHOT \ # optional
-DlearnlibVersion=0.9-SNAPSHOT # optional
The above examples made use of the typical
archetype, but also other archetypes are available:
-
core
: A minimal setup, consisting only oflearnlib-core
plus its (transitive) dependencies. -
typical
: A typical setup, comprising various components which are typically used for automata learning applications, such as a learning algorithm (lstar-generic
), a cache filter, basic equivalence tests etc. -
complete
: A setup containing all LearnLib modules as dependencies.
The archetype plugin can not only be used to create new Maven projects, but also to extend existing Maven projects. When run from within an existing project's directory, the above mvn
command will modify the project files, adding all the currently missing information that would be present in a newly created Maven project.