-
Notifications
You must be signed in to change notification settings - Fork 132
/
build.sh
executable file
·83 lines (73 loc) · 2.56 KB
/
build.sh
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
#!/usr/bin/env bash
#
# Copyright (C) 2024 Open Transit Software Foundation <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#!/bin/bash
# Function to print help message
print_help() {
echo "Usage: $0 [OPTIONS]"
echo "Wrapper script for Maven build command with customizable options."
echo
echo "Options:"
echo " --help Display this help message"
echo " --clean Run the clean phase before building (optional)"
echo " --check-updates Force a check for updated releases and snapshots"
echo " --test Run tests (disabled by default)"
echo " --javadoc Generate JavaDoc (disabled by default)"
echo " --validate-silent VALUE Set the validate.silent option (default: true)"
echo " --log4j-config VALUE Set the log4j.configuration option (default: empty)"
echo
echo "Example:"
echo " $0 --clean --check-updates --test --javadoc --validate-silent false --log4j-config my-log4j.properties"
}
# Default values
clean=""
check_updates=""
run_tests="false"
generate_javadoc="false"
validate_silent="true"
log4j_config=""
# Parse command line arguments
while [[ "$#" -gt 0 ]]; do
case $1 in
--help) print_help; exit 0;;
--clean) clean="clean ";;
--check-updates) check_updates="-U ";;
--test) run_tests="true";;
--javadoc) generate_javadoc="true";;
--validate-silent) validate_silent="$2"; shift;;
--log4j-config) log4j_config="$2"; shift;;
*) echo "Unknown parameter: $1"; print_help; exit 1;;
esac
shift
done
# Construct the Maven command
cmd="mvn ${check_updates}${clean}install"
# Add options based on parsed arguments
if [ "$run_tests" = "false" ]; then
cmd="$cmd -DskipTests=true"
fi
if [ "$generate_javadoc" = "false" ]; then
cmd="$cmd -Dmaven.javadoc.skip=true"
fi
cmd="$cmd -Dvalidate.silent=$validate_silent"
if [ -n "$log4j_config" ]; then
cmd="$cmd -Dlog4j.configuration=$log4j_config"
else
cmd="$cmd -Dlog4j.configuration="
fi
# Execute the command
echo "Executing: $cmd"
eval $cmd