Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sbt 如何基于另一个插件修改插件中的设置和任务';有空吗?_Sbt_Thrift_Scrooge - Fatal编程技术网

Sbt 如何基于另一个插件修改插件中的设置和任务';有空吗?

Sbt 如何基于另一个插件修改插件中的设置和任务';有空吗?,sbt,thrift,scrooge,Sbt,Thrift,Scrooge,在我编写的插件的build.sbt文件中,我有以下两行代码: scroogeThriftDependencies in Compile := Seq("shared_2.10") mappings in (Compile,packageBin) ~= { (ms: Seq[(File, String)]) => ms filter { case (file, toPath) => !toPath.startsWith(s"shared") } } 但我只想在构建还

在我编写的插件的
build.sbt
文件中,我有以下两行代码:

scroogeThriftDependencies in Compile := Seq("shared_2.10")

mappings in (Compile,packageBin) ~= { (ms: Seq[(File, String)]) =>
  ms filter { case (file, toPath) =>
    !toPath.startsWith(s"shared")
  }
}
但我只想在构建还包含。如何做到这一点

我尝试了以下方法,但不起作用:

lazy val onlyWithScrooge = taskKey[Unit]("Executes only if the Scrooge plugin is part of the build")

onlyWithScrooge := {
  val structure: BuildStructure = Project.extract(state.value).structure
  val pluginNames = structure.units.values.map { un => un.unit.plugins.detected }
  pluginNames.foreach(
    plugins => {
      plugins.plugins.modules.foreach {
        plugin =>
          if (plugin._1 == "com.twitter.scrooge.ScroogeSBT") {
            // i get here at least
            scroogeThriftDependencies in Compile := Seq("shared_2.10")
            mappings in (Compile,packageBin) ~= { (ms: Seq[(File, String)]) =>
              ms filter { case (file, toPath) =>
                !toPath.startsWith(s"shared")
              }
            }
          }
      }
    }
  )
}

(scroogeGen in Compile) <<= (scroogeGen in Compile) dependsOn onlyWithScrooge
lazy val onlyWithScrooge=taskKey[Unit](“仅当Scrooge插件是构建的一部分时执行”)
仅限WithScrooge:={
val结构:BuildStructure=Project.extract(state.value).structure
val pluginNames=structure.units.values.map{un=>un.unit.plugins.detected}
福雷赫酒店(
插件=>{
plugins.plugins.modules.foreach{
插件=>
if(plugin._1==“com.twitter.scrooge.ScroogeSBT”){
//至少我到了这里
编译中的scroogeThriftDependencies:=Seq(“共享_2.10”)
(Compile,packageBin)~={(ms:Seq[(文件,字符串)])=>
ms筛选器{case(文件,toPath)=>
!toPath.startsWith(s“共享”)
}
}
}
}
}
)
}

(编译中的scroogeGen)你正在开发一个插件,它基于一个条件添加了一些额外的设置?条件是存在一个插件——史克鲁奇插件?我的理解正确吗?@JacekLaskowski是的,正确。基本上,如果Scrooge插件是构建的一部分,我想设置scroogeThriftDependencies并从映射中排除一些生成的代码。这将是我们所有项目都将包含的通用插件的一部分。否则,每个项目都需要将这两个修改添加到自己的build.sbt文件中。