Maven - Heigvd/Wegas GitHub Wiki

Maven

We use maven 3.6.

You need to install maven in your computer.

What it is

Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information. It provides a way to help with managing:

  • Builds
  • Documentation
  • Reporting
  • Dependencies
  • SCMs
  • Releases
  • Distribution

Links

Structure

In Wegas, the main project (= module) is wegas-project. It contains multiple modules : build-tools, wegas-core, wegas-ts-api, wegas-app, wegas-resources, wenerator-maven-plugin, wegas-runtime, wegas-annotation (the sorting is important to handle the dependencies). This structure allow to build everything with one call at wegas-project level.

All projects have a clear folder structure used by maven.

Each module has a pom.xml file to configure maven.

Some modules have a src/site/site.xml file to configure the reporting.

Build

  • mvn install -DskipTests to compile and build but without launching all tests
  • mvn install -DskipPrivateTests to compile and build but without launching the tests that have a PrivateRelatedTest annotation
  • mvn install to compile, build and launch the tests
  • mvn clean install to clean the target folder, compile, build and launch the tests

Test

  • mvn test to run the tests
  • mvn test -pl wegas-core -Dtest=xxxTest to run a specific test

Dependencies

see maven documentation.

The dependencies are locally stored in a .m2 folder at root.

The dependency management section is a mechanism for centralizing dependency information. When you have a set of projects that inherit from a common parent, it's possible to put all information about the dependency in the common POM and have simpler references to the artifacts in the child POMs. wegas-project pom.xml defines the version of all the dependencies for all modules in the dependencyManagement.

Reporting

  • mvn site to generate a reporting site. It is available in target/site

Cheat sheet & tricks

Add -pl wegas-core by example to run the maven command only in the wegas-core module. To get info about a goal, run something like mvn compiler:help -Ddetail=true -Dgoal=compile

In IntelliJ

Maven tool window (View -> Tool Windows -> Maven).

Dependency Analyzer editor (from Maven tool window > right-click on a Dependency > Analyze Dependencies... ).

There are actions for pom.xml files (right-click > Maven > ...).