AspectJ 编织 sbt 抛出提供的外部 jar 文件无法确定缺少类型的超类
AspectJ weaving external jar file provided by sbt throws can't determine superclass of missing type
我正在尝试编写测试库 scalatest (https://mvnrepository.com/artifact/org.scalatest/scalatest_2.12/3.2.0-SNAP10)。这个库依赖在我的 build.sbt:
enablePlugins(SbtAspectj)
libraryDependencies += "org.scalactic" %% "scalactic" % "3.0.5"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.5" % "test"
aspectjInputs in Aspectj ++= update.value.matching(moduleFilter(organization = "com.typesafe.akka", name = "akka-actor*"))
aspectjInputs in Aspectj ++= update.value.matching(moduleFilter(organization = "org.scalatest", name = "scalatest*"))
fullClasspath in Runtime := aspectjUseInstrumentedClasses(Runtime).value ++ aspectjUseInstrumentedClasses(Test).value
查看 Maven 网站,它列出了其他几个可选的依赖项,例如 org.jmock 等
问题是 SBT 只下载 scalatest.jar 而不是 jmock.jar (以及其他可选依赖项)。打印出 aspectjInputs
确实显示 scalatest.jar,但 不是 jmock.jar.
由于这个原因(?),它给了我以下错误:
[error] error at (no source information available)
[error] /Users/jonas/.ivy2/cache/org.scalatest/scalatest_2.12/bundles/scalatest_2.12-3.0.5.jar:0::0 can't determine superclass of missing type org.jmock.Expectations
[error] when weaving type org.scalatest.jmock.JMockExpectations
[error] when weaving classes
[error] when weaving
[error] when batch building BuildConfig[null] #Files=1 AopXmls=#0
[error] [Xlint:cantFindType]
我假设我以某种方式需要 ScalaTest 的可选依赖项的 .jar 文件,但由于它们不是由 sbt 下载的,所以我不知道如何解决这个问题。
那么,当编织发生时,我如何解决它们或将它们添加到类路径中?
我正在使用 aspectj-sbt 插件。
您可以将可选依赖项包含在配置映射中,如下所示:
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.5" % "test->compile,optional"
我正在尝试编写测试库 scalatest (https://mvnrepository.com/artifact/org.scalatest/scalatest_2.12/3.2.0-SNAP10)。这个库依赖在我的 build.sbt:
enablePlugins(SbtAspectj)
libraryDependencies += "org.scalactic" %% "scalactic" % "3.0.5"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.5" % "test"
aspectjInputs in Aspectj ++= update.value.matching(moduleFilter(organization = "com.typesafe.akka", name = "akka-actor*"))
aspectjInputs in Aspectj ++= update.value.matching(moduleFilter(organization = "org.scalatest", name = "scalatest*"))
fullClasspath in Runtime := aspectjUseInstrumentedClasses(Runtime).value ++ aspectjUseInstrumentedClasses(Test).value
查看 Maven 网站,它列出了其他几个可选的依赖项,例如 org.jmock 等
问题是 SBT 只下载 scalatest.jar 而不是 jmock.jar (以及其他可选依赖项)。打印出 aspectjInputs
确实显示 scalatest.jar,但 不是 jmock.jar.
由于这个原因(?),它给了我以下错误:
[error] error at (no source information available)
[error] /Users/jonas/.ivy2/cache/org.scalatest/scalatest_2.12/bundles/scalatest_2.12-3.0.5.jar:0::0 can't determine superclass of missing type org.jmock.Expectations
[error] when weaving type org.scalatest.jmock.JMockExpectations
[error] when weaving classes
[error] when weaving
[error] when batch building BuildConfig[null] #Files=1 AopXmls=#0
[error] [Xlint:cantFindType]
我假设我以某种方式需要 ScalaTest 的可选依赖项的 .jar 文件,但由于它们不是由 sbt 下载的,所以我不知道如何解决这个问题。
那么,当编织发生时,我如何解决它们或将它们添加到类路径中?
我正在使用 aspectj-sbt 插件。
您可以将可选依赖项包含在配置映射中,如下所示:
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.5" % "test->compile,optional"