ScalaMacros and Eclipse

限于喜欢 提交于 2019-12-05 05:00:53
Mikaël Mayer

How to create a macro project to link to an existing project:

  • Create a scala project named for example ProjectMacros, put a file named for example Macros.scala containing macros in it. This project should compile without problems, because there are only macros.
  • Right-click on the existing scala project, then "Properties". The Properties window opens.
  • In the Java Build Path section:
    • Under the tab Projects, add ProjectMacros.
    • Under the tab Libraries, click Add Class Folder, and select the ProjectMacros/bin directory.
  • In the Project References section, check ProjectMacros

Now, after adding in the existing project an import like import Macros._ you can use the macros functions and annotations.

Well, separating macro implementation and macro invocation in two differents projects (and playing with project references) seems to solve the issue. Anyway, the Scala-IDE plugin has been notably improved with its version for Scala 2.10-M4 (in terms of macro support), so I recommend to update to it.

You could probably use Ant for building, but since you are saying that you already achieved this with terminal I think it would be easier to create script, and run it using custom builder (go to project properties, click Builders -> New... -> Program and then set it up to run your script.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!