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
- https://mvnrepository.com/ indexes the Maven repositories, providing developers with a fast and easy way to search for packages and their dependencies.
- https://maven.apache.org/
- https://maven.apache.org/guides/getting-started/index.html
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 -DskipTeststo compile and build but without launching all testsmvn install -DskipPrivateTeststo compile and build but without launching the tests that have aPrivateRelatedTestannotationmvn installto compile, build and launch the testsmvn clean installto clean thetargetfolder, compile, build and launch the tests
Test
mvn testto run the testsmvn test -pl wegas-core -Dtest=xxxTestto 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 siteto generate a reporting site. It is available intarget/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 > ...).