2017-10-13 42 views
0

我的示例sbt插件使用scala版本2.10.6編譯得很好。 我想在sbt插件build.sbt中升級scalaVersion:=「2.11.7」。使用scala版本訪問sbt插件中的依賴項(而非子項)2.11.7

它打破與followinng CTE: -

/Users/mogli/gitrepos/study/SbtPlugins/ScalaPlugin/src/main/scala/base/BasePlugin.scala:21: 不能展開宏由斯卡拉[錯誤]
VAL項目的早期版本編譯= thisProject.value.dependencies

這是工作的罰款與scalaVersion:如以下問題建議通過微Dotta =「2.10.6」: -

accessing dependent (not child) projects in sbt plugin

簡體SBT插件BasePlugin.scala:

package base 

import sbt.{ThisBuild, Def, TaskKey, AutoPlugin} 
import sbt._ 
import Keys._ 


object BasePlugin extends AutoPlugin { 

    object autoImport { 
    lazy val customtask: TaskKey[Unit] = TaskKey("customtask") 
    } 

    import autoImport.customtask 


    override def projectSettings: Seq[Def.Setting[_]] = Seq(
    customtask := { 
     val projects = thisProject.value.dependencies 
     projects map println 
    } 
) 
} 

如何獲得它scalaVersion工作:= 「2.11.7」?我想這個插件與使用財政版本11

回答

0

項目使用試試這個:

override def projectSettings: Seq[Def.Setting[_]] = Seq(
     customtask := { 
      val projects = thisProject.value.dependencies 
      projects map println 
     }, 
     scalaVersion := "2.11.7" 
    ) 
0

SBT建立defintions被綁定到由他們使用的SBT版本的Scala版本:

  • SBT 0.12.x構建定義和代碼必須與斯卡拉2.9.x編譯
  • SBT 0.13.x構建定義和代碼必須與斯卡拉編譯2.10.x

因爲1.0.0 SBT編譯反對斯卡拉版本2.12和需要Java 8

所以,

沒有SBT版本,其中SBT建立defintions可以使用Scala 2.11(至少在沒有冒着錯誤編譯)。

您可以通過在project/build.properties設置它操縱你正在使用的版本SBT:

sbt.version=1.0.0 

確保您使用的是當前SBT包裝腳本。

相關問題