Gradle 2.7 + Play: 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"
  }
}

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$]
at play.runsupport.AssetsClassLoader.exists(AssetsClassLoader.scala:26)
at play.runsupport.AssetsClassLoader$$anonfun$findResource$1.isDefinedAt(AssetsClassLoader.scala:20)

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

We have the wrong configuration for the Typesafe Ivy repository in our examples. It seems to use an non-standard layout. Here is an example of a minimal build file for Play 2.3.7 .

plugins {
    id 'play'
}

model {
    components {
        play {
            platform play: '2.3.7', scala: '2.10', java: '1.7'
        }
    }
}

repositories{
    jcenter()
    maven{
        name = "typesafe-maven-release"
        url = "https://repo.typesafe.com/typesafe/maven-releases"
    }
    ivy {
        url "https://repo.typesafe.com/typesafe/ivy-releases/"
        layout "pattern", {
            ivy "[organisation]/[module]/[revision]/ivys/ivy.xml"
            artifact "[organisation]/[module]/[revision]/jars/[artifact].[ext]"
        }
    }
}
1 Like

This issue cannot be reproduced when Play version is 2.3.9 . I found this comment about Typesafe repo .

1 Like

Huge help, Lari! Your solution worked.

Alternate crazy solution I came up with:

  ['play', 'playRun', 'playTest'].each {
    configurations.findByName(it).exclude(group: "org.scala-sbt", module: "io")
    configurations.findByName(it).resolutionStrategy {
      eachDependency { DependencyResolveDetails drd ->
        if (drd.requested.group == "fu" && drd.requested.name == "sbt") {
          drd.useTarget group: "org.scala-sbt", name: "io", version: drd.requested.version
        }
      }
    }
  }

dependencies {
  play group: "fu", name: "sbt", version: "0.13.8", configuration: "compile"
  playRun group: "fu", name: "sbt", version: "0.13.8", configuration: "compile"
  playTest group: "fu", name: "sbt", version: "0.13.8", configuration: "compile"
}