X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=utils%2Fgetdown%2Fjalviewc.ps1;h=d3bde6aec80a1e2093b81e91793888ec6bbc79f7;hb=6bcc1d250a895ef8d45d750048a60381d9206396;hp=300bd9eff2c8259af1570d6c45e2cc83628548ed;hpb=9586ff5036f9b7995276adcabf713ee780115d88;p=jalview.git diff --git a/utils/getdown/jalviewc.ps1 b/utils/getdown/jalviewc.ps1 index 300bd9e..d3bde6a 100755 --- a/utils/getdown/jalviewc.ps1 +++ b/utils/getdown/jalviewc.ps1 @@ -1,30 +1,34 @@ #!/usr/bin/env pwsh -# save first parameter +# save args and first parameter $ARGS = $args $ARG1 = $args[0] -# parent dir of this script (should be the getdown app dir) -$DIR = Split-Path $MyInvocation.MyCommand.Path -Parent +# parent dir of this script (should be the getdown app dir). Follow symlinks. +$TARGET = ( Get-Item $MyInvocation.MyCommand.Path ).Target +$DIR = ( $TARGET -eq $null ) ? ( Split-Path $MyInvocation.MyCommand.Path -Parent ) : ( Split-Path $TARGET -Parent ) # insert an "-open" parameter to Jalview's ARGS if ARG1 is non-zero-length, and not "open" or starts with a "-" -if ( $ARG1.length -gt 0 -and (-not $ARG1.StartsWith("-")) -and $ARG1 -ne "open" ) { +if ( $ARG1.length -gt 0 -and ( -not $ARG1.StartsWith("-") ) -and $ARG1 -cne "open" ) { $ARGS = "-open " + $ARGS } $APPDIR = $DIR -$JAVA = "${APPDIR}\jre\bin\java.exe" -$GETDOWNTXT = "${APPDIR}\getdown.txt" +$JAVAEXE = ( $IsWindows ? "java.exe" : "java" ) +$JAVA = Join-Path -Path $APPDIR -ChildPath ( "jre/" + ( $IsMacOs ? "Contents/Home/" : "" ) + "bin/${JAVAEXE}" ) +$GETDOWNTXT = Join-Path -Path $APPDIR -ChildPath "getdown.txt" -if (-not (Test-Path -Path "${GETDOWNTXT}")) { +# look for getdown.txt -- needed to create classpath +if ( -not ( Test-Path -Path "${GETDOWNTXT}" ) ) { throw "Cannot find getdown.txt" } -if (-not (Test-Path -Path "${JAVA}")) { - Write-Host "Cannot find bundled java.exe. Using system and hoping for the best!" - $JAVA = "java.exe" +# look for bundled JRE. Might not be there if unix installer used in which case just invoke "java" +if ( -not ( Test-Path -Path "${JAVA}" ) ) { + Write-Host "Cannot find bundled ${JAVAEXE}. Using system ${JAVAEXE} and hoping for the best!" + $JAVA = $JAVAEXE } -$CLASSPATH = (Select-String -Path "${GETDOWNTXT}" -AllMatches -Pattern "code\s*=\s*(.*)$" | foreach { "$DIR\$($_.Matches.Groups[1].Value -replace "/", "\")" }) -join ";" +$CLASSPATH = ( Select-String -Path "${GETDOWNTXT}" -AllMatches -Pattern "code\s*=\s*(.*)$" | foreach { Join-Path -Path $DIR -ChildPath $($_.Matches.Groups[1].Value ) } ) -join ( $IsWindows ? ";" : ":" ) Invoke-Expression -Command "${JAVA} -cp '${CLASSPATH}' jalview.bin.Launcher $ARGS"