[英]Package Ruby Library (permailer) as .jar (using JRuby)
Essentially, we need to use Premailer ( https://github.com/premailer/premailer ) as part of our Scala backend, however since it is coded in Ruby we need to use something like JRuby
so we can execute it on the JVM. 本质上,我们需要使用Premailer( https://github.com/premailer/premailer )作为Scala后端的一部分,但是由于它是用Ruby编码的,因此我们需要使用类似
JRuby
东西,以便可以在JVM上执行它。
Ideally we would want to create a separate clean .jar
which just contains JRuby
(either as a dependency or in the actual JAR itself), Premailer plus a thin Java
wrapper that would let us call the Premailer API in Java
(and hence in Scala
). 理想情况下,我们希望创建一个单独的clean
.jar
,其中仅包含JRuby
(作为依赖项或在实际的JAR本身中),Premailer以及一个薄的Java
包装器,该包装器使我们可以用Java
(因此也可以在Scala
)调用Premailer API。 。
The idea is then we would obviously just include the premailer jar as a dependency in our Scala
backend through SBT
and just call the thin Java
wrapper. 当时的想法是,我们显然会通过
SBT
将premailer jar作为依赖项包含在我们的Scala
后端中,并只调用瘦Java
包装器。 Does anyone know if there is a tool that lets you do this, or if there is a tutorial on how to do this? 有谁知道是否有工具可以执行此操作,或者是否有有关如何执行此操作的教程?
EDIT: It appears a java wrapper already exists, it is here https://github.com/r-shah/java-premailer-wrapper , so it appears its now just a question of packaging it properly 编辑:看来一个Java包装器已经存在,它在这里https://github.com/r-shah/java-premailer-wrapper ,所以现在看来它只是将其正确包装的问题
seems like the work needed to create an interface (so that you abstract away from JRuby's Java/embed APIs) is done - as you've find out. 正如您所发现的,似乎已经完成了创建接口所需的工作(以便您从JRuby的Java /嵌入式API中抽象出来)。
the project already packages using Maven including the JRuby jar and the ruby dependencies for the premailer gem. 该项目已经使用Maven进行了打包,包括JRuby jar和 premailer gem 的ruby依赖关系 。
while those are not to be found (on Maven Central) they should work as they are auto-generated from https://rubygems.org assets (the rubygems-proxy.torquebox.org does that) ... thus mvn install
locally and you should be all set 虽然找不到这些文件(在Maven Central上),但它们应该可以工作,因为它们是从https://rubygems.org资产自动生成的(rubygems-proxy.torquebox.org可以做到这一点)...因此
mvn install
在本地mvn install
并你应该准备好了
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.