-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnp
More file actions
executable file
·63 lines (47 loc) · 1.97 KB
/
np
File metadata and controls
executable file
·63 lines (47 loc) · 1.97 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
#!/bin/bash
set -e
function download-nanopub-jar {
>&2 echo "Getting latest nanopub version..."
NANOPUB_LATEST_LOCATION=$(
curl --head -s https://github.com/Nanopublication/nanopub-java/releases/latest \
| egrep -i '^location:'
)
NANOPUB_VERSION=${NANOPUB_LATEST_LOCATION##*-}
NANOPUB_VERSION="${NANOPUB_VERSION%"${NANOPUB_VERSION##*[![:space:]]}"}"
>&2 echo "Downloading nanopub jar file version $NANOPUB_VERSION..."
echo "$SCRIPTDIR/nanopub-${NANOPUB_VERSION}-jar-with-dependencies.jar"
curl -L --output "$SCRIPTDIR/nanopub-${NANOPUB_VERSION}-jar-with-dependencies.jar" "https://github.com/Nanopublication/nanopub-java/releases/download/nanopub-${NANOPUB_VERSION}/nanopub-${NANOPUB_VERSION}-jar-with-dependencies.jar"
}
WORKINGDIR=`pwd`
cd "$( dirname "${BASH_SOURCE[0]}" )"
SCRIPTDIR=`pwd`
if [ "$1" == "--download" ]; then
download-nanopub-jar
exit
fi
cd -P ..
PROJECTDIR=`pwd`
# for Cygwin:
PROJECTDIR=${PROJECTDIR#/cygdrive/?}
cd $WORKINGDIR
NANOPUBJAR=$(find $SCRIPTDIR -maxdepth 1 -name "nanopub-*-jar-with-dependencies.jar" 2>/dev/null | sort -n | tail -1)
JAVAPARAMS="-Dsun.jnu.encoding=utf8 -Dfile.encoding=utf8"
if [ ! -z "$NANOPUBJAR" ]; then
exec java $JAVAPARAMS -jar $NANOPUBJAR "$@"
fi
NANOPUBJAR=$(find /usr/share/java/ -maxdepth 1 -name "nanopub-*-jar-with-dependencies.jar" 2>/dev/null | sort -n | tail -1)
if [ ! -z "$NANOPUBJAR" ]; then
exec java $JAVAPARAMS -jar $NANOPUBJAR "$@"
fi
NANOPUBJAR=$(find $PROJECTDIR/target/ -maxdepth 1 -name "nanopub-*-jar-with-dependencies.jar" 2>/dev/null | sort -n | tail -1)
if [ ! -z "$NANOPUBJAR" ]; then
exec java $JAVAPARAMS -jar $NANOPUBJAR "$@"
fi
>&2 echo "No nanopub jar file found. Downloading it from the web..."
download-nanopub-jar
NANOPUBJAR=$(find $SCRIPTDIR -maxdepth 1 -name "nanopub-*-jar-with-dependencies.jar" 2>/dev/null | sort -n | tail -1)
if [ ! -z "$NANOPUBJAR" ]; then
exec java $JAVAPARAMS -jar $NANOPUBJAR "$@"
fi
>&2 echo "ERROR: Failed to find or download nanopub jar file."
exit 1