Usage

The most minimal parent pom is If you are able to accept more opinionated defaults continue to The minimal parent is meant to contain uncontroversial best practices that are applicable to all projects Inherit from in your project s pom xml liftwizard minimal parent liftwizard profile parent liftwizard minimal parent <parent> <groupId>io liftwizard< groupId> <artifactId>liftwizard minimal parent< artifactId> <version>$ liftwizard version < version> < parent>

What you will get

The following sections describe the best practices that are enforced by You will not need to configure these in your project s pom xml if you inherit from liftwizard minimal parent liftwizard minimal parent

Resource encodings

If you encounter a warning like this is because the project does not specify a character encoding scheme to configure specifies the character encoding scheme in the section of the pom xml This will become unnecessary starting with maven 4 x WARNING Using platform encoding UTF 8 actually to copy filtered resources i e build is platform dependent maven resources plugin liftwizard minimal parent properties <project build sourceEncoding>UTF 8< project build sourceEncoding> <project reporting outputEncoding>UTF 8< project reporting outputEncoding>

Reproducible builds

Reproducible builds are a set of software development practices that create an independently verifiable path from source to binary code A build is reproducible if given the same source code build environment and build instructions any party can recreate bit by bit identical copies of all specified artifacts You can enable Reproducible Builds mode for plugins by specifying locking down the outputTimestamp property You will also need to run and as described in the guide to validate that builds are truly reproducible <project build outputTimestamp>2024 10 31T13 51 17Z< project build outputTimestamp> mvn artifact check buildplan mvn verify artifact compare

Default Goal

You can specify the default goal to run when you run without any arguments is a better choice than in the presence of concurrent builds that may write to simultaneously is a better choice than because developers may build up state like test files and test databases under and may not expect them to be deleted by default It s easy to run when you need it mvn <defaultGoal>verify< defaultGoal> verify install m2 repository verify clean verify target mvn clean

Plugins which are bound and enabled by default

Maven builds are configured by binding plugins to lifecycle phases Even if you don t declare any plugins in your pom xml maven will still bind some plugins to the main phases All versions of maven bind the same plugins but newer versions of maven bind newer versions of the plugins If you don t specify the versions of the plugins different members of the team could be using different versions leading to different build results on different machines It s becoming more common to lock down the version of maven itself but this wasn t always the case If you haven t specified the versions of these plugins maven enforcer plugin will log an error like To avoid this we specify versions of the plugins in the parent pom ERROR Rule 3 org apache maven enforcer rules RequirePluginVersions failed with message Some plugins are missing valid versions or depend on Maven 3 9 5 defaults LATEST RELEASE as plugin version are not allowed org apache maven plugins maven compiler plugin The version currently in use is 3 11 0 via default lifecycle bindings org apache maven plugins maven surefire plugin The version currently in use is 3 1 2 via default lifecycle bindings org apache maven plugins maven jar plugin The version currently in use is 3 3 0 via default lifecycle bindings org apache maven plugins maven clean plugin The version currently in use is 3 2 0 via default lifecycle bindings org apache maven plugins maven install plugin The version currently in use is 3 1 1 via default lifecycle bindings org apache maven plugins maven site plugin The version currently in use is 3 12 1 via default lifecycle bindings org apache maven plugins maven resources plugin The version currently in use is 3 3 1 via default lifecycle bindings org apache maven plugins maven deploy plugin The version currently in use is 3 1 1 via default lifecycle bindings < These plugins are bound and enabled by default > < But the default version of these plugins changes with the version of maven running > < region Phase 0 clean > <plugin> <groupId>org apache maven plugins< groupId> <artifactId>maven clean plugin< artifactId> <version>3 4 0< version> < plugin> < endregion Phase 0 clean > < region Phase 6 process resources > <plugin> <groupId>org apache maven plugins< groupId> <artifactId>maven resources plugin< artifactId> <version>3 3 1< version> < plugin> < endregion Phase 6 process resources > < region Phase 7 compile > <plugin> <groupId>org apache maven plugins< groupId> <artifactId>maven compiler plugin< artifactId> <version>3 13 0< version> <configuration> < https maven apache org plugins archives maven compiler plugin 3 8 1 compile mojo html#parameters > < https stackoverflow com a 44075684 > < https docs oracle com javase 9 tools javac htm > < Generates metadata for reflection on method parameters Stores formal parameter names of constructors and methods in the generated class file so that the method java lang reflect Executable getParameters from the Reflection API can retrieve them > <parameters>true< parameters> < configuration> < plugin> < endregion Phase 7 compile > < region Phase 15 test > <plugin> <groupId>org apache maven plugins< groupId> <artifactId>maven surefire plugin< artifactId> <version>3 5 2< version> < In maven 3 9 6 and 4 x maven is able to auto detect JUnit and these dependencies are not required > < In maven 3 9 5 there is an internal exception inside surefire without these declared > < Even with newer versions of maven it is advantageous to keep these declarations > < Without them maven may only run JUnit 5 tests in a project with both JUnit 4 and 5 > <dependencies> <dependency> <groupId>org junit jupiter< groupId> <artifactId>junit jupiter engine< artifactId> <version>5 10 3< version> < dependency> <dependency> <groupId>org junit platform< groupId> <artifactId>junit platform engine< artifactId> <version>1 10 3< version> < dependency> <dependency> <groupId>org junit vintage< groupId> <artifactId>junit vintage engine< artifactId> <version>5 10 3< version> < dependency> < dependencies> <configuration> < The compiler in the server VM now provides correct stack backtraces for all cold built in exceptions For performance purposes when such an exception is thrown a few times the method may be recompiled After recompilation the compiler may choose a faster tactic using preallocated exceptions that do not provide a stack trace To disable completely the use of preallocated exceptions use this new flag XX OmitStackTraceInFastThrow > < https stackoverflow com a 4659279 > < The compiler in the server VM now provides correct stack backtraces for all cold built in exceptions For performance purposes when such an exception is thrown a few times the method may be recompiled After recompilation the compiler may choose a faster tactic using preallocated exceptions that do not provide a stack trace To disable completely the use of preallocated exceptions use this new flag XX OmitStackTraceInFastThrow > < https stackoverflow com a 4659279 > < Add argLine to allow the Jacoco plugin to append without overriding the setting > < https stackoverflow com a 39818768 > <argLine> XX OmitStackTraceInFastThrow @ argLine < argLine> <runOrder>random< runOrder> <trimStackTrace>false< trimStackTrace> < configuration> < plugin> < endregion Phase 15 test > < region Phase 17 package > <plugin> <groupId>org apache maven plugins< groupId> <artifactId>maven jar plugin< artifactId> <version>3 4 2< version> < plugin> < endregion Phase 17 package > < region Phase 22 install > <plugin> <groupId>org apache maven plugins< groupId> <artifactId>maven install plugin< artifactId> <version>3 1 3< version> < plugin> < endregion Phase 22 install > < region Phase 23 deploy > <plugin> <groupId>org apache maven plugins< groupId> <artifactId>maven deploy plugin< artifactId> <version>3 1 3< version> < plugin> < endregion Phase 23 deploy >

No phase

The are a number of maven plugins with goals that are designed to be run interactively rather than being bound to a phase in the pom xml For example prints a visual representation of the dependencies of the project and updates the versions of dependencies in the pom xml Any maven plugin can be run from the command line with and configured using command line arguments without it appearing in the pom xml For example we can run the to list the plugins bound to each phase with this command If we configure the plugin in the pom xml we can run it with the syntax and add any configuration that would otherwise be specified with flags We configure several plugins in the parent pom xml that are not bound to any phase mvn dependency tree mvn versions set mvn groupId artifactId version goal buildplan maven plugin mvn org codehaus mojo buildplan maven plugin 2 2 2 list mvn phase goal D mvn buildplan list < mvn versions display dependency updates > < mvn versions display plugin updates > < mvn versions display property updates > <plugin> <groupId>org codehaus mojo< groupId> <artifactId>versions maven plugin< artifactId> <version>2 18 0< version> <configuration> < Don t create pom xml versionsBackup files > <generateBackupPoms>false< generateBackupPoms> < Process all modules in a multi module build even aggregator modules without a parent child relationship > < https stackoverflow com a 49246337 23572 > <processAllModules>true< processAllModules> < configuration> < plugin> < mvn dependency tree > <plugin> <groupId>org apache maven plugins< groupId> <artifactId>maven dependency plugin< artifactId> <version>3 8 1< version> < plugin> < mvn buildplan list > < mvn buildplan list phase > < mvn buildplan list plugin > <plugin> <groupId>org codehaus mojo< groupId> <artifactId>buildplan maven plugin< artifactId> <version>2 2 2< version> <configuration> < Default value is deploy > <tasks> <task>clean< task> <task>deploy< task> < tasks> < print all phases even if no mapping to an execution is available > <showAllPhases>true< showAllPhases> < configuration> < plugin> < mvn rewrite run > < mvn rewrite dryRun > <plugin> <groupId>org openrewrite maven< groupId> <artifactId>rewrite maven plugin< artifactId> <version>5 45 0< version> <dependencies> <dependency> <groupId>org openrewrite recipe< groupId> <artifactId>rewrite static analysis< artifactId> <version>1 20 0< version> < dependency> <dependency> <groupId>org openrewrite recipe< groupId> <artifactId>rewrite migrate java< artifactId> <version>2 29 0< version> < dependency> <dependency> <groupId>org openrewrite recipe< groupId> <artifactId>rewrite testing frameworks< artifactId> <version>2 22 0< version> < dependency> <dependency> <groupId>org openrewrite recipe< groupId> <artifactId>rewrite logging frameworks< artifactId> <version>2 16 0< version> < dependency> <dependency> <groupId>org openrewrite recipe< groupId> <artifactId>rewrite apache< artifactId> <version>1 8 2< version> < dependency> < dependencies> < plugin> < mvnw wrapper wrapper Dmaven 4 0 0 alpha 7 > <plugin> <artifactId>maven wrapper plugin< artifactId> <version>3 3 2< version> < plugin> < mvn clean release clean release prepare DdevelopmentVersion 1 2 3 SNAPSHOT > <plugin> <groupId>org apache maven plugins< groupId> <artifactId>maven release plugin< artifactId> <version>3 1 1< version> <configuration> < Default value is invoker > <mavenExecutorId>forked path< mavenExecutorId> < Automatically assign submodules the parent version > <autoVersionSubmodules>true< autoVersionSubmodules> < Do not `git push` changes to the upstream repository > <pushChanges>false< pushChanges> < Format to use when generating the tag name > < Default value is @ project artifactId @ project version > <tagNameFormat>@ project version < tagNameFormat> < configuration> < plugin>