mirror of
https://github.com/actions/setup-java.git
synced 2025-04-19 01:16:46 +00:00
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
This commit is contained in:
parent
4003c04fbc
commit
457d7a4579
6 changed files with 121 additions and 37 deletions
|
@ -9,3 +9,23 @@ if (!$java_version.Contains($args[0]))
|
|||
{
|
||||
throw "Unexpected version"
|
||||
}
|
||||
|
||||
if ($args.Count -lt 2 -or !$args[1])
|
||||
{
|
||||
throw "Must supply java path argument"
|
||||
}
|
||||
|
||||
if ($args[1] -ne $Env:JAVA_HOME)
|
||||
{
|
||||
throw "Unexpected path"
|
||||
}
|
||||
|
||||
if ($args.Count -lt 3 -or !$args[2])
|
||||
{
|
||||
throw "Must supply java version argument"
|
||||
}
|
||||
|
||||
if ($args[0] -ne $args[2])
|
||||
{
|
||||
throw "Unexpected version"
|
||||
}
|
||||
|
|
|
@ -1,13 +1,33 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Must supply java version argument"
|
||||
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 "Unexpected version"
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue