如何在构建项目中使用 Ruby 代码?
如何在 buildr 项目中使用 Ruby?
我在很多单独的项目中使用过 Ruby、JRuby、Java 和 Clojure。我目前正在标准 Ruby 中开发一个模拟应用程序,我想尝试使用 Clojure 后端(我确实喜欢功能代码)以及 JRuby GUI 和测试套件。我还可以看到将来在不同的项目中使用 Scala 作为后端。
我想我要为我的项目尝试一下 buildr (http://buildr.apache.org/),但我注意到 buildr 似乎没有设置为在项目本身内使用 JRuby 代码!这看起来有点愚蠢,因为该工具旨在统一常见的 JVM 语言,并且内置于 ruby 中。
有谁知道如何实现这一点,而不是将输出的 jar 包含在一个独特的、仅限 ruby 的项目中?
How can use Ruby in a buildr project?
I've used Ruby, JRuby, Java, and Clojure in quite a few separate projects. I'm currently working on a simulation app in my standard Ruby that I wanted to try to do with a Clojure backend (I do enjoy the functional code), and JRuby gui and test suite. I could also see using say, Scala, for the backend in a different project in the future.
I think I'm going to give buildr (http://buildr.apache.org/) a try for my project, but I noticed that buildr doesn't seem to be set up to use JRuby code inside the project itself! This seems a little silly, seeing as the tool is meant to unify the common JVM languages and is built in ruby.
Does anyone know how you would accomplish this, short of including the outputted jar in a distinct, ruby only project?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您对于如何使用 (J)Ruby 代码并不是很具体,因此我将从多种可能的方法中为您提供一个示例。
让我们创建一个目录结构,并将Java和Ruby文件放入其中,
Foo.java
内容如下,以及一个简单的
app.rb
启动脚本,您的
buildfile
看起来有点像,(
run
任务记录在 http://buildr.apache.org/more_stuff.html#run),您现在可以通过键入来运行您的应用程序,
并获得以下输出,
You're not very specific about how you want to use your (J)Ruby code so I'll give you one example out of many possible approaches.
Let's create a directory structure and put Java and Ruby files in it,
with the content of
Foo.java
as follows,and a simple
app.rb
startup script,Your
buildfile
would look somewhat like,(the
run
task is documented at http://buildr.apache.org/more_stuff.html#run)and you can now run your application by typing,
and get the following output,
您可以安装构建器来使用 JRuby。
You can install buildr to use JRuby.