-
Notifications
You must be signed in to change notification settings - Fork 54
Setting Up a New Maven Project (Command Line)
Maven Archetypes are the most convenient way of creating your own (Maven) projects that use LearnLib. On this page, we will explain how you set up your own project using the Maven via the command line.
We assume that you have a sufficiently recent version of Maven 3 installed, and that you are familiar with a command line shell (such as bash).
To create a new Maven project from an archetype using typical LearnLib dependencies, simply enter the following command in your shell:
mvn archetype:generate \
-DarchetypeGroupId=de.learnlib.archetypes \
-DarchetypeArtifactId=complete \
-DarchetypeVersion=<learnlib.version>
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.example.learnlib
- 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.learnlib
Define value for property 'artifactId': : my-project
Define value for property 'version': 1.0-SNAPSHOT: :
Define value for property 'package': org.example.learnlib: :
[INFO] Using property: learnlibVersion = 0.13.1
Confirm properties configuration:
groupId: org.example
artifactId: my-project
version: 1.0-SNAPSHOT
package: org.example
learnlibVersion: 0.13.1
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.13.1: :
Confirm properties configuration:
groupId: org.example
artifactId: my-project
version: 1.0-SNAPSHOT
package: org.example
learnlibVersion: 0.13.1
Y: :
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: complete:0.13.1
[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.13.1
[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 which is shipped with the bundled Eclipse for Java Developers, or can be installed separately. 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=complete \
-DarchetypeVersion=<learnlib.version> \
-DgroupId=org.example \
-DartifactId=my-project \
-Dversion=1.0-SNAPSHOT \ # optional
-DlearnlibVersion=0.13.1 # optional
In this example, we used the complete
archetype. See the List of LearnLib Artifacts page for an overview of other archetypes.