author | Walther Neuper <walther.neuper@jku.at> |
Fri, 26 Mar 2021 10:45:05 +0100 | |
changeset 5239 | b4e3883d7b66 |
parent 5229 | 6bf0e95981e3 |
permissions | -rw-r--r-- |
wneuper@5074 | 1 |
/** |
wneuper@5074 | 2 |
* @author Walther Neuper |
wneuper@5074 | 3 |
* Created on Mar 30, 2017 |
wneuper@5074 | 4 |
* (c) due to copyright terms |
wneuper@5074 | 5 |
*/ |
wneuper@5074 | 6 |
|
wneuper@5074 | 7 |
package isac.bridge; |
wneuper@5074 | 8 |
|
wneuper@5074 | 9 |
import java.io.FileNotFoundException; |
wneuper@5074 | 10 |
import java.io.IOException; |
wneuper@5074 | 11 |
import java.io.InputStream; |
wneuper@5074 | 12 |
import java.nio.file.Paths; |
wneuper@5074 | 13 |
import java.util.Properties; |
wneuper@5074 | 14 |
|
walther@5239 | 15 |
import edu.tum.cs.isabelle.api.Configuration; |
walther@5239 | 16 |
import edu.tum.cs.isabelle.api.Environment; |
walther@5239 | 17 |
import edu.tum.cs.isabelle.api.Version; |
walther@5239 | 18 |
import edu.tum.cs.isabelle.japi.JPlatform; |
walther@5239 | 19 |
import edu.tum.cs.isabelle.japi.JSetup; |
walther@5239 | 20 |
import edu.tum.cs.isabelle.japi.JSystem; |
walther@5239 | 21 |
import edu.tum.cs.isabelle.setup.Setup; |
wneuper@5074 | 22 |
|
wneuper@5074 | 23 |
/* |
wneuper@5074 | 24 |
* Connect tests with Isac's mathematics engine. |
wneuper@5074 | 25 |
*/ |
wneuper@5074 | 26 |
public class Isabelle_Isac { |
wneuper@5074 | 27 |
|
wneuper@5074 | 28 |
public static JSystem connect() { |
wneuper@5074 | 29 |
String isabelle_home_ = ""; |
wneuper@5074 | 30 |
InputStream inputStream = null; |
wneuper@5074 | 31 |
try { |
wneuper@5074 | 32 |
Properties prop = new Properties(); |
wneuper@5074 | 33 |
String propFileName = "./properties/BridgeMain.properties"; |
wneuper@5074 | 34 |
inputStream = Isabelle_Isac.class.getClassLoader().getResourceAsStream(propFileName); |
wneuper@5074 | 35 |
if (inputStream != null) { |
wneuper@5074 | 36 |
prop.load(inputStream); |
wneuper@5074 | 37 |
} else { |
wneuper@5074 | 38 |
throw new FileNotFoundException("property file '" + propFileName + "' not found in the classpath"); |
wneuper@5074 | 39 |
} |
wneuper@5074 | 40 |
// get the property value and print it out |
wneuper@5074 | 41 |
isabelle_home_ = prop.getProperty("ISABELLE_HOME"); |
wneuper@5074 | 42 |
} catch (Exception e) { |
wneuper@5074 | 43 |
System.out.println("Exception: " + e); |
wneuper@5074 | 44 |
} finally { |
wneuper@5074 | 45 |
try { inputStream.close(); |
wneuper@5074 | 46 |
} catch (IOException e) { e.printStackTrace(); } |
wneuper@5074 | 47 |
} |
walther@5239 | 48 |
Setup setup = new Setup(Paths.get(isabelle_home_), JPlatform.guess(), |
walther@5239 | 49 |
new Version("2015"), Setup.defaultPackageName()); |
walther@5239 | 50 |
Environment env = JSetup.makeEnvironment(setup); // without Duration |
wneuper@5074 | 51 |
Configuration config = Configuration.fromBuiltin("libisabelle_Isac"); |
walther@5239 | 52 |
return JSystem.create(env, config); |
wneuper@5074 | 53 |
} |
wneuper@5074 | 54 |
|
wneuper@5074 | 55 |
} |