【问题标题】:What is buildInfoPackage in sbt-buildinfo?sbt-buildinfo 中的 buildInfoPackage 是什么?
【发布时间】:2021-03-09 03:17:55
【问题描述】:

假设我有一个名为 myservice 的模块,其中包含子模块 service1service2

myproject/
          myservice/ 
                   / service1
                             /com/sample/process
                                                 SomeFile1.scala
                                                 SomeFile11.scala
                                        /endpoint
                                                                                                  
                                                 SomeFile13.scala
                                                 SomeFile111.scala
                   / service2
                             /com/sample/mov
                                                 SomeFile2.scala
                                                 SomeFile21.scala

我将构建信息定义为:

lazy val service1 = project.in(file("myservice/service1"))
lazy val service2 = project.in(file("myservice/service2"))

lazy val root = (project in file(".")).
  enablePlugins(BuildInfoPlugin).
  settings(
    buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion),
    buildInfoPackage := "?" //What will be the package name here ?
  )

第一季度。我是否需要分别为每个模块启用 buildinfo 插件,如下所示?
Q2。如果是的话,这里的包裹是什么

  lazy val service1 = project.in(file("myservice/service1"))
                     enablePlugins(BuildInfoPlugin).
                settings(
                buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion),
                buildInfoPackage := "?" //What will be the package name here ?
                 )

  lazy val service2 = project.in(file("myservice/service2"))
                     enablePlugins(BuildInfoPlugin).
                settings(
                buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion),
                buildInfoPackage := "?" //What will be the package name here ?
                 )

【问题讨论】:

    标签: scala sbt sbt-assembly sbt-plugin sbt-buildinfo


    【解决方案1】:

    在源代码中我没有注意到任何触发器,因此插件不会自动打开 - 我会为每个需要生成它的项目手动启用它。

    包是这个生成的case class 将被放置的地方。您希望将其放入com.my.package 并在源代码中以com.my.package.BuildInfo 的形式提供吗?然后将buildInfoPackage设置为"com.my.package"

    请记住,如果您启用此插件两次(或更多次)并且在每个包中您将在同一个包中生成案例类,那么如果任何东西同时使用这两个模块,您将产生冲突。或者,如果一个人依赖另一个人。所以我只会在项目的其余部分重用的一些公共模块中生成这个案例类,除非你想例如将每个模块发布为库,并在运行时检查库组件是否处于兼容版本(类似于 Akka 检查所有库是否具有匹配版本)——在这种情况下,每个模块应该使用不同的包作为生成器的目标。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-21
      • 2017-03-06
      • 2014-06-04
      • 2018-03-27
      • 2012-01-29
      • 2018-07-18
      • 2015-04-23
      • 2012-07-04
      相关资源
      最近更新 更多