1
請查看下面使用我們插件的build.sbt示例文件。 在此示例BasePlugin,我們要完整路徑/工程,B /項目目錄: -訪問sbt插件中的依賴項(不是子項)
import sbt._
import Keys._
import BasePlugin._
BasePlugin.settings
lazy val root = Project("root", file(".")).dependsOn(
ProjectRef(uri("../some/where/a"), "a"),
ProjectRef(uri("../some/where/b"), "b")
)
enablePlugins(BasePlugin)
此外,在下面找到,簡化SBT插件BasePlugin.scala: -
package base
import sbt.{ThisBuild, Def, TaskKey, AutoPlugin}
import sbt._
import Keys._
/**
* Created by mogli on 4/23/2017.
*/
object BasePlugin extends AutoPlugin {
object autoImport {
lazy val customtask: TaskKey[Unit] = TaskKey("customtask")
}
import autoImport.customtask
override def projectSettings: Seq[Def.Setting[_]] = Seq(
customtask := {
//expectation: to get an iterator or collection sort of thing for dependent projects, but they are not in this variable (projectDependencies)
val deps = projectDependencies
deps map { c => println("project : " + c) }
}
)
}
如何訪問sbt插件中的依賴項目。
val deps = thisProject.value.dependencies.map {dep => dep.project}? –
我想你不小心忘了包括你的問題 – Martijn
@Micro:請在回答部分添加您的評論,以便接受它:) – mogli