如何在PlayFramework 2.1.1中配置AspectJ编译 [英] How configure aspectj compilation in playframework 2.1.1

查看:174
本文介绍了如何在PlayFramework 2.1.1中配置AspectJ编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在plugins.sbt中添加了此声明

I have added to plugins.sbt this declaration

addSbtPlugin("com.typesafe.sbt" % "sbt-aspectj" % "0.9.0")

现在,我想像使用Aspectj-maven-plugin一样,配置该插件以使用方面库org.springframework:spring-aspects:3.1.4编译我的Java控制器类

Now I would like to configure this plugin to compile my java controller classes using aspect library org.springframework:spring-aspects:3.1.4 as with aspectj-maven-plugin

我已经设置了此配置:

import sbt._
import Keys._
import play.Project._
import com.typesafe.sbt.SbtAspectj._
import com.typesafe.sbt.SbtAspectj.AspectjKeys._

object ApplicationBuild extends Build {

    val appDependencies = Seq(javaCore)

    val main = play.Project(appName, appVersion, appDependencies).settings(
        AspectjKeys.verbose in Aspectj := true,
        AspectjKeys.showWeaveInfo in Aspectj := true,
        AspectjKeys.inputs in Aspectj <+= compiledClasses
    )

}

但是它确实失败了.

[error] Reference to undefined setting: 
[error] 
[error]   aspectj:inputs from aspectj:inputs

我真的是sbt的新手.

I am really a newbie with the sbt thing.

插件github页面: https://github.com/sbt/sbt-aspectj

The plugin github page : https://github.com/sbt/sbt-aspectj

推荐答案

好吧,这要感谢sbt邮件列表,比照. https://groups.google.com/forum/?fromgroups =#!topic/simple-build-tool/MUXyfKigC7w

Ok, I make it works, thanks to sbt mailing list, cf. https://groups.google.com/forum/?fromgroups=#!topic/simple-build-tool/MUXyfKigC7w

和playframework邮件列表,请参见. https://groups.google.com/forum/?fromgroups =#!topic/play-framework/RfJFEwVbUUk

and the playframework mailing list also, cf. https://groups.google.com/forum/?fromgroups=#!topic/play-framework/RfJFEwVbUUk

实际上并不难,但有些东西你看不到.

It was not very hard in fact but something you can't see things.

import sbt._
import Keys._
import play.Project._
import com.typesafe.sbt.SbtAspectj._
import com.typesafe.sbt.SbtAspectj.AspectjKeys._

object ApplicationBuild extends Build {

    val appDependencies = Seq(javaCore, filters)

    val main = play.Project(appName, appVersion, appDependencies)
            .settings(aspectjSettings: _*)
            .settings(
                    libraryDependencies += "org.springframework" % "spring-aspects" % "3.1.4.RELEASE",
                    libraryDependencies += "org.springframework.security" % "spring-security-aspects" % "3.1.4.RELEASE",
                    sourceLevel := "-1.7",
                    verbose in Aspectj := false,
                    showWeaveInfo in Aspectj := false,
                    inputs in Aspectj <+= compiledClasses,
                    binaries in Aspectj <++= update map { report =>
                        report.matching(
                                moduleFilter(organization = "org.springframework", name = "spring-aspects")
                                || moduleFilter(organization = "org.springframework.security", name = "spring-security-aspects")
                        )
                    },
                    products in Compile <<= products in Aspectj,
                    products in Runtime <<= products in Compile
                )
}

不要忘记在plugins.sbt中添加它,在声明之间使用新的行分隔符

Don't forget to add this in in plugins.sbt, with a new line separator between declaration

addSbtPlugin("com.typesafe.sbt" % "sbt-aspectj" % "0.9.0")

这篇关于如何在PlayFramework 2.1.1中配置AspectJ编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆