Skip to content

Commit bb91d9b

Browse files
authored
Merge pull request #36 from evolvedbinary/6.x.x/feature/build-scripts
[6.x.x] Add a simple build script
2 parents df8b2e3 + 5506f19 commit bb91d9b

File tree

7 files changed

+744
-12
lines changed

7 files changed

+744
-12
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
wrapperVersion=3.3.2
18+
distributionType=only-script
19+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.10/apache-maven-3.9.10-bin.zip

BUILD.md

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,33 @@ Elemental itself is written in Java 8. The build system is [Apache Maven](http:/
44

55
To build Elemental:
66

7-
- Checkout the Git Repository
8-
- Execute a Maven to compile Elemental
7+
1. Checkout the Git Repository
98

10-
```bash
11-
$ git clone https://github.com/evolvedbinary/elemental.git
12-
$ cd elemental
13-
$ git checkout gold
14-
$ mvn -DskipTests package
15-
```
9+
```bash
10+
$ git clone https://github.com/evolvedbinary/elemental.git
11+
$ git checkout gold
12+
$ cd elemental
13+
```
14+
15+
2. Execute Maven to compile Elemental
16+
17+
We provide a build script to try and make common build tasks easier for users.
18+
19+
For macOS/Linux/Unix platforms:
20+
```bash
21+
$ ./build.sh quick
22+
```
23+
24+
or, for Windows platforms:
25+
```cmd
26+
> build.bat quick
27+
```
1628

1729
From here, you now have a compiled version of Elemental in the `exist-distribution/target` folder that you may use just as you would an installed version of Elemental. An installer is also build and present in `exist-installer/target` for easy installation elsewhere.
1830

19-
Useful build switches:
20-
- `-Ddocker=true` : builds the docker image
21-
- `-DskipTests` : skips running tests
22-
- `-Ddependency-check.skip=true` : skips validating dependencies
31+
The `quick` build target will build distribution directory that can be found at: `exist-distribution/target/elemental-x.y.x-dir`.
32+
If you wish to see what other build targets are available, you can run `./build.sh --help` (or `build.bat --help` on Windows platforms).
33+
2334

2435
Further build options can be found at: [eXist-db Build Documentation](http://www.exist-db.org/exist/apps/doc/exist-building.xml "How to build eXist-db").
2536

build.bat

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
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

build.sh

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Elemental
4+
# Copyright (C) 2024, Evolved Binary Ltd
5+
#
6+
7+
# https://www.evolvedbinary.com | https://www.elemental.xyz
8+
#
9+
# This library is free software; you can redistribute it and/or
10+
# modify it under the terms of the GNU Lesser General Public
11+
# License as published by the Free Software Foundation; version 2.1.
12+
#
13+
# This library is distributed in the hope that it will be useful,
14+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
# Lesser General Public License for more details.
17+
#
18+
# You should have received a copy of the GNU Lesser General Public
19+
# License along with this library; if not, write to the Free Software
20+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21+
#
22+
23+
##
24+
# Simple build Script for Elemental that tries to make it easier to build a few of the usual targets
25+
# Author: Adam Retter
26+
##
27+
28+
set -e
29+
30+
TARGET="useage"
31+
OFFLINE=false
32+
CONCURRENCY="-T2C"
33+
34+
POSITIONAL=()
35+
while [[ $# -gt 0 ]]
36+
do
37+
key="$1"
38+
39+
case $key in
40+
quick|quick-archives|quick-docker|quick-archives-docker|quick-install|test|site|license-check|license-format|dependency-check|dependency-security-check)
41+
TARGET="$1"
42+
shift
43+
;;
44+
--offline)
45+
OFFLINE=true
46+
shift
47+
;;
48+
-h|--help)
49+
TARGET="useage"
50+
shift
51+
;;
52+
*)
53+
POSITIONAL+=("$1") # save it in an array for later
54+
shift
55+
;;
56+
esac
57+
done
58+
59+
function print-useage() {
60+
echo -e "\n./build.sh [--offline] <target> | --help"
61+
echo -e "\nAvailable build targets are:"
62+
echo -e "\tquick - A distribution directory that can be found in exist-distribution/target/elemental-x.y.x-dir"
63+
echo -e "\tquick-archives - A distribution directory, and distribution archives that can be found in exist-distribution/target/"
64+
echo -e "\tquick-docker - A distribution directory and Docker Image"
65+
echo -e "\tquick-archives-docker - A distribution directory, distribution archives, and Docker Image"
66+
echo -e "\tquick-install - A distribution directory, and installs Maven Artifacts to your local Maven repository"
67+
echo -e "\ttest - Runs the test suite"
68+
echo -e "\tsite - Runs the test suite and produces a Maven Site in target/site/ that details the results"
69+
echo -e "\tlicence-check - Checks that all source files have the correct license header"
70+
echo -e "\tlicence-format - Adds the correct license header to any source files that are missing it"
71+
echo -e "\tdependency-check - Checks that all modules have correctly declared their dependencies"
72+
echo -e "\tdependency-security-check - Checks that all dependencies have no unexpected CVE security issues"
73+
echo -e "\n--offline - attempts to run the Maven build in offline mode"
74+
}
75+
76+
set -- "${POSITIONAL[@]}" # restore positional parameters
77+
78+
if [ "${TARGET}" == "useage" ]; then
79+
print-useage
80+
exit 0;
81+
fi
82+
83+
84+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
85+
BASE_CMD="${SCRIPT_DIR}/mvnw -V"
86+
87+
if [ "${OFFLINE}" == "true" ]; then
88+
BASE_CMD="${BASE_CMD} --offline"
89+
fi
90+
91+
if [ "${TARGET}" == "quick" ]; then
92+
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"
93+
$CMD
94+
exit 0;
95+
fi
96+
97+
if [ "${TARGET}" == "quick-archives" ]; then
98+
CMD="${BASE_CMD} ${CONCURRENCY} clean package -DskipTests -Ddependency-check.skip=true -Ddocker=true -P installer,!concurrency-stress-tests,!micro-benchmarks"
99+
$CMD
100+
exit 0;
101+
fi
102+
103+
if [ "${TARGET}" == "quick-docker" ]; then
104+
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"
105+
$CMD
106+
exit 0;
107+
fi
108+
109+
if [ "${TARGET}" == "quick-archives-docker" ]; then
110+
CMD="${BASE_CMD} ${CONCURRENCY} clean package -DskipTests -Ddependency-check.skip=true -Ddocker=true -P installer,-P docker,!concurrency-stress-tests,!micro-benchmarks"
111+
$CMD
112+
exit 0;
113+
fi
114+
115+
if [ "${TARGET}" == "quick-install" ]; then
116+
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"
117+
$CMD
118+
exit 0;
119+
fi
120+
121+
if [ "${TARGET}" == "test" ]; then
122+
CMD="${BASE_CMD} clean test -Ddependency-check.skip=true"
123+
$CMD
124+
exit 0;
125+
fi
126+
127+
if [ "${TARGET}" == "site" ]; then
128+
CMD="${BASE_CMD} clean test -Ddependency-check.skip=true"
129+
$CMD
130+
exit 0;
131+
fi
132+
133+
if [ "${TARGET}" == "license-check" ]; then
134+
CMD="${BASE_CMD} license:check"
135+
$CMD
136+
exit 0;
137+
fi
138+
139+
if [ "${TARGET}" == "license-format" ]; then
140+
CMD="${BASE_CMD} license:format"
141+
$CMD
142+
exit 0;
143+
fi
144+
145+
if [ "${TARGET}" == "dependency-check" ]; then
146+
CMD="${BASE_CMD} dependency:analyze"
147+
$CMD
148+
exit 0;
149+
fi
150+
151+
if [ "${TARGET}" == "dependency-security-check" ]; then
152+
CMD="${BASE_CMD} dependency-check:check"
153+
$CMD
154+
exit 0;
155+
fi
156+
157+
print-useage
158+
exit 0;

0 commit comments

Comments
 (0)