1
0
Fork 0
mirror of https://github.com/actions/setup-java synced 2024-11-09 23:22:40 +00:00
setup-java/__tests__/verify-java.sh
Thomas Broyer 457d7a4579 Add output parameters for the tool path and version
This allows calling the action multiple times in the
same job and retrieving the path and/or version in
other steps.

Fixes #65
2020-05-27 09:04:20 +02:00

33 lines
616 B
Bash
Executable file

#!/bin/sh
if [ -z "$1" ]; then
echo "::error::Must supply java version argument"
exit 1
fi
java_version="$(java -version 2>&1)"
echo "Found java version: $java_version"
if [ -z "$(echo $java_version | grep --fixed-strings $1)" ]; then
echo "::error::Unexpected version"
exit 1
fi
if [ -z "$2" ]; then
echo "::error::Must supply java path argument"
exit 1
fi
if [ "$2" != "$JAVA_HOME" ]; then
echo "::error::Unexpected path"
exit 1
fi
if [ -z "$3" ]; then
echo "::error::Must supply java version argument"
exit 1
fi
if [ "$1" != "$3" ]; then
echo "::error::Unexpected version"
exit 1
fi