2014-10-08 26 views
2

我想在我的Play 2.3.4(scala 2.10.4)應用程序中使用jacoco4sbt,但只有2.1.4似乎工作。當我使用.5或.6我得到以下錯誤:爲什麼Play 2.3.4和jacoco4sbt> 2.1.4在NoSuchMethodError失敗?

[error] (main/jacoco:fullClasspath) java.lang.NoSuchMethodError: 
org.objectweb.asm.MethodVisitor.visitMethodInsn(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)V 

我嘗試添加asm-all(版本4.1和5.0.3)的依賴關係,但是這並不能幫助所有。

那麼會有什麼問題呢?我是否需要添加任何額外的依賴項?

+1

請問另一個問題(所以我們不要劫持這個問題),添加解決方案與PMD作爲答案和批准。這使得SO更清潔。 – 2014-10-09 21:41:38

+0

@JacekLaskowski感謝您在這裏的幫助。我將更新信息添加到[新問題](http://stackoverflow.com/q/26288867/1205368)。 – Salem 2014-10-09 22:21:57

+0

謝謝!良好的合作。喜歡那個。 – 2014-10-09 22:33:35

回答

1

看了Jacek答案並開始從我的項目中刪除東西后,我發現這是由一些custom task運行PMD引起的,我不知道這可能取決於不同的asm版本。

爲了解決這個問題我只是改變了依賴於project/plugins.sbt排除ASM依賴性:

libraryDependencies ++= Seq(
    // (...) 
    "net.sourceforge.pmd" % "pmd" % "5.1.3" exclude("org.ow2.asm", "asm") 
) 

和Jacoco和PMD都開始工作了。

1

They have indeed changed the ASM version到5.0.1,甚至與此我不能再現您的問題。

項目/ build.properties

sbt.version=0.13.7-M3 

項目/ plugins.sbt

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.4") 

插件/ jacoco4sbt.sbt

addSbtPlugin("de.johoop" % "jacoco4sbt" % "2.1.6") 

build.sbt

name := """play-jacoco""" 

version := "1.0-SNAPSHOT" 

enablePlugins(PlayScala) 

scalaVersion := "2.11.2" 

libraryDependencies ++= Seq(
    jdbc, 
    anorm, 
    cache, 
    ws 
) 

pipelineStages := Seq(rjs, digest, gzip) 

jacoco.settings 

當我跑jacoco:cover它工作得很好。

[play-uglify] $ jacoco:cover 
[info] Compiling 2 Scala sources to /Users/jacek/sandbox/play-uglify/target/scala-2.11/test-classes... 
SLF4J: The following set of substitute loggers may have been accessed 
SLF4J: during the initialization phase. Logging calls during this 
SLF4J: phase were not honored. However, subsequent logging calls to these 
SLF4J: loggers will work as normally expected. 
SLF4J: See also http://www.slf4j.org/codes.html#substituteLogger 
SLF4J: org.apache.http.impl.client.DefaultHttpClient 
SLF4J: com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl 
SLF4J: com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter 
SLF4J: com.gargoylesoftware.htmlunit.DefaultCssErrorHandler 
SLF4J: com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration 
SLF4J: com.gargoylesoftware.htmlunit.WebClient 
SLF4J: com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine 
SLF4J: com.gargoylesoftware.htmlunit.WebResponse 
[info] IntegrationSpec 
[info] 
[info] Application should 
[info] + work from within a browser 
[info] 
[info] Total for specification IntegrationSpec 
[info] Finished in 29 ms 
[info] 1 example, 0 failure, 0 error 
[info] ApplicationSpec 
[info] 
[info] Application should 
[info] + send 404 on a bad request 
[info] + render the index page 
[info] 
[info] Total for specification ApplicationSpec 
[info] Finished in 29 ms 
[info] 2 examples, 0 failure, 0 error 
[info] Passed: Total 3, Failed 0, Errors 0, Passed 3 
[info] 
[info] ------- Jacoco Coverage Report -------- 
[info] 
[info] Lines: 57.5% (>= required 0.0%) covered, 34 of 80 missed, OK 
[info] Instructions: 72.12% (>= required 0.0%) covered, 522 of 1872 missed, OK 
[info] Branches: 27.78% (>= required 0.0%) covered, 26 of 36 missed, OK 
[info] Methods: 81.94% (>= required 0.0%) covered, 41 of 227 missed, OK 
[info] Complexity: 76.73% (>= required 0.0%) covered, 57 of 245 missed, OK 
[info] Class: 57.14% (>= required 0.0%) covered, 12 of 28 missed, OK 
[info] Check /Users/jacek/sandbox/play-uglify/target/scala-2.11/jacoco for detail report 
[info] 
[success] Total time: 6 s, completed Oct 9, 2014 7:42:31 AM 

我們在哪裏有區別?