Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrating to the new version of sbt-aspectj #40

Open
hasansozer opened this issue Dec 18, 2017 · 4 comments
Open

Migrating to the new version of sbt-aspectj #40

hasansozer opened this issue Dec 18, 2017 · 4 comments

Comments

@hasansozer
Copy link

I am trying to compile and run a tool, which is using an old version of sbt-aspectj (com.typesafe.sbtaspectj" % "sbt-aspectj" % "0.5.3"). I updated the plugins.sbt file to switch to the new version ("com.lightbend.sbt" % "sbt-aspectj" % "0.11.0"). I updated the build file as well. The original build file can be found in this link: https://github.com/samira-t/Bita/blob/master/project/Build.scala

Hereby, I updated the import statements as follows:

mport com.lightbend.sbt.SbtAspectj
import com.lightbend.sbt.AspectjKeys.{ aspectjInputs, aspectjBinaries, aspectjWeave }

Then I updated the library dependencies as follows:

libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % "2.4.1",
"org.scalatest" %% "scalatest" % "2.2.4" % "test",
"org.scala-lang" % "scala-reflect" % "2.11.7",
"org.scala-lang.modules" %% "scala-xml" % "1.0.4"
),

The following definition does not work since "inputs in Aspectj" is apparently not defined anymore:

inputs in Aspectj <<= update map { report =>
report.matching(moduleFilter(organization = "com.typesafe.akka", name = "akka-actor"))
},

So, I changed it as follows (hoping that this value in AspectjKeys is representative):

aspectjInputs <<= update map { report =>
report.matching(moduleFilter(organization = "com.typesafe.akka", name = "akka-actor"))
},

I changed the last two lines for using the instrumented versions as well (hoping that they are comparable to the use of AspectjPlugin.useInstrumentedClasses and AspectjPlugin.useInstrumentedJars):

fullClasspath in Test <<= SbtAspectj.aspectjUseInstrumentedClasses(Test),
fullClasspath in Runtime <<= SbtAspectj.aspectjUseInstrumentedClasses(Runtime)))

Assuming that the above modifications are correct, the part that I am really puzzled with is the definition of an aspect filter as copied below:

aspectFilter in Aspectj := {
(jar, aspects) =>
{
if (jar.name.contains("akka-actor") )
aspects filter (jar => (jar.name.startsWith("Actor")))
else Seq.empty[File]
}
},

Apperrently such a filter is not defined in the version. I also could not find a representative definition.

@alonsodomin
Copy link

Hi, sorry for the late response. Let's see if this can help you:

  • aspectjInputs still needs to be scoped to the Aspectj configuration, despite it's prefix. i.e.: aspectjInputs in Aspectj <<= update map { ... }
  • Your use case looks very very similar to this specific example: https://github.com/sbt/sbt-aspectj/blob/master/src/sbt-test/weave/external/build.sbt. It's about instrumenting an external JAR file and then reusing it later in a different module. You might be interested on mimic part of it.
  • You are using a very old version of SBT, 0.12.x, the latest version of this plugin it's only being tested with SBT 0.13.5+ and 1.0.x. Upgrading SBT to the latest will also force you to change the <<= syntax though.

@hasansozer
Copy link
Author

Thank you for help. Scoping leads to a compile error in my case (keyword Aspectj is not recognized); however, I will study and try to mimic the statements in the example build file. I will also try to upgrade the SBT version.

@alexfel
Copy link

alexfel commented May 27, 2018

Hi,
Im trying to write a skinny poc in scala (2.11.11 version) and sbt 1.0.4 of aspectj and it just doesn't work for me. can someone kindly link me to such come skinny code example that works?
Thanks in advanced

@rooagarw
Copy link

@hasansozer I am using
aspectjInputs in Aspectj += (aspectjCompiledClasses in Aspectj).value,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants