Skip to content

chains-project/maven-module-graph

Repository files navigation

You will remember me when computing metrics for Java dataset

Counting the number of Maven modules is a must-do if you are working on Java research. This metric helps to assess the complexity of the projects selected for study.

Googling "how to count maven module maven project" resulted in the following StackOverflow post:

However, none of the solutions provided in the post worked for me well.

Let's try current solutions on handlebars.java v4.2.1

mvn -Dexec.executable='echo' -Dexec.args='${project.artifactId}' exec:exec -q

TLDR: 1) maven based solutions are too slow 2) build must pass

Output:

handlebars.java
handlebars
handlebars-helpers
handlebars-springmvc
handlebars-jackson2
handlebars-markdown
handlebars-humanize
handlebars-proto
handlebars-guava-cache
handlebars-maven-plugin
handlebars-maven-plugin-tests

Time:

real 4.30
user 17.33
sys 1.06
find -name pom.xml | grep -v target | sort
  1. Great to count number of modules, but won't give GAV coordinates.
  2. Is prone to error since some pom.xml may not be part of reactor. Eg, spoon has many modules but they are not submodules.

Others did not work for me :) Please correct me if I am wrong.

Our solution

./gradlew build
java -jar build/libs/maven-module-graph-1.0-SNAPSHOT.jar \
  --project-root <path/to/maven/project/root> \
  --json <path/to/output.json> \
  --plain-text <path/to/output.txt>

TLDR: 1) extremely fast, 2) provides GAV coordinates, 3) provides a graph in JSON format

I wanted to learn Gradle so I built using Gradle.

Output:

com.github.jknack:handlebars.java:4.2.1
  com.github.jknack:handlebars-maven-plugin-tests:4.2.1
  com.github.jknack:handlebars-maven-plugin:4.2.1
  com.github.jknack:handlebars-guava-cache:4.2.1
  com.github.jknack:handlebars-proto:4.2.1
  com.github.jknack:handlebars-humanize:4.2.1
  com.github.jknack:handlebars-markdown:4.2.1
  com.github.jknack:handlebars-jackson2:4.2.1
  com.github.jknack:handlebars-springmvc:4.2.1
  com.github.jknack:handlebars-helpers:4.2.1
  com.github.jknack:handlebars:4.2.1

Time:

real 0.31
user 0.52
sys 0.07

About

Listing and Counting Maven (sub)modules.

Resources

Stars

Watchers

Forks

Languages