Changeset 31983 for main


Ignore:
Timestamp:
09/22/17 20:10:10 (3 years ago)
Author:
ak19
Message:

Forgot to bring the Windows setup.bat script up to speed with the changes for Mac/Linux made in commit 31972 (also related to bugfix in perl in 31972 and comment of 31973): Set the Java environment in GS2, either to the bundled JRE or anything already on the system found by search4j, so that Lucene can find and Java when building. Else a lucene collection fails at lucene_passes.pl.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/setup.bat

    r31854 r31983  
    158158@call "!GSDLHOME!\bin\script\checkwritability.bat"
    159159
     160::::::::::::::::::::::::::::::
     161if "!GSDL3SRCHOME!" == "" (goto javacheck) else (goto done)
     162
     163:javacheck
     164:: Only for GS2: work out java, and if the bundled jre is found, then set Java env vars with it
     165:: Then the same java will be consistently available for all aspects of GS2 (server or GLI, and any subshells these launch)
     166echo.
     167set MINIMUM_JAVA_VERSION=1.5.0_00
     168echo GS2 installation: Checking for Java of version !MINIMUM_JAVA_VERSION! or above
     169
     170set BUNDLED_JRE=!GSDLHOME!\packages\jre
     171if exist "!BUNDLED_JRE!" (
     172    set HINT=!BUNDLED_JRE!
     173) else (
     174    echo No bundled JRE
     175    set HINT=
     176)
     177
     178set SEARCH4J_EXECUTABLE=!GSDLHOME!\bin\!GSDLOS!\search4j.exe
     179if not exist "!SEARCH4J_EXECUTABLE!" (
     180    echo Can't check for java, no Search4j 
     181    if not exist "!BUNDLED_JRE!" echo Ensure Java environment variables are set ^(either JAVA_HOME or JRE_HOME and on PATH^) & goto done
     182    :: else use Bundled JRE
     183    echo Will use the bundled JRE and unset any JAVA_HOME to prevent conflicts
     184    set JAVA_HOME=
     185    set JRE_HOME=!BUNDLED_JRE!
     186    set PATH=!BUNDLED_JRE!\bin;!PATH!
     187    goto done
     188)
     189
     190for /F "tokens=*" %%r in ('bin\!GSDLOS!\search4j.exe -p "!HINT!" -m !MINIMUM_JAVA_VERSION!') do set GS_JAVA_HOME=%%r
     191
     192if "!GS_JAVA_HOME!" == "" (
     193    if not exist "!BUNDLED_JRE!" echo There's no bundled JRE.
     194    echo setup.bat: Could not find Java in the environment or installation.
     195    echo Set JAVA_HOME or JRE_HOME, and put it on the PATH, if working with Java tools like Lucene.
     196    goto done
     197)
     198
     199:: found java, now GS_JAVA_HOME env vars set, set JAVA_HOME else JRE_HOME
     200
     201if "!GS_JAVA_HOME!" == "!BUNDLED_JRE!" (   
     202    :: since our bundled JRE was selected by search4j and we'll be using that, clearing any existing JAVA_HOME to prevent version conflicts
     203    echo Found a bundled JRE. Setting up GS2's Java environment to use this ^(and unsetting any JAVA_HOME to prevent version conflicts^)
     204    set JAVA_HOME=
     205    set JRE_HOME=!BUNDLED_JRE!
     206    set PATH=!BUNDLED_JRE!\bin;!PATH!
     207    goto done
     208)
     209
     210:: Otherwise, the java that search4j found is not the bundled jre. In that case
     211:: if JAVA_HOME or JRE_HOME is already set to the Java found, then PATH presumably would already be set too.
     212if "!JAVA_HOME!" == "!GS_JAVA_HOME!" (
     213    echo Looks like the Java environment is already set up with a JAVA_HOME
     214    ::echo Looks like the Java environment is already set up with a JAVA_HOME, unsetting any JRE_HOME   
     215    goto done
     216)
     217if "!JRE_HOME!" == "!GS_JAVA_HOME!" (
     218    echo Looks like the Java environment is already set up with a JRE_HOME, unsetting any JAVA_HOME to prevent java version conflicts
     219    set JAVA_HOME=
     220    goto done
     221)
     222
     223:: if Java env vars not already set, then set them to the GS_JAVA_HOME found
     224echo Found a Java on the system. Setting up GS2's Java environment to use this
     225::echo Found a Java on the system. Setting up GS2's Java environment to use this: !GS_JAVA_HOME!
     226set PATH=!GS_JAVA_HOME!\bin;!PATH!
     227:: extract the last 4 chars from folder name. Could be \jre or jre\ or otherwise
     228set javafoldername=!GS_JAVA_HOME:~-4!
     229:: now can test if the foldername contains jre or otherwise, and based on that set either JAVA_HOME or JRE_HOME
     230:: https://stackoverflow.com/questions/7005951/batch-file-find-if-substring-is-in-string-not-in-a-file
     231:: https://ss64.com/nt/syntax-substring.html
     232if /i "x!javafoldername:jre=!" == "x!javafoldername!" (
     233    echo Setting JAVA_HOME, and unsetting any JRE_HOME to prevent version conflicts
     234    set JAVA_HOME=!GS_JAVA_HOME!
     235    set JRE_HOME=
     236) else (
     237    echo Setting JRE_HOME, and unsetting any JAVA_HOME to prevent version conflicts
     238    set JRE_HOME=!GS_JAVA_HOME!
     239    set JAVA_HOME=
     240)
     241
     242::::::::::::::::::::::::::::::
     243
    160244:done
    161245popd
    162 endlocal & set PATH=%PATH%& set GSDLHOME=%GSDLHOME%& set GSDLOS=%GSDLOS%
     246endlocal & set PATH=%PATH%& set GSDLHOME=%GSDLHOME%& set GSDLOS=%GSDLOS%& set JRE_HOME=%JRE_HOME%& set JAVA_HOME=%JAVA_HOME%
     247
     248if not "%JAVA_HOME%" == "" echo JAVA_HOME: %JAVA_HOME%
     249if not "%JRE_HOME%" == "" echo JRE_HOME: %JRE_HOME%
     250if "%JAVA_HOME%" == "" if "%JRE_HOME%" == "" echo Warning: Neither JAVA_HOME nor JRE_HOME set. Ensure one is set and on PATH.
    163251
    164252:: Perl >= v5.18.* randomises map iteration order within a process
Note: See TracChangeset for help on using the changeset viewer.