Mercurial > forge
changeset 12443:e7dcc221d754 octave-forge
Check built-in Java support before testing Java-based interfaces
author | prnienhuis |
---|---|
date | Sat, 26 Apr 2014 08:15:08 +0000 |
parents | 74b476ae32eb |
children | f9742be93497 |
files | main/io/inst/private/__chk_java_sprt__.m main/io/inst/private/getodsinterfaces.m main/io/inst/private/getxlsinterfaces.m |
diffstat | 3 files changed, 248 insertions(+), 204 deletions(-) [+] |
line wrap: on
line diff
--- a/main/io/inst/private/__chk_java_sprt__.m Thu Apr 24 20:06:44 2014 +0000 +++ b/main/io/inst/private/__chk_java_sprt__.m Sat Apr 26 08:15:08 2014 +0000 @@ -1,4 +1,4 @@ -## Copyright (C) 2013 Philip Nienhuis +## Copyright (C) 2013,2014 Philip Nienhuis ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -25,12 +25,19 @@ ## 2014-01-08 Tiny style fix function [ tmp1, jcp ] = __chk_java_sprt__ (dbug=0) - - jcp = {}; - tmp1 = 0; + + jcp = {}; + tmp1 = 0; + if (! octave_config_info.features.JAVA) + ## No Java support built in => any further checks are moot + return + endif + try - jcp = javaclasspath ("-all"); # For java pkg >= 1.2.8 - if (isempty (jcp)), jcp = javaclasspath; endif # For java pkg < 1.2.8 + jcp = javaclasspath ("-all"); # For java pkg >= 1.2.8 + if (isempty (jcp)) # & Octave >= 3.7.2 + jcp = javaclasspath; # For java pkg < 1.2.8 + endif ## If we get here, at least Java works. if (dbug > 1) printf ("Java seems to work OK.\n");
--- a/main/io/inst/private/getodsinterfaces.m Thu Apr 24 20:06:44 2014 +0000 +++ b/main/io/inst/private/getodsinterfaces.m Sat Apr 26 08:15:08 2014 +0000 @@ -1,4 +1,4 @@ -## Copyright (C) 2009,2010,2011,2012,2013 Philip Nienhuis +## Copyright (C) 2009,2010,2011,2012,2013,2014 Philip Nienhuis ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -75,13 +75,19 @@ ## 2013-09-29 Treat OCT as any other interface ## 2013-12-06 Updated copyright strings; style fixes ## 2013-12-20 java_invoke -> javaMethod +## 2014-04-24 Skip all Java checks if Octave was built w/o Java support function [odsinterfaces] = getodsinterfaces (odsinterfaces) ## tmp1 = [] (not initialized), 0 (No Java detected), or 1 (Working Java found) persistent tmp1 = []; - persistent jcp; # Java class path + persistent jcp={}; ## Java class path + persistent has_java = []; ## Built-in Java support persistent uno_1st_time = 0; + + if (isempty (has_java)) + has_java = octave_config_info.features.JAVA; + endif if (isempty (odsinterfaces.OTK) && isempty (odsinterfaces.JOD) ... && isempty (odsinterfaces.UNO)) @@ -94,121 +100,133 @@ if (tmp1) # Check Java support again tmp1 = []; - else + elseif (has_java) ## Renew jcp (javaclasspath) as it may have been updated since last call jcp = javaclasspath ("-all"); ## For java pkg >= 1.2.8 - if (isempty (jcp)); jcp = javaclasspath; endif ## For java pkg < 1.2.8 + if (isempty (jcp)) ## & Octave >= 3.7.2 + jcp = javaclasspath; + endif ## For java pkg < 1.2.8 if (isunix && ! iscell (jcp)); jcp = strsplit (char (jcp), pathsep ()); endif - endif - endif - deflt = 0; - - if (isempty (tmp1)) - ## Check Java support - [tmp1, jcp] = __chk_java_sprt__ (); - if (! tmp1) - ## No Java support found - if (isempty (odsinterfaces.OTK) || isempty (odsinterfaces.JOD) ... - || isempty (odsinterfaces.UNO)) - ## Some or all Java-based interface explicitly requested; but no Java support - warning ... - (" No Java support found (no Java JRE? no Java pkg installed AND loaded?)"); - endif - ## Set Java interfaces to 0 anyway as there's no Java support - odsinterfaces.OTK = 0; - odsinterfaces.JOD = 0; - odsinterfaces.UNO = 0; - printf ("\n"); - ## No more need to try any Java interface - return; endif endif + deflt = 0; + + if (has_java) + if (isempty (tmp1)) + ## Check Java support + [tmp1, jcp] = __chk_java_sprt__ (); + if (! tmp1) + ## No Java support found + if (isempty (odsinterfaces.OTK) || isempty (odsinterfaces.JOD) ... + || isempty (odsinterfaces.UNO)) + ## Some or all Java-based interface explicitly requested; but no Java support + warning ... + (" No Java support found (no Java JRE or JDK?)\n"); + endif + ## Set Java-based interfaces to 0 anyway as there's no Java support + odsinterfaces.OTK = 0; + odsinterfaces.JOD = 0; + odsinterfaces.UNO = 0; + printf ("\n"); + ## No more need to try any Java interface + return; + endif + endif - ## Try Java & ODF toolkit - if (isempty (odsinterfaces.OTK)) - odsinterfaces.OTK = 0; - entries = {"odfdom", "xercesImpl"}; - ## Only under *nix we might use brute force: e.g., strfind(classpath, classname); - ## under Windows we need the following more subtle, platform-independent approach: - if (chk_jar_entries (jcp, entries) >= numel (entries)) - ## Apparently all requested classes present. - ## Only now we can check for proper odfdom version (only 0.7.5 & 0.8.6-0.8.8 work OK). - ## The odfdom team deemed it necessary to change the version call so we need this: - odfvsn = " "; - try - ## New in 0.8.6 - odfvsn = ... - javaMethod ("getOdfdomVersion", "org.odftoolkit.odfdom.JarManifest"); - catch - odfvsn = ... - javaMethod ("getApplicationVersion", "org.odftoolkit.odfdom.Version"); - end_try_catch - ## For odfdom-incubator (= 0.8.8+), strip extra info - odfvsn = regexp (odfvsn, '\d\.\d\.\d', "match"){1}; - if (! (strcmp (odfvsn, "0.7.5") || strcmp (odfvsn, "0.8.6") ... - || strcmp (odfvsn, "0.8.7") || strfind (odfvsn, "0.8.8"))) - warning ("\nodfdom version %s is not supported - use v. 0.8.6, 0.8.7 or 0.8.8\n", odfvsn); + ## Try Java & ODF toolkit + if (isempty (odsinterfaces.OTK)) + odsinterfaces.OTK = 0; + entries = {"odfdom", "xercesImpl"}; + ## Only under *nix we might use brute force: e.g., strfind(classpath, classname); + ## under Windows we need the following more subtle, platform-independent approach: + if (chk_jar_entries (jcp, entries) >= numel (entries)) + ## Apparently all requested classes present. + ## Only now we can check for proper odfdom version (only 0.7.5 & 0.8.6-0.8.8 work OK). + ## The odfdom team deemed it necessary to change the version call so we need this: + odfvsn = " "; + try + ## New in 0.8.6 + odfvsn = ... + javaMethod ("getOdfdomVersion", "org.odftoolkit.odfdom.JarManifest"); + catch + odfvsn = ... + javaMethod ("getApplicationVersion", "org.odftoolkit.odfdom.Version"); + end_try_catch + ## For odfdom-incubator (= 0.8.8+), strip extra info + odfvsn = regexp (odfvsn, '\d\.\d\.\d', "match"){1}; + if (! (strcmp (odfvsn, "0.7.5") || strcmp (odfvsn, "0.8.6") ... + || strcmp (odfvsn, "0.8.7") || strfind (odfvsn, "0.8.8"))) + warning ("\nodfdom version %s is not supported - use v. 0.8.6, 0.8.7 or 0.8.8\n", odfvsn); + else + if (strcmp (odfvsn, "0.7.5")) + warning (["odfdom v. 0.7.5 support won't be maintained " ... + "- please upgrade to 0.8.8"]); + endif + odsinterfaces.OTK = 1; + printf ("OTK"); + if (deflt) + printf ("; "); + else + printf ("*; "); + deflt = 1; + endif + endif + odsinterfaces.odfvsn = odfvsn; else - if (strcmp (odfvsn, "0.7.5")) - warning (["odfdom v. 0.7.5 support won't be maintained " ... - "- please upgrade to 0.8.8"]); - endif - odsinterfaces.OTK = 1; - printf ("OTK"); + warning ("\nNot all required classes (.jar) in classpath for OTK"); + endif + endif + + ## Try Java & jOpenDocument + if (isempty (odsinterfaces.JOD)) + odsinterfaces.JOD = 0; + entries = {"jOpenDocument"}; + if (chk_jar_entries (jcp, entries) >= numel (entries)) + odsinterfaces.JOD = 1; + printf ("JOD"); if (deflt) printf ("; "); - else + else printf ("*; "); deflt = 1; endif + else + warning ("\nNot all required classes (.jar) in classpath for JOD"); endif - odsinterfaces.odfvsn = odfvsn; - else - warning ("\nNot all required classes (.jar) in classpath for OTK"); - endif - endif - - ## Try Java & jOpenDocument - if (isempty (odsinterfaces.JOD)) - odsinterfaces.JOD = 0; - entries = {"jOpenDocument"}; - if (chk_jar_entries (jcp, entries) >= numel (entries)) - odsinterfaces.JOD = 1; - printf ("JOD"); - if (deflt) - printf ("; "); - else - printf ("*; "); - deflt = 1; - endif - else - warning ("\nNot all required classes (.jar) in classpath for JOD"); endif - endif - ## Try Java & UNO - if (isempty (odsinterfaces.UNO)) - odsinterfaces.UNO = 0; - ## entries(1) = not a jar but a directory (<OOo_install_dir/program/>) - entries = {"program", "unoil", "jurt", "juh", "unoloader", "ridl"}; - if (chk_jar_entries (jcp, entries) >= numel (entries)) - odsinterfaces.UNO = 1; - printf ("UNO"); - if (deflt) - printf ("; "); + ## Try Java & UNO + if (isempty (odsinterfaces.UNO)) + odsinterfaces.UNO = 0; + ## entries(1) = not a jar but a directory (<OOo_install_dir/program/>) + entries = {"program", "unoil", "jurt", "juh", "unoloader", "ridl"}; + if (chk_jar_entries (jcp, entries) >= numel (entries)) + odsinterfaces.UNO = 1; + printf ("UNO"); + if (deflt) + printf ("; "); + else + printf ("*; "); + deflt = 1; + uno_1st_time = min (++uno_1st_time, 2); + endif else - printf ("*; "); - deflt = 1; - uno_1st_time = min (++uno_1st_time, 2); + warning ("\nOne or more UNO classes (.jar) missing in javaclasspath"); endif - else - warning ("\nOne or more UNO classes (.jar) missing in javaclasspath"); - endif - endif + endif - ## Native Octave + else + ## Set Java-based interfaces to 0 anyway as there's no Java support + odsinterfaces.OTK = 0; + odsinterfaces.JOD = 0; + odsinterfaces.UNO = 0; + + ## End of has_java block + endif + + ## Native Octave (OCT) if (isempty (odsinterfaces.OCT)) ## Nothing to check, always supported odsinterfaces.OCT = 1;
--- a/main/io/inst/private/getxlsinterfaces.m Thu Apr 24 20:06:44 2014 +0000 +++ b/main/io/inst/private/getxlsinterfaces.m Sat Apr 26 08:15:08 2014 +0000 @@ -1,4 +1,4 @@ -## Copyright (C) 2009,2010,2011,2012,2013 Philip Nienhuis +## Copyright (C) 2009,2010,2011,2012,2013,2014 Philip Nienhuis ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -74,15 +74,21 @@ ## 2013-12-06 Updated copyright strings; style fixes ## 2013-12-27 Slight updates to texinfo header ## 2013-12-28 Added check for OpenXLS version 10 -## 2013-12-29 Added gwt-servlet-deps.jar to OpenXLS dependencies +## 2013-12-29 Added gwt-servlet-deps.jar to OpenXLS dependencies +## 2014-04-24 Skip all Java checks if Octave was built w/o Java support function [xlsinterfaces] = getxlsinterfaces (xlsinterfaces) ## tmp1 = [] (not initialized), 0 (No Java detected), or 1 (Working Java found) persistent tmp1 = []; persistent tmp2 = []; + persistent has_java = []; ## Built-in Java support persistent jcp; ## Java class path persistent uno_1st_time = 0; + + if (isempty (has_java)) + has_java = octave_config_info.features.JAVA; + endif if (isempty (xlsinterfaces.COM) && isempty (xlsinterfaces.POI) ... && isempty (xlsinterfaces.JXL) && isempty (xlsinterfaces.OXS) ... @@ -93,11 +99,11 @@ elseif (isempty (xlsinterfaces.COM) || isempty (xlsinterfaces.POI) ... || isempty (xlsinterfaces.JXL) || isempty (xlsinterfaces.OXS) ... || isempty (xlsinterfaces.UNO)) - ## Can't be first call. Here one of the Java interfaces is requested + ## Can't be first call. Here one of the Java interfaces may be requested if (! tmp1) ## Check Java support again tmp1 = []; - else + elseif (has_java) ## Renew jcp (javaclasspath) as it may have been updated since last call jcp = javaclasspath ("-all"); ## For java pkg >= 1.2.8 if (isempty (jcp)) @@ -137,113 +143,125 @@ endif end_try_catch endif - - if (isempty (tmp1)) - ## Check Java support - [tmp1, jcp] = __chk_java_sprt__ (); - if (! tmp1) - ## No Java support found - tmp1 = 0; - if (isempty (xlsinterfaces.POI) || isempty (xlsinterfaces.JXL)... - || isempty (xlsinterfaces.OXS) || isempty (xlsinterfaces.UNO)) - ## Some or all Java-based interface(s) explicitly requested but no Java support - warning ... - (" No Java support found (no Java JRE? no Java pkg installed AND loaded?)"); + + if (has_java) + if (isempty (tmp1)) + ## Check Java support + [tmp1, jcp] = __chk_java_sprt__ (); + if (! tmp1) + ## No Java support found + tmp1 = 0; + if (isempty (xlsinterfaces.POI) || isempty (xlsinterfaces.JXL)... + || isempty (xlsinterfaces.OXS) || isempty (xlsinterfaces.UNO)) + ## Some or all Java-based interface(s) explicitly requested but no Java support + warning ... + (" No Java support found (no Java JRE? no Java pkg installed AND loaded?)"); + endif + ## Set Java-based interfaces to 0 anyway as there's no Java support + xlsinterfaces.POI = 0; + xlsinterfaces.JXL = 0; + xlsinterfaces.OXS = 0; + xlsinterfaces.UNO = 0; + printf ("\n"); + ## No more need to try any Java interface + return endif - ## Set Java interfaces to 0 anyway as there's no Java support - xlsinterfaces.POI = 0; - xlsinterfaces.JXL = 0; - xlsinterfaces.OXS = 0; - xlsinterfaces.UNO = 0; - printf ("\n"); - ## No more need to try any Java interface - return endif - endif - ## Try Java & Apache POI - if (isempty (xlsinterfaces.POI)) - xlsinterfaces.POI = 0; - ## Check basic .xls (BIFF8) support - entries = {{"apache-poi.", "poi-3"}, {"apache-poi-ooxml.", "poi-ooxml-3"}}; - ## Only under *nix we might use brute force: e.g., strfind (classname, classpath); - ## under Windows we need the following more subtle, platform-independent approach: - if (chk_jar_entries (jcp, entries) >= numel (entries)) - xlsinterfaces.POI = 1; - printf ("POI"); - endif - ## Check OOXML support - entries = {{"xbean", "xmlbean"}, {"apache-poi-ooxml-schemas", "poi-ooxml-schemas"}, "dom4j"}; - if (chk_jar_entries (jcp, entries) >= numel (entries)) - printf (" (& OOXML)"); - endif - if (xlsinterfaces.POI) - if (deflt) - printf ("; "); - else - printf ("*; "); - deflt = 1; + ## Try Java & Apache POI + if (isempty (xlsinterfaces.POI)) + xlsinterfaces.POI = 0; + ## Check basic .xls (BIFF8) support + entries = {{"apache-poi.", "poi-3"}, {"apache-poi-ooxml.", "poi-ooxml-3"}}; + ## Only under *nix we might use brute force: e.g., strfind (classname, classpath); + ## under Windows we need the following more subtle, platform-independent approach: + if (chk_jar_entries (jcp, entries) >= numel (entries)) + xlsinterfaces.POI = 1; + printf ("POI"); + endif + ## Check OOXML support + entries = {{"xbean", "xmlbean"}, {"apache-poi-ooxml-schemas", ... + "poi-ooxml-schemas"}, "dom4j"}; + if (chk_jar_entries (jcp, entries) >= numel (entries)) + printf (" (& OOXML)"); + endif + if (xlsinterfaces.POI) + if (deflt) + printf ("; "); + else + printf ("*; "); + deflt = 1; + endif endif endif - endif - ## Try Java & JExcelAPI - if (isempty (xlsinterfaces.JXL)) - xlsinterfaces.JXL = 0; - entries = {"jxl"}; - if (chk_jar_entries (jcp, entries) >= numel (entries)) - xlsinterfaces.JXL = 1; - printf ("JXL"); - if (deflt) - printf ("; "); - else - printf ("*; "); - deflt = 1; + ## Try Java & JExcelAPI + if (isempty (xlsinterfaces.JXL)) + xlsinterfaces.JXL = 0; + entries = {"jxl"}; + if (chk_jar_entries (jcp, entries) >= numel (entries)) + xlsinterfaces.JXL = 1; + printf ("JXL"); + if (deflt) + printf ("; "); + else + printf ("*; "); + deflt = 1; + endif endif endif - endif - ## Try Java & OpenXLS - if (isempty (xlsinterfaces.OXS)) - xlsinterfaces.OXS = 0; - entries = {"openxls", "gwt-servlet-deps"}; - if (chk_jar_entries (jcp, entries) >= numel (entries)) - ## OK, jar in the javaclasspath. Check version (should be >= 10 - try - ## ...a method that is first introduced in OpenXLS v.10 - javaMethod ("getVersion", "com.extentech.ExtenXLS.GetInfo"); - ## If we get here, we do have v. 10 - xlsinterfaces.OXS = 1; - printf ("OXS"); - if (deflt) - printf ("; "); - else - printf ("*; "); - deflt = 1; - endif - catch - ## Wrong OpenXLS.jar version (probably <= 6.08). V. 10 is required now - warning ("OpenXLS.jar version is outdated; please upgrade to v.10"); - end_try_catch - endif - endif - - ## Try Java & UNO - if (isempty (xlsinterfaces.UNO)) - xlsinterfaces.UNO = 0; - ## entries0(1) = not a jar but a directory (<00o_install_dir/program/>) - entries = {"program", "unoil", "jurt", "juh", "unoloader", "ridl"}; - if (chk_jar_entries (jcp, entries) >= numel (entries)) - xlsinterfaces.UNO = 1; - printf ("UNO"); - if (deflt); - printf ("; "); - else - printf ("*; "); - deflt = 1; - uno_1st_time = min (++uno_1st_time, 2); + ## Try Java & OpenXLS + if (isempty (xlsinterfaces.OXS)) + xlsinterfaces.OXS = 0; + entries = {"openxls", "gwt-servlet-deps"}; + if (chk_jar_entries (jcp, entries) >= numel (entries)) + ## OK, jar in the javaclasspath. Check version (should be >= 10 + try + ## ...a method that is first introduced in OpenXLS v.10 + javaMethod ("getVersion", "com.extentech.ExtenXLS.GetInfo"); + ## If we get here, we do have v. 10 + xlsinterfaces.OXS = 1; + printf ("OXS"); + if (deflt) + printf ("; "); + else + printf ("*; "); + deflt = 1; + endif + catch + ## Wrong OpenXLS.jar version (probably <= 6.08). V. 10 is required now + warning ("OpenXLS.jar version is outdated; please upgrade to v.10"); + end_try_catch endif endif + + ## Try Java & UNO + if (isempty (xlsinterfaces.UNO)) + xlsinterfaces.UNO = 0; + ## entries0(1) = not a jar but a directory (<00o_install_dir/program/>) + entries = {"program", "unoil", "jurt", "juh", "unoloader", "ridl"}; + if (chk_jar_entries (jcp, entries) >= numel (entries)) + xlsinterfaces.UNO = 1; + printf ("UNO"); + if (deflt); + printf ("; "); + else + printf ("*; "); + deflt = 1; + uno_1st_time = min (++uno_1st_time, 2); + endif + endif + endif + + else + ## Set Java-based interfaces to 0 anyway as there's no Java support + xlsinterfaces.POI = 0; + xlsinterfaces.JXL = 0; + xlsinterfaces.OXS = 0; + xlsinterfaces.UNO = 0; + + ## End of has_java block endif ## Native Octave @@ -259,7 +277,8 @@ endif endif - ## ---- Other interfaces here, similar to the ones above + ## ---- Other interfaces here, similar to the ones above. + ## Java interfaces should be in the has-java if-block if (deflt) printf ("(* = default interface)\n");