How do you add a ruby file to an existing project

2019-03-01 05:54发布

问题:

I've installed the Dynamic Languages Toolkit (DLTK) in Eclipse 3.6. But I can't figure out how to create a Ruby file in an existing Java project.

Doing the obvious thing (New -> Empty Ruby Script) just gives the error message "Source folder is not a correct project". Do I have to modify the project in some way to tell DLTK that it's OK to add Ruby files to it?

(Adding the file outside of Eclipse does work.)

回答1:

Do the following steps (has worked for me):

  1. Create a java project, or visit an existing one.
  2. Select in the directory you want the ruby file to live in the menu entry New file and enter in the dialog the filename my_file.rb. The essential part is the extension, because this will ensure that the ruby mechanisms are in place.
  3. Enter in the new ruby file def and press CTRL-SPACE, you should see as a result the list with def - method definition (the template), def and defined?. This is all part of the ruby text editor.

So it is possible to mix java and ruby files in the same project, that has as nature java. The only thing I has noticed is that the run menu entry only allows you to start the dialog Run As > Run Configurations... and enter there the necessary parameters to start your ruby script.