2015-09-15 88 views
3

我在Gradle 2.7中使用新的Play Framework支持。具有諷刺意味的是,Play 2.3.x明確依賴org.scala-sbt:io:0.13.8Gradle + PlayFramework:無法解析源依賴

搖籃能夠解決從類型安全的存儲庫JAR(沒有來源,就在班)如果我添加

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" }

但它似乎無法解決io-sources.jar。我得到這個:

FAILURE: Build failed with an exception.

我其實並不關心這些來源,我只是想避免這種運行時異常運行時gradlew runPlay

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

有什麼建議?我似乎無法弄清楚如何排除或解決源依賴。

+1

我已經在Gradle論壇上回復:https://discuss.gradle.org/t/gradle-2-7-play-cannot-resolve-sources-dependency/11707 –

+1

發現了關於Typesafe常春藤回購的評論: https://github.com/linkedin/rest.li-sbt-plugin/blob/de19700211923d76acdccfd40610884a4e689717/build.gradle#L77-L82 –

回答

0

A類搖籃dev的回答對Gradle forums

TL我的問題; DR - Gradle/Play bug具體到2.3.7,可以通過使用解決

repositories { 
    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]" 
     } 
    } 
} 

在我的情況下,你pgrading Play 2.3.9修復了我的問題。

1

我遇到了與Play 2.4和Gradle 2.7相同的RuntimeException(NoClassDefFound sbt/Path $)。在我的情況下,根本問題是沒有正確定義所有的存儲庫(不包括typesafe-ivy-> sbt-io沒有解決 - >我以爲我需要說明sbt-io-dependency->錯誤的sbt-io導致提到例外...)。

我建議您添加jcenter()作爲存儲庫,刪除sbt的顯式依賴項,並在build.gradle中聲明播放版本。作爲一個例子我的工作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 
    } 
} 
} 

在你的情況下,最後一部分應該是:

model { 
components { 
    play { 
    platform play: '2.3.7', scala: '2.10' 
    } 
} 
} 
+0

感謝您的建議。恐怕,添加jcenter()和排除「org.scala-sbt」的變體並沒有改變事情的好轉。當你說「刪除顯式依賴」時,你是否在整個遊戲配置或其他方式中排除了sbt? –

+0

我已經更新了這個建議,以清楚說明我只是不打擾自己在構建文件中導入「org.scala-sbt」。 – user24195