Skip to content

Commit

Permalink
add arg
Browse files Browse the repository at this point in the history
  • Loading branch information
carltimmer committed Sep 25, 2024
1 parent 29faa62 commit f2a0f8b
Showing 1 changed file with 39 additions and 15 deletions.
54 changes: 39 additions & 15 deletions setup_java
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,58 @@
# Script to setup the evio directory to use to correct version
# of the supporting jar files.
# The choice is based on the version of java in the path.
# JAVA_HOME must be set.
# If java is not in the path, then default to java 8.
# This can be overwritten by giving the major java version number as an arg

# Check if Java is available in the path
if ( ! $?JAVA_HOME ) then
echo "Java is not installed or not found in the path."
exit 1
endif
# Use java 8 jars by default
set majorVersion = 8

# Check if "java" is in the PATH
set javaPath = `which java >& /dev/null`

# Check the exit status of the "which" command
if ($status != 0) then
echo "Java is not in the PATH, use java 8 jars by default"
else
set javaPath = `which java`
echo "Java is located at: $javaPath"

# Capture the Java version string
set javaVersion = `java -version |& grep "version" | awk '{print $3}' | tr -d '"'`

# Capture the Java version string
set javaVersion = `java -version |& grep "version" | awk '{print $3}' | tr -d '"'`
# Extract the major version
set majorVersion = `echo $javaVersion | awk -F. '{print $1}'`

# Extract the major version
set majorVersion = `echo $javaVersion | awk -F. '{print $1}'`
# If major version is "1", extract the second number (for Java 1.x, where x is the real version)
if ( "$majorVersion" == "1" ) then
set majorVersion = `echo $javaVersion | awk -F. '{print $2}'`
endif

# If major version is "1", extract the second number (for Java 1.x, where x is the real version)
if ( "$majorVersion" == "1" ) then
set majorVersion = `echo $javaVersion | awk -F. '{print $2}'`
# Output the major Java version
echo "Found java major version $majorVersion in path"
endif


# Check if there is exactly one argument which can override java version
if ($#argv == 1) then
# Check if the argument is an integer (0 - 99)
if ("$argv[1]" =~ [0-9] || "$argv[1]" =~ [0-9][0-9]) then
# Parse the argument as an integer
set majorVersion = $argv[1]
echo "Argument is a valid integer, set java major version: $majorVersion"
else
echo "Argument $argv[1] is NOT a valid integer"
endif
endif

# Output the major Java version
echo "Java major version: $majorVersion"

# Define the destination directory
set destDir = "java/jars"

# Remove all jar files from destination
rm $destDir/*.jar


# Define the source directory
if ($majorVersion < 15) then
set srcDir = "java/jars/java8"
Expand Down

0 comments on commit f2a0f8b

Please sign in to comment.