Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle + PlayFramework: Cannot resolve sources dependency

I'm using the new Play Framework support in Gradle 2.7.

Ironically, Play 2.3.x explicitly depends on org.scala-sbt:io:0.13.8.

Gradle is able to resolve the JAR (not the sources, just the classes) from typesafe's repository if I add

model { components { play { platform play: "2.3.7", scala: "2.10", java: "1.7" } } } repositories { maven { name "typesafe-maven-release" url "https://repo.typesafe.com/typesafe/maven-releases" } ivy { name "typesafe-ivy-release" url "https://repo.typesafe.com/typesafe/ivy-releases" layout "ivy" } } dependencies { play group: "org.scala-sbt", name: "io", version: "0.13.8", classifier: "jar", configuration: "compile" }

however it seems that it cannot resolve the io-sources.jar. I get this:

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':runPlayBinary'.

    Could not find io-sources.jar (org.scala-sbt:io:0.13.8). Searched in the following locations: https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/io/0.13.8/srcs/io.jar

I actually don't care about these sources, I just want to avoid this runtime exception when running gradlew runPlay

Execution exception [RuntimeException: java.lang.NoClassDefFoundError: sbt/Path$]

Any advice? I can't seem to figure out how to exclude or resolve the sources dependency.

like image 500
Eric Wendelin Avatar asked Mar 27 '26 07:03

Eric Wendelin


1 Answers

I ran into the same RuntimeException (NoClassDefFound sbt/Path$) with Play 2.4 and Gradle 2.7. In my case the root problem was to not define all repositories correctly (didn't include typesafe-ivy -> sbt-io was not resolved -> thought i need to state sbt-io-dependency -> wrong sbt-io led to mentioned Exception...).

I would advise you to add jcenter() as repository, remove the explicit dependency on sbt and state the play version in your build.gradle. As an example my working gradle.build:

plugins {
 id 'play'
}
dependencies {
 repositories {
  jcenter()
  maven {
    name "typesafe-maven-release"
    url "https://repo.typesafe.com/typesafe/maven-releases"
  }
  ivy {
    name "typesafe-ivy-release"
    url "https://repo.typesafe.com/typesafe/ivy-releases"
    layout "ivy"
  }
 }
 play 'com.typesafe.play:play-jdbc_2.11:2.4.3'
 [...other dependencies - but not "org.scala-sbt"!]
}

model {
 components {
  play {
    platform play: '2.4.3', scala: '2.11'
    injectedRoutesGenerator = true
  }
 }
}

In your case the last part should be:

model {
 components {
  play {
    platform play: '2.3.7', scala: '2.10'
  }
 }
}
like image 144
laborg Avatar answered Apr 02 '26 18:04

laborg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!