导出的 eclipse-plugin 无法执行 python 脚本

Exported eclipse-plugin is not able to execute python script

我希望有人能帮助我了解如何解决我的问题:

导出的 eclipse-plugin 到 python.exe 和调用的 python 脚本 (test.py) 的路径错误。因此,当插件正常调用脚本时,它会抛出错误。

有没有办法将 python 和相应的 python 文件与 .jar 一起编译,或者是否有其他正确的方法?

我创建了一个通过 ProcessBuilder-class 调用 python 脚本的 eclipse 插件。 python 脚本导入 lxml 并对两个 xml 文件执行一些合并步骤。当我以 "Eclipse Application" 启动插件时,脚本被执行并且一切正常。当我将插件导出为 .jar 文件时,我无法调用 python 脚本,因为它在 .jar 文件中将路径附加到 python.exe 和 test.py(例如“插件.jar/test.py).

// Init the processBuilder
ProcessBuilder procBuilder = new ProcessBuilder(
absolute/path/to/venv/Scripts/python.exe", // Possible workaround: "python",
absolute/path/to/test.py, 
arg1, arg2);

绝对路径的意思是这样的:"C:/Users/user/path/to/project/venv/Scripts/python.exe"(它是通过 "virtualenv venv" 创建的 virtualenv)

如上所述,出现以下错误: 1) 当插件应该调用 test.py 时找不到 "C:/Users/user/eclipse/plugins/plugin.jar_100/src/utils/test.py" 2) java.io.IOExeption: cannot 运行 program "C:\absolute\path\eclipse\plugins\plugin_133.jar\venv\Scripts\python.exe": CreateProcess error=2, 系统找不到指定的文件。

出口 plug-ins 通常会将所有内容打包到一个罐子里。 jar 中的对象不是文件,您无法使用像 ProcessBuilder 这样需要文件的东西来访问它们。

您可以包括

Eclipse-BundleShape: dir

在 MANIFEST.MF 中为 plug-in 构建 plug-in 作为目录而不是 jar。内容将成为普通文件。

如果 plug-in 包含在 'feature' 中,则 'unpack plug-in archive after installation' 选项会覆盖 manifest.mf 设置。