我有一个罐子,它的 struct 如下:
main-app/
├─ META-INF/
│ ├─ maven.org.rascalmpl.runmain/
│ │ ├─ pom.xml
│ │ ├─ pom.properties
│ ├─ MANIFEST.MF
├─ rascal/
│ ├─ Main.tpl
│ ├─ MyModule.tpl
├─ Main.rsc
├─ MyModule.rsc
我正在编写一个从JAR运行函数的求值器,到目前为止,我得到了以下内容:
final GlobalEnvironment heap = new GlobalEnvironment();
final ModuleEnvironment top = new ModuleEnvironment("test", heap);
Evaluator eval = new Evaluator(vf, System.in, System.err, System.out, top, heap);
eval.addRascalSearchPathContributor(StandardLibraryContributor.getInstance());
eval.addRascalSearchPath(URIUtil.rootLocation("std"));
ISourceLocation tmp = URIUtil.correctLocation("jar", "", "/path/to/runmain-0.1.0-SNAPSHOT.jar!");
eval.addRascalSearchPath(tmp);
eval.doImport(null, "Main");
eval.doImport(null, "MyModule");
System.out.println(eval.getHeap().existsModule("Main")); // Check if module has been added to heap
eval.call("main", tmp, null);
当我try 运行此命令时,它只打印出false
,然后出现以下异常:
Exception in thread "main" org.rascalmpl.interpreter.staticErrors.ModuleImport: Could not import module Main: can not find in search path
个
如何访问JAR中的.tpl
个文件或.rsc
个文件来调用任意函数?
附言:当我编译JAR时,输出中没有包含RASCAL.MF,有必要吗?