|
| 1 | +@REM |
| 2 | +@REM Elemental |
| 3 | +@REM Copyright (C) 2024, Evolved Binary Ltd |
| 4 | +@REM |
| 5 | + |
| 6 | +@REM https://www.evolvedbinary.com | https://www.elemental.xyz |
| 7 | +@REM |
| 8 | +@REM This library is free software; you can redistribute it and/or |
| 9 | +@REM modify it under the terms of the GNU Lesser General Public |
| 10 | +@REM License as published by the Free Software Foundation; version 2.1. |
| 11 | +@REM |
| 12 | +@REM This library is distributed in the hope that it will be useful, |
| 13 | +@REM but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | +@REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | +@REM Lesser General Public License for more details. |
| 16 | +@REM |
| 17 | +@REM You should have received a copy of the GNU Lesser General Public |
| 18 | +@REM License along with this library; if not, write to the Free Software |
| 19 | +@REM Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | +@REM |
| 21 | + |
| 22 | +@REM |
| 23 | +@REM Simple build Script for Elemental that tries to make it easier to build a few of the usual targets |
| 24 | +@REM Author: Adam Retter |
| 25 | +@REM |
| 26 | + |
| 27 | +@echo off |
| 28 | +setlocal enabledelayedexpansion |
| 29 | + |
| 30 | +set "TARGET=useage" |
| 31 | +set "OFFLINE=false" |
| 32 | +set "CONCURRENCY=-T2C" |
| 33 | + |
| 34 | +:: Process arguments |
| 35 | +:parse_args |
| 36 | +if "%~1"=="" goto done_parsing |
| 37 | + |
| 38 | +if /I "%~1"=="--offline" ( |
| 39 | + set "OFFLINE=true" |
| 40 | +) else if /I "%~1"=="--help" ( |
| 41 | + set "TARGET=useage" |
| 42 | +) else if /I "%~1"=="-h" ( |
| 43 | + set "TARGET=useage" |
| 44 | +) else if /I "%~1"=="quick" ( |
| 45 | + set "TARGET=quick" |
| 46 | +) else if /I "%~1"=="quick-archives" ( |
| 47 | + set "TARGET=quick-archives" |
| 48 | +) else if /I "%~1"=="quick-docker" ( |
| 49 | + set "TARGET=quick-docker" |
| 50 | +) else if /I "%~1"=="quick-archives-docker" ( |
| 51 | + set "TARGET=quick-archives-docker" |
| 52 | +) else if /I "%~1"=="quick-install" ( |
| 53 | + set "TARGET=quick-install" |
| 54 | +) else if /I "%~1"=="test" ( |
| 55 | + set "TARGET=test" |
| 56 | +) else if /I "%~1"=="site" ( |
| 57 | + set "TARGET=site" |
| 58 | +) else if /I "%~1"=="license-check" ( |
| 59 | + set "TARGET=license-check" |
| 60 | +) else if /I "%~1"=="license-format" ( |
| 61 | + set "TARGET=license-format" |
| 62 | +) else if /I "%~1"=="dependency-check" ( |
| 63 | + set "TARGET=dependency-check" |
| 64 | +) else if /I "%~1"=="dependency-security-check" ( |
| 65 | + set "TARGET=dependency-security-check" |
| 66 | +) |
| 67 | +shift |
| 68 | +goto parse_args |
| 69 | + |
| 70 | +:done_parsing |
| 71 | + |
| 72 | +if "%OFFLINE%"=="true" ( |
| 73 | + set "BASE_CMD=%BASE_CMD% --offline" |
| 74 | +) |
| 75 | + |
| 76 | +if "%TARGET%"=="useage" ( |
| 77 | + goto show_useage |
| 78 | +) |
| 79 | + |
| 80 | +:: Determine script directory |
| 81 | +set "SCRIPT_DIR=%~dp0" |
| 82 | +set "BASE_CMD=%SCRIPT_DIR%\mvnw.cmd -V" |
| 83 | + |
| 84 | +:: Set CMD based on TARGET |
| 85 | +if "%TARGET%"=="quick" ( |
| 86 | + set "CMD=%BASE_CMD% %CONCURRENCY% clean package -DskipTests -Ddependency-check.skip=true -Dappbundler.skip=true -Ddocker=false -P !mac-dmg-on-mac,!codesign-mac-app,!codesign-mac-dmg,!mac-dmg-on-unix,!installer,!concurrency-stress-tests,!micro-benchmarks,skip-build-dist-archives" |
| 87 | +) else if "%TARGET%"=="quick-archives" ( |
| 88 | + set "CMD=%BASE_CMD% %CONCURRENCY% clean package -DskipTests -Ddependency-check.skip=true -Ddocker=true -P installer,!concurrency-stress-tests,!micro-benchmarks" |
| 89 | +) else if "%TARGET%"=="quick-docker" ( |
| 90 | + set "CMD=%BASE_CMD% %CONCURRENCY% clean package -DskipTests -Ddependency-check.skip=true -Dappbundler.skip=true -Ddocker=true -P docker,!mac-dmg-on-mac,!codesign-mac-app,!codesign-mac-dmg,!mac-dmg-on-unix,!installer,!concurrency-stress-tests,!micro-benchmarks,skip-build-dist-archives" |
| 91 | +) else if "%TARGET%"=="quick-archives-docker" ( |
| 92 | + set "CMD=%BASE_CMD% %CONCURRENCY% clean package -DskipTests -Ddependency-check.skip=true -Ddocker=true -P installer,-P docker,!concurrency-stress-tests,!micro-benchmarks" |
| 93 | +) else if "%TARGET%"=="quick-install" ( |
| 94 | + set "CMD=%BASE_CMD% %CONCURRENCY% clean install package -DskipTests -Ddependency-check.skip=true -Dappbundler.skip=true -Ddocker=false -P !mac-dmg-on-mac,!codesign-mac-app,!codesign-mac-dmg,!mac-dmg-on-unix,!installer,!concurrency-stress-tests,!micro-benchmarks,skip-build-dist-archives" |
| 95 | +) else if "%TARGET%"=="test" ( |
| 96 | + set "CMD=%BASE_CMD% clean test -Ddependency-check.skip=true" |
| 97 | +) else if "%TARGET%"=="site" ( |
| 98 | + set "CMD=%BASE_CMD% clean test -Ddependency-check.skip=true" |
| 99 | +) else if "%TARGET%"=="license-check" ( |
| 100 | + set "CMD=%BASE_CMD% license:check" |
| 101 | +) else if "%TARGET%"=="license-format" ( |
| 102 | + set "CMD=%BASE_CMD% license:format" |
| 103 | +) else if "%TARGET%"=="dependency-check" ( |
| 104 | + set "CMD=%BASE_CMD% dependency:analyze" |
| 105 | +) else if "%TARGET%"=="dependency-security-check" ( |
| 106 | + set "CMD=%BASE_CMD% dependency-check:check" |
| 107 | +) else ( |
| 108 | + echo Invalid target: %TARGET% |
| 109 | + goto show_useage |
| 110 | +) |
| 111 | + |
| 112 | +:: Execute the command |
| 113 | +call %CMD% |
| 114 | +goto end |
| 115 | + |
| 116 | +:show_useage |
| 117 | +echo. |
| 118 | +echo Usage: build.bat [--offline] ^<target^> ^| --help |
| 119 | +echo. |
| 120 | +echo Available build targets: |
| 121 | +echo quick - Build distribution directory |
| 122 | +echo quick-archives - Build and archive distribution |
| 123 | +echo quick-docker - Build distribution + Docker image |
| 124 | +echo quick-archives-docker - All of the above |
| 125 | +echo quick-install - Installs Maven artifacts locally |
| 126 | +echo test - Run test suite |
| 127 | +echo site - Run tests and generate Maven site |
| 128 | +echo license-check - Check license headers |
| 129 | +echo license-format - Add missing license headers |
| 130 | +echo dependency-check - Analyze dependencies |
| 131 | +echo dependency-security-check - Check for known CVEs |
| 132 | + |
| 133 | +:end |
| 134 | +endlocal |
0 commit comments