将 Jython 与 Maven 结合使用
我有一个 Maven 模块,它依赖于我通过 jython 代码访问的各种其他 Maven 依赖项。
我现在已经完成了,我想将项目编译为 .jar,或者甚至只是运行它而不编译,但我不知道从哪里开始。
有谁知道如何运行一些 .py 文件来访问其他包中的一些 Java 库?
另外,当一切都完成后,如何将其编译为 .jar 文件?
谢谢!
I have a Maven module, that depends on various other Maven dependencies by which I am accessing through my jython code.
I am now done, and I would like to compile the project as a .jar, or even just run it without compiling, but I have no clue where to start.
Does anyone have any idea how I can run some .py files that accesses some Java libraries in other packages?
Also, how can I compile it as a .jar file when all is done and good?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
编译和集成 python
使用 jython-compile-maven-plugin。它允许您部署一个包含 jython 和库的独立项目。
有关此插件的演示,请参阅演示项目及其 源代码。它展示了如何
启动 python 控制台——查看AbstractInitJython 和 InitJython 了解如何启动 python/jython 控制台,如何执行 python 代码片段,以及如何运行 python 脚本。
包含 python 库——该插件还在打包阶段下载并捆绑 python 库(使用 easy_install),并将它们添加到 jar 中。生成的 jar 可以包含项目的所有库、所有 pom 依赖项以及请求的所有 python 库。演示项目使用“nose”python 库(请参阅 pom 文件)展示了这一点。
测试 python / jython 代码
python-test-maven-plugin 允许您与正常的 junit 测试一起运行 python 测试。演示项目(查看源代码 源代码)展示了标准Python单元测试(使用nose)和BDD(行为测试)与lettuce-clone freshen的使用。
sourceforge 伞式项目是 http://mavenjython.sourceforge.net/
与 maven-jython-plugin 不同,它们不不要使用过时的 jythonc 编译器。
Compiling and integrating python
Use the jython-compile-maven-plugin. It allows you to deploy a standalone project that includes jython with libraries.
For demonstration of this plugin, see the demo project and its source code. It shows how to
launch a python console -- look at AbstractInitJython and InitJython on how to launch a python/jython console, how to execute python code snippets, and how to run a python script.
include python libraries -- the plugin also downloads and bundles python libraries (using easy_install) in the package phase, and adds them to the jar. The resulting jar can have all the libraries of the project, all pom dependencies and all the python libraries requested. The demo project shows this with the "nose" python library (see the pom file).
Testing python / jython code
The python-test-maven-plugin allows you to run your python tests alongside the normal junit tests. The demo project (look at the source at source code) shows the use of standard python unit tests (with nose) and BDD (behaviour testing) with the lettuce-clone freshen.
The sourceforge umbrella project is http://mavenjython.sourceforge.net/
Unlike maven-jython-plugin, they don't use the outdated jythonc compiler.
看起来有一个 maven-jython-plugin 允许将 jython 源文件编译为 Java 类文件。
It looks like there is a maven-jython-plugin allowing to compile jython source files to Java class files.
我已经大概找到了这个问题的答案。我不应该尝试编译它,而是用 Java 包装 python 代码: http://jythonpodcast.hostjava.net/jythonbook/en/1.0/JythonAndJavaIntegration.html#using-jython-within-java-applications
I've kinda figured out my answer to this. I shouldn't have tried to compile it, but instead wrap the python code with Java: http://jythonpodcast.hostjava.net/jythonbook/en/1.0/JythonAndJavaIntegration.html#using-jython-within-java-applications
jython 的编译器部分 jythonc 从 2.5 开始已弃用 -- http://wiki.python.org/ jython/ReplaceJythonc——替代品正在开发中。
The compiler portion of jython, jythonc, is deprecated as of 2.5 -- http://wiki.python.org/jython/ReplaceJythonc -- a replacement is in the works.