Created
January 18, 2021 12:45
-
-
Save projected1/756aaac164f976943fd319a133f094e2 to your computer and use it in GitHub Desktop.
Wrapper script for Maven CLI to simplify builds.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@rem ------------------------------------------------------ | |
@rem Usage: | |
@rem mvn.bat <phase_or_goal> <list_of_modules> <path/to/settings.xml> | |
@rem | |
@rem phase_or_goal - compile, package, test | |
@rem list_of_modules - Comma-delimited list of modules in a multi-module project: | |
@rem "module_name_to_include,!module_name_to_exclude" | |
@rem | |
@rem Example: | |
@rem mvn.bat package "main-module,!deprecated-module" "%homepath%\.m2\settings.xml" | |
@rem | |
@rem ------------------------------------------------------ | |
@echo off | |
setlocal | |
rem Maven lifecycles: | |
rem http://maven.apache.org/ref/3.5.2/maven-core/lifecycles.html | |
if "%1" == "" ( | |
set PHASE_OR_GOAL=compile | |
) else ( | |
set PHASE_OR_GOAL=%1 | |
) | |
if not %2 == "" ( | |
set MODULES=-pl %2 -am -amd | |
) | |
if not "%3" == "" ( | |
set SETTINGS=-s %3 | |
) | |
:choose_mode | |
set /p OFFLINE_MODE="Offline mode (y/N)? " | |
if not "%OFFLINE_MODE%" == "y" if not "%OFFLINE_MODE%" == "n" if not "%OFFLINE_MODE%" == "" ( | |
goto choose_mode | |
) | |
if "%OFFLINE_MODE%" == "y" ( | |
set OFFLINE=-o | |
) | |
rem Bellow are JVM settings, which optimize compilation | |
rem --------------------------------------------------- | |
rem TieredCompilation : Manages intermediate compilation tiers (1, 2, 3), so that a method is | |
rem either interpreted or compiled at the maximum optimization level (C2). | |
rem TieredStopAtLevel : | |
rem + : =true | |
rem - : =false | |
set MAVEN_OPTS=-XX:+TieredCompilation -XX:TieredStopAtLevel=1 | |
rem -pl,--projects : Comma-delimited list of specified reactor projects to build instead of all projects | |
rem A project can be specified by [groupId]:artifactId or by its relative path | |
rem -am,--also-make : If project list is specified, also build projects required by the list | |
rem -amd,--also-make-dependents : If project list is specified, also build projects that depend on projects on the list | |
rem -N, --non-recursive : Prevents Maven from building submodules. Only builds the project contained in the current directory | |
rem -o,--offline : Work offline (Don't download any transitive dependencies) | |
rem -s,--settings : Alternate path for the user settings file | |
rem -T,--threads : Thread count, for instance 2.0C where C is core multiplied | |
rem -D, --define <arg> : Defines a system property | |
rem -DskipTests : Skips unit-tests (a common property that the majority plugins respect) | |
rem -DdependencyLocationsEnabled=false : | |
set RUN=mvn.cmd %PHASE_OR_GOAL% %MODULES% %SETTINGS% %OFFLINE% -T 4 -DskipTests ^| tee %~dp0mvn.log | |
echo %RUN% | |
%RUN% | |
endlocal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment