Monday 14 December 2020

Maven Tips

Maven Tips Link

https://dzone.com/articles/5-maven-tips

https://zeroturnaround.com/rebellabs/your-maven-build-is-slow-speed-it-up/

https://zeroturnaround.com/rebellabs/maven-cheat-sheet/

Helpful Maven Build Commands

  1.  Resume Build
    mvn -rf <module-name> clean install
  2. Parallel Builds
    mvn -T <no. of Threads> install
    mvn -T <no. of CPU Cores>C install
  3. Build Selective Modules
    mvn -pl <module-name1>,<module-name2> clean install
  4. Build Selective Module and its dependencies
    mvn install -pl <module-name> -am
  5. Build Selective Module and its dependents
    mvn install -pl <module-name> -amd
  6. Build Selective Module and its dependents at the same time exclude a dependent
    mvn install -pl <module-name>,!<dep-module-name> -amd

Few Skip Activities to Improve Build productivity in Maven

  1. Skip Unit Test
    mvn install -Dmaven.test.skip=true
  2. Skip FindBugs Analysis
    mvn install -Dfindbugs.skip=true
  3. Skip Online Build (Offline build)
    mvn -o install
  4. Skip Cleaning, only package or install
  5. Skip Unrequired Modules - By building selective modules.
  6. Skip Assembly (moving packages and other simple assemblies), If required.

Helpful Maven Analysis Commands

  1. Generate Dependency Tree - Finding the Dependencies
    mvn dependency:tree
  2. Generate Dependency Tree of a particular Module in MultiModule Project - Finding the Dependents
    mvn dependency:tree -Dincludes=<group-id>:<artifact:id>
    example:
    mvn -o dependency:tree -Dincludes=com.wildcraft:app -DappendOutput=true -DoutputType=dot -DoutputFile=C:/dependencyTree.dot
  3. Filter includes with LIKE option with * - Filtering the Dependents
    mvn dependency:tree -Dincludes=<group-id partial name>.*
    example:
    mvn -o dependency:tree -Dincludes=com.aris.* -DoutputType=dot -DoutputFile=dependencyTree.dot

Combine dot format in GraphViz

While checking list of dependents of a Module, one might required to combine various digraphs generated by maven with command - mvn -o dependency:tree -Dincludes=<module-name> -DappendOutput=true -DoutputType=dot -DoutputFile=<filepath>

GraphViz tool can be used to combine these multiple graphs with example command as below.

C:\Softwares\graphviz-2.38\bin>type C:\dependencyTree.dot | gvpack -u -o output.dot

Output file will be available at C:\Softwares\graphviz-2.38\bin

Meditation and 5 L

Relaxation and Laughter distinguishes being human and human being . Relaxation is meditation. May be it is a lie, but a beautiful one, whic...