在 Eclipse 项目中混合 AspectJ 和 Scala

发布于 2024-10-16 08:11:50 字数 148 浏览 1 评论 0原文

有人能够让 Scala 和 AspectJ (AJDT) 在 Eclipse 3.6 中很好地协同工作吗?

看来 Scala 的编织器与 AspectJ 的编织器冲突。 我希望我只是错过了一些东西。

编辑:在同一个项目中玩得很好

Any one been able to get a Scala and AspectJ (AJDT) to play nicely together in Eclipse 3.6?

It seems Scala's weaver conflicts with AspectJ's weaver.
I'm hoping I'm just missing something.

Edit: Play nicely in the same project

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

云仙小弟 2024-10-23 08:11:50

根据您上面的评论,您似乎希望在一个项目中同时使用 AspectJ 构建器和 Scala 构建器。这是不可能的。每个编译器都委托给自己的编译器,并且这两个编译器(尚)不兼容。 Scala 编译器可以一起构建 Java 和 Scala 代码,AspectJ 编译器可以一起构建 AspectJ 和 Java 代码,但仅此而已。

如果您希望方面应用于 Scala 代码,则必须将 AspectJ 和 Scala 代码分离到不同的项目中,然后将 Scala 项目添加到 AspectJ 项目的 inpath 中。

如果您从 ant 或命令行进行编译,这与您需要执行的操作相同。

Based on your comment above, it looks like you want a single project to use both the AspectJ builder and the Scala builder. This is not possible. Each one delegates to its own compiler and the two compilers are not (yet) compatible. The Scala compiler can build Java and Scala code together, and the AspectJ compiler can build AspectJ and Java code together, but that's it.

If you want aspects to apply to your Scala code, you must separate your AspectJ and Scala code into different projects and then add the Scala project to the inpath of your AspectJ project.

This is the same thing that you would need to do if you were compiling from ant or the command line.

稍尽春風 2024-10-23 08:11:50

目前推荐的版本是仍然是Eclipse3.5.2

门票,例如 10000753251 提及:

如果您绝望了,可以在 http://download.scala-ide.org/nightly-update-wip-helios-2.8.0.final

今天,您可以尝试使用 Helios 3.6 的当前每晚版本为:

http ://download.scala-ide.org/nightly-update-master-2.8.1.final

Right now, the recommended version is still Eclipse3.5.2.

Tickets like 1000075 or 3251 mention:

If you're desperate there's an experimental nightly build update site at http://download.scala-ide.org/nightly-update-wip-helios-2.8.0.final.

Today, the current nightly you could try with Helios 3.6 would be:

http://download.scala-ide.org/nightly-update-master-2.8.1.final

甜尕妞 2024-10-23 08:11:50

我已经为此苦苦挣扎了一段时间了。这是我的解决方案:

首先,将 Scala 和 AspectJ 代码分离到不同的项目中。

然后将 Ant 构建器添加到您的 Scala 项目中。只要 scala 构建器运行并进行编织,它就会运行。它使用 ant4eclipse 提取类路径,但您必须提供 scala 库的位置。

构建.xml:

<project name="simple-example" default="compile"
xmlns:ant4eclipse="antlib:org.ant4eclipse"
         xmlns:antcontrib="antlib:net.sf.antcontrib">

<ant4eclipse:jdtClassPathLibrary name="org.scala-ide.sdt.launching.SCALA_CONTAINER">
  <fileset file="../lib/scala-library.jar"/>
</ant4eclipse:jdtClassPathLibrary >

<ant4eclipse:getJdtClassPath 
    workspacedirectory=".."
    projectName="lpfExample"
    property="classpath"/>

<target name="compile">
    <iajc sourceroots="src" destdir="bin">
        <inpath>
            <pathelement location="bin" />
        </inpath>
        <aspectpath>
            <pathelement location="../aspects/bin"/>
        </aspectpath>
        <classpath path="${classpath}"/>
    </iajc>
</target>
</project>

I've been struggling with this for some time now. Here is my Solution:

First, separate your Scala and your AspectJ code into different projects.

Then add an Ant builder to your Scala project. It runs whenever the scala builder runs and does the weaving. It uses ant4eclipse to extract the classpath, but you'll have to supply the location of the scala library.

Build.xml:

<project name="simple-example" default="compile"
xmlns:ant4eclipse="antlib:org.ant4eclipse"
         xmlns:antcontrib="antlib:net.sf.antcontrib">

<ant4eclipse:jdtClassPathLibrary name="org.scala-ide.sdt.launching.SCALA_CONTAINER">
  <fileset file="../lib/scala-library.jar"/>
</ant4eclipse:jdtClassPathLibrary >

<ant4eclipse:getJdtClassPath 
    workspacedirectory=".."
    projectName="lpfExample"
    property="classpath"/>

<target name="compile">
    <iajc sourceroots="src" destdir="bin">
        <inpath>
            <pathelement location="bin" />
        </inpath>
        <aspectpath>
            <pathelement location="../aspects/bin"/>
        </aspectpath>
        <classpath path="${classpath}"/>
    </iajc>
</target>
</project>
诗酒趁年少 2024-10-23 08:11:50

您的意思是同时安装 Scala 插件和 AJDT 吗?这绝对是可行的——例如,开发 Scala 插件本身就需要它。

我执行以下操作:

  • 安装 AspectJ 开发工具 + eclipse weaving 服务功能
  • 安装 Scala IDE,但省略 JDT Weaving for Scala

Do you mean having both the Scala plug-in and AJDT installed simultaneously? This is definitely doable -- it's needed for developing the Scala plug-in itself, for example.

I do the following:

  • Install the AspectJ dev tools + eclipse weaving service feature
  • Install Scala IDE, but omit JDT Weaving for Scala
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文