Skip to the content.

Utilisation de Maven Lite et description de toutes les fonctionnalités

Table des matières

List of Options

Basic Usage

Command Line

The command line is the classic way to use Maven Lite, although it is less convenient than using a configuration file.

You can include as many options as you want in any order.

Just place the arguments with spaces in quotes, for example, -args "your argument". On Windows, it is impossible to include the " character in arguments.

Example Command Line

Configuration File

The use of a configuration file is done with the --file or -f option.

The configuration file is unique to each project and configures the options that Maven Lite should use.

The default name of the configuration file is LPOM.conf and must be at the root of the project. You can rename it, but in that case, you need to specify its name when using the option, for example, mvnl -f myFile.extension.

If you want to add your system CLASSPATH to the Maven Lite CLASSPATH in the configuration file, use the term $CLASSPATH in uppercase.

You can include as many options as you want in any order.

Example Configuration File

Project Creation

The use of this option is done with the --create or -cr option.

It is impossible to create a project with a space in the name. It is impossible to create a project with a name that is already used by a file or folder.

You can create a project in the current folder with the following command:

mvnl --create ./

By default, the project name is NewProject, and the structure is as follows:

NewProject
├── LPOM.conf
├── src
│   ├── main
│   │   └── java
│   │       └── HelloWorld.java
│   └── resources
│       └── lib
└── target

Model-View-Controller

The use of this option is done with the --model-view-controller or -mvc option.

It allows specifying to the ‘--create’ option to create the structure of an MVC project.

Project Compilation

The use of this option is done with the --compilation or -c or --compile-launch or -cl or --launch-compile or -lc option.

This option allows compiling the project.

Project Launch

The use of this option is done with the --launch or -l or --compile-launch or -cl or --launch-compile or -lc option.

This option allows launching the project.

Quiet

The use of this option is done with the --quiet or -q option.

This option suppresses the display of java in the terminal during project execution.

Verbose

The use of this option is done with the --verbose or -v option.

This option displays the executed commands.

Exclusion of Files and Folders

The use of this option is done with the --exclude or -ex option.

This option allows excluding Java files and folders from the compilation.

If you want to exclude a folder, you should use the relative path of the folder from the project’s source folder and without using ./ or ../.

If you exclude a folder, all the files and folders it contains will also be excluded.

Note: If you exclude the test folder, all files or folders containing the word test in their name will also be excluded.

Compilation into a Jar File

The use of this option is done with the --compile-jar or -cj option.

This option allows creating an executable jar file of your project.

The naming conventions for jar files are as follows: <name>-<M>.<m>.<b>.jar.

Launching a Jar File

The use of this option is done with the --launch-jar or -lj option.

This option allows launching the executable jar file of your project.

Integration of Unit Tests

The use of this option is done with the --integrate-test or -it option.

This option allows integrating unit tests into the project, i.e., creating the unit test directory structure, unit test files, and also copying the jar files used by JUnit into the libraries folder.

If you use it together with the -cr or --create option, Maven Lite will create the unit test directory structure as well as a default test file containing a unit test for the main class.

If you use it after creating the project, Maven Lite will create the unit test directory structure as well as a unit test file for each Java file in the project.

Project Source

The use of this option is done with the --source or -s option.

This option allows specifying the folder containing the Java files to compile.

The source folder is not the root of the project but the first folder containing the Java files to compile. The Java files in this folder do not have a package.

Compiled Files Destination

The use of this option is done with the --target or -t option.

This option allows specifying the output folder for compiled files, the input folder for launch files, the output folder for jar files, and the input folder for .class files to include in the jar.

You don’t need to create the output folder for compiled files; Maven Lite will do it for you.

You don’t need to add the output folder for compiled files to the classpath; Maven Lite will do it for you.

Resources

The use of this option is done with the --resources or -r option.

This option allows specifying the folder containing resource files to be copied to the output folder for compiled files when creating a jar file.

Classpath

The use of this option is done with the --classpath or -cp option.

This option allows specifying the classpath to use during compilation and execution.

You can add the system classpath by using the term $CLASSPATH in uppercase in the configuration file.

In the command line, you can use the system classpath by using the term $CLASSPATH under Linux and MacOS. Under Windows, you can use the term %CLASSPATH%.

Libraries

The use of this option is done with the --libraries or -lib option.

This option allows specifying the folder containing the jar files used by the program. All jar files will be added to the classpath during compilation and execution.

You can create subfolders in the libraries folder to better organize your jar files, and Maven Lite will take them into account.

Arguments

The use of this option is done with the --arguments or -args option.

This option allows specifying all the arguments to pass to the main class of your project.

These arguments will be passed to the main class in the order they are passed to Maven Lite.

Note: Under Windows, it is impossible to use the character " in arguments passed in the command line, so it should be passed in the configuration file.

Example of using the Arguments option

Arguments in the command line

Command line under Linux and MacOS

Command line under Windows

// TODO: Verify that special characters work under Windows

Arguments in the configuration file

// TODO: Verify special characters

Main Class

The use of this option is done with the --main or -m option.

This option allows specifying the main class to be launched with the package in the form package.MainClass. This option is useful only if you have multiple main classes in your project; if not, Maven Lite will automatically find and use the main class of the project.

Encoding

The use of this option is done with the --encoding or -e option.

This option allows specifying the encoding of the Java files to compile.

Export

This option is used with the --export or -exp option.

This option allows creating an executable .class file configured for your project, enabling you to compile and run your project without installing Maven Lite.

The only options that the .class file accepts are the main class options, --arguments, -args, launch, and compilation options, --launch, -l, --compile, -c, --compile-launch, -cl, --launch-compile, -lc, and the config file option --file, -f, and that’s it. Other options will not be taken into account.

It is important to use the configuration file when using the --export or -exp option because it specifies the parameters that the executable .class file will use.

The purpose of this option is to be able to launch your project via a single file without arguments and without having to install Maven Lite. This allows people who do not have Maven Lite to use your project.

Convert to Maven Project

This option is used with the --maven or -mvn option.

This option allows converting your project to a Maven project by creating a pom.xml file and moving files if necessary.

Voici la traduction en anglais :

Language

The use of this option is done with the -lang or --language option.

This option allows displaying the available languages for Maven Lite if used alone.

If you use this option with a language, Maven Lite will use that language to display messages.

This option is persistent, meaning that if you use it once, Maven Lite will continue using this language to display messages until you change the language again.

Version

This option is used with the --version or -V option.

This option displays the version of Maven Lite as well as the location of the main Maven Lite file, Java version, build type, Java runtime used, system language, encoding platform used by Maven Lite, operating system name, operating system kernel version, and system architecture.

Help

This option is used with the --help or -h option.

This option displays the list of options along with their description, the number of arguments they take, and their default value if they have one, as well as a link to the documentation.

Clear Compiled Files

This option is used with the --clear or -clr option.

This option allows deleting all files in the output folder for compiled files. This option frees up disk space and ensures a clean jar file.

Example, Features, and Limitations