Maven Guide - nicho92/MtgDesktopCompanion GitHub Wiki

pom.xml Usage Guide

This guide explains how the project's pom.xml is organized and which Maven goals are the most useful when working on MTG Desktop Companion.

1) What pom.xml does in this project

The pom.xml defines:

  • project identity (groupId, artifactId, version, packaging)
  • Java version (25)
  • dependencies (runtime, build-time, test)
  • Maven plugins used during the build lifecycle

In this repository, the main packaging output is a JAR, and the build also prepares an executable layout and a ZIP archive through dedicated plugins.


2) Standard Maven lifecycle commands

These goals are part of the standard Maven lifecycle and are used most often:

  • mvn clean: removes previous build artifacts (target/)
  • mvn compile: compiles source code
  • mvn test: runs tests
  • mvn package: creates packaging artifacts (JAR + configured assemblies)
  • mvn install: installs the artifact into the local Maven repository (~/.m2)

Recommended local command:

mvn clean install

Faster build without running tests:

mvn -DskipTests clean install

3) Plugin goals available in this pom.xml

A. Code formatting — spotless-maven-plugin

Plugin: com.diffplug.spotless:spotless-maven-plugin

Useful goals:

  • spotless:check: verifies formatting without changing files
  • spotless:apply: auto-applies formatting (imports, whitespace, etc.)

Examples:

mvn spotless:check
mvn spotless:apply

B. Dependency analysis — maven-dependency-plugin

Plugin: org.apache.maven.plugins:maven-dependency-plugin

Useful diagnostic goals:

  • dependency:tree: prints the dependency tree
  • dependency:analyze: detects potentially unused/missing dependencies
  • dependency:copy-dependencies: copies dependencies to a local directory

Examples:

mvn dependency:tree
mvn dependency:analyze

C. Compilation — maven-compiler-plugin

Plugin: org.apache.maven.plugins:maven-compiler-plugin

In this project, the plugin has a specific execution:

  • compile goal via execution log4j-plugin-processor in the process-classes phase

This execution runs the Log4j annotation processor (PluginProcessor) to generate required plugin metadata.

Useful commands:

mvn compile
mvn process-classes

D. Startup script generation — appassembler-maven-plugin

Plugin: org.codehaus.mojo:appassembler-maven-plugin

Configured goal:

  • appassembler:assemble (bound to package)

This goal generates startup scripts and the executable directory layout in:

  • target/executable/

It includes multiple launch programs (desktop, web-ui, server-launch, script-launch).

Explicit command:

mvn appassembler:assemble

E. ZIP distribution creation — maven-assembly-plugin

Plugin: org.apache.maven.plugins:maven-assembly-plugin

Configured goal:

  • assembly:single (package phase) using descriptor src/assembly/zip.xml

Expected result:

  • a distributable archive named mtg-desktop-companion in target/

Explicit command:

mvn assembly:single

4) Recommended workflows by use case

Daily development

mvn clean compile
mvn test

Quality + formatting check

mvn spotless:check
# then if needed
mvn spotless:apply

Full distribution-ready build

mvn clean package

Artifacts + local Maven publish

mvn clean install

5) Practical tips

  • If you get Java version errors, make sure your JDK is Java 25+.
  • To troubleshoot dependency conflicts, start with mvn dependency:tree.
  • To regenerate distribution artifacts after updating resources/scripts, run mvn clean package.

6) Quick summary of key goals

  • Standard lifecycle: clean, compile, test, package, install
  • Spotless: spotless:check, spotless:apply
  • Dependencies: dependency:tree, dependency:analyze
  • Appassembler: appassembler:assemble
  • Resources: resources:copy-resources
  • Assembly: assembly:single