-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.bat
More file actions
165 lines (150 loc) · 6.22 KB
/
build.bat
File metadata and controls
165 lines (150 loc) · 6.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
@REM
@REM Elemental
@REM Copyright (C) 2024, Evolved Binary Ltd
@REM
@REM admin@evolvedbinary.com
@REM https://www.evolvedbinary.com | https://www.elemental.xyz
@REM
@REM This library is free software; you can redistribute it and/or
@REM modify it under the terms of the GNU Lesser General Public
@REM License as published by the Free Software Foundation; version 2.1.
@REM
@REM This library is distributed in the hope that it will be useful,
@REM but WITHOUT ANY WARRANTY; without even the implied warranty of
@REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@REM Lesser General Public License for more details.
@REM
@REM You should have received a copy of the GNU Lesser General Public
@REM License along with this library; if not, write to the Free Software
@REM Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
@REM
@REM
@REM Simple build Script for Elemental that tries to make it easier to build a few of the usual targets
@REM Author: Adam Retter
@REM
@echo off
setlocal
set "TARGET=useage"
set "DEBUG=false"
set "OFFLINE=false"
set "CONCURRENCY=-T2C"
:: Process arguments
:parse_args
if "%~1"=="" goto done_parsing
if /I "%~1"=="--debug" (
set "DEBUG=true"
) else if /I "%~1"=="--offline" (
set "OFFLINE=true"
) else if /I "%~1"=="--help" (
set "TARGET=useage"
) else if /I "%~1"=="-h" (
set "TARGET=useage"
) else if /I "%~1"=="clean" (
set "TARGET=clean"
) else if /I "%~1"=="quick" (
set "TARGET=quick"
) else if /I "%~1"=="quick-archives" (
set "TARGET=quick-archives"
) else if /I "%~1"=="quick-docker" (
set "TARGET=quick-docker"
) else if /I "%~1"=="quick-archives-docker" (
set "TARGET=quick-archives-docker"
) else if /I "%~1"=="quick-install" (
set "TARGET=quick-install"
) else if /I "%~1"=="test" (
set "TARGET=test"
) else if /I "%~1"=="site" (
set "TARGET=site"
) else if /I "%~1"=="license-check" (
set "TARGET=license-check"
) else if /I "%~1"=="license-format" (
set "TARGET=license-format"
) else if /I "%~1"=="dependency-check" (
set "TARGET=dependency-check"
) else if /I "%~1"=="dependency-security-check" (
set "TARGET=dependency-security-check"
) else if /I "%~1"=="format-poms" (
set "TARGET=format-poms"
)
shift
goto parse_args
:done_parsing
if "%DEBUG%"=="true" (
set "BASE_CMD=%BASE_CMD% --debug"
)
if "%OFFLINE%"=="true" (
set "BASE_CMD=%BASE_CMD% --offline"
)
if "%TARGET%"=="useage" (
goto show_useage
)
:: Determine script directory
set "SCRIPT_DIR=%~dp0"
set "BASE_CMD=%SCRIPT_DIR%\mvnw.cmd -V"
:: Set CMD based on TARGET
if "%TARGET%"=="clean" (
set "CMD=%BASE_CMD% %CONCURRENCY% clean -Pinstaller,docker,concurrency-stress-tests,micro-benchmarks"
) else if "%TARGET%"=="quick" (
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"
) else if "%TARGET%"=="quick-archives" (
set "CMD=%BASE_CMD% %CONCURRENCY% clean package -DskipTests -Ddependency-check.skip=true -Ddocker=false -P installer,!concurrency-stress-tests,!micro-benchmarks"
) else if "%TARGET%"=="quick-docker" (
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"
) else if "%TARGET%"=="quick-archives-docker" (
set "CMD=%BASE_CMD% %CONCURRENCY% clean package -DskipTests -Ddependency-check.skip=true -Ddocker=true -P installer,-P docker,!concurrency-stress-tests,!micro-benchmarks"
) else if "%TARGET%"=="quick-install" (
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"
) else if "%TARGET%"=="test" (
set "CMD=%BASE_CMD% clean test -Ddependency-check.skip=true"
) else if "%TARGET%"=="site" (
set "CMD=%BASE_CMD% clean verify site -Ddependency-check.skip=true"
) else if "%TARGET%"=="license-check" (
set "CMD=%BASE_CMD% license:check"
) else if "%TARGET%"=="license-format" (
set "CMD=%BASE_CMD% license:format"
) else if "%TARGET%"=="dependency-check" (
set "CMD=%BASE_CMD% dependency:analyze"
) else if "%TARGET%"=="dependency-security-check" (
set "CMD=%BASE_CMD% dependency-check:check"
) else if "%TARGET%"=="format-poms" (
setlocal enabledelayedexpansion
set "SAXON=%USERPROFILE%\.m2\repository\net\sf\saxon\Saxon-HE\9.9.1-8\Saxon-HE-9.9.1-8.jar"
for /r %%P in (pom.xml) do (
if exist "%%P" (
set "POM=%%P"
echo | set /p dummyName="Formatting !POM! ..."
java -jar "!SAXON!" -s:!POM! -xsl:format-pom.xslt -o:!POM!
echo OK
echo | set /p dummyName="Checking for duplicate license entries in !POM! ... "
java -cp "!SAXON!" net.sf.saxon.Query -q:check-pom-license-uniqueness.xq pom-file-path=!POM!
echo OK
)
)
endlocal
goto end
) else (
echo Invalid target: %TARGET%
goto show_useage
)
:: Execute the command
call %CMD%
goto end
:show_useage
echo.
echo Usage: build.bat [--debug] [--offline] ^<target^> ^| --help
echo.
echo Available build targets:
echo clean - Remove all built artifacts
echo quick - Build distribution directory
echo quick-archives - Build and archive distribution
echo quick-docker - Build distribution + Docker image
echo quick-archives-docker - All of the above
echo quick-install - Installs Maven artifacts locally
echo test - Run test suite
echo site - Run tests and generate Maven site
echo license-check - Check license headers
echo license-format - Add missing license headers
echo dependency-check - Analyze dependencies
echo dependency-security-check - Check for known CVEs
:end
endlocal