-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-picocli.sh
executable file
·53 lines (40 loc) · 1.77 KB
/
update-picocli.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
#!/bin/bash
set -e
#########################################################################
#
# Update the version of picocli
#
# https://github.com/remkop/picocli
#
#########################################################################
# Retrieve Latest Version
VERSION=$(curl -sI https://github.com/remkop/picocli/releases/latest | grep -i location: | awk -F"/" '{ printf "%s", $NF }' | tr -d 'v' | tr -d '\r\n')
# Global Variables
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
DIR="$( cd "$( dirname "$( dirname "${BASH_SOURCE[0]}" )")" && pwd )"
ROOT_DIR="$( cd "$( dirname "$( dirname "$( dirname "${BASH_SOURCE[0]}" )")")" && pwd )"
BASE_URL="https://raw.githubusercontent.com/remkop/picocli"
LICENSE_URL="$BASE_URL/v$VERSION/LICENSE"
LICENSE_FILE_PATH="$DIR/src/main/resources/META-INF/licenses/picocli.txt"
RELATIVE_SOURCE_FILE_PATH="src/main/java/picocli/CommandLine.java"
SOURCE_URL="$BASE_URL/v$VERSION/$RELATIVE_SOURCE_FILE_PATH"
SOURCE_FILE_PATH="$DIR/$RELATIVE_SOURCE_FILE_PATH"
# Download the license and source file
curl -ksf "$LICENSE_URL" > "$LICENSE_FILE_PATH"
curl -ksf "$SOURCE_URL" > "$SOURCE_FILE_PATH"
if [[ "$OS" == "linux" ]]
then
# Add some warning suppression to the java source file
sed -i 's/public\sclass\sCommandLine/@SuppressWarnings({"rawtypes", "deprecation" })\npublic class CommandLine/g' "$SOURCE_FILE_PATH"
# Replace the version in build files
sed -i "s/<picocli.version>[-[:alnum:]./]\{1,\}<\/picocli.version>/<picocli.version>$VERSION<\/picocli.version>/" "$DIR/pom.xml"
sed -i "/picocliVersion( )?=( )?/ s/=.*/= $VERSION/" gradle.properties
# Remove TODOs so not highlighted in editor
sed -i 's/TODO/TIDO/g' "$SOURCE_FILE_PATH"
elif [[ "$OS" == "darwin" ]]
then
echo "TODO: mac"
else
die
fi
echo "Picocli updated to version: $VERSION"