556 sao GitHub và vẫn tăng — sbt/sbt-buildinfo là dự án Scala mà TopGit đang theo dõi trên nền tảng. I know this because build.sbt knows this.
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
lazy val root = (project in file(".")).
enablePlugins(BuildInfoPlugin).
settings(
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion),
buildInfoPackage := "hello"
)
When you reload the settings and compile, this generates the following:
package hello
/** This object was generated by sbt-buildinfo. */
case object BuildInfo {
/** The value is "helloworld". */
val name: String = "helloworld"
/** The value is "0.1-SNAPSHOT". */
val version: String = "0.1-SNAPSHOT"
/** The value is "2.10.3". */
val scalaVersion: String = "2.10.3"
/** The value is "0.13.2". */
val sbtVersion: String = "0.13.2"
override val toString: String = "name: %s, version: %s, scalaVersion: %s, sbtVersion: %s".format(name, version, scalaVersion, sbtVersion)
}
As this is generated source it will be found under target, specifically for a Scala 2.11 project under target/scala-2.11/src_managed/main/sbt-buildinfo
Customize buildInfoKeys by adding whatever keys you want to have in BuildInfo. You can use BuildInfoKey.map to change the generated field name and value, add new fields with tuples, or add new fields with values computed at build-time. Note: BuildInfoKey.map can handle both SettingKey[T] and TaskKey[T] types as arguments:
buildInfoKeys ++= Seq[BuildInfoKey](
resolvers,
Test / libraryDependencies,
BuildInfoKey.map(name) { case (k, v) => "project" + k.capitalize -> v.capitalize },
"custom" -> 1234, // computed at project load time
BuildInfoKey.action("buildTime") {
System.currentTimeMillis
} // re-computed each time at compile
)
This generates:
/** The value is Seq("Sonatype Public: https://oss.sonatype.org/content/groups/public"). */
val resolvers: Seq[String] = Seq("Sonatype Public: https://oss.sonatype.org/content/groups/public")
/** The value is Seq("org.scala-lang:scala-library:2.9.1", ...). */
val test_libraryDependencies: Seq[String] = Seq("org.scala-lang:scala-library:2.9.1", ...)
/** The value is "Helloworld". */
val projectName = "Helloworld"
/** The value is 1234. */
val custom = 1234
/** The value is 1346906092160L. */
val buildTime = 1346906092160L
Tasks can be added only if they do not depend on sourceGenerators. Otherwise, it will cause an infinite loop.
Here's how to change the generated object name:
buildInfoObject := "Info"
This changes the generated object name to object Info. Changing the object name is optional, but to avoid name clash with other jars, package name should be unique. Use buildInfoPackage key for this.
buildInfoPackage := "hello"
build number
A build number can be generated as follows. Note that cross building against multiple Scala would each generate a new number.
/** The value is "2015-07-30 03:30:16.849-0700". */
val builtAtString: String = "2015-07-30 03:30:16.849-0700"
/** The value is 1438227016849L. */
val builtAtMillis: Long = 1438227016849L
BuildInfoOption.PackagePrivate
Set the package using buildInfoPackage and use the option BuildInfoOption.PackagePrivate
to explicitly import scala.Predef._ in the generated code.
package hello
import scala.Predef._
/** This object was generated by sbt-buildinfo. */
case object BuildInfo {
...
}
This import is necessary only when using compiler option -Yno-imports. Please note, the generated import is not compatible when compiling with Scala 3 compiler option -source:future because import wildcards must be *.
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/sbt/sbt-buildinfo là nguồn chính thức.
sbt/sbt-buildinfo có phải mã nguồn mở không?
Có — sbt/sbt-buildinfo phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/sbt/sbt-buildinfo.
sbt/sbt-buildinfo có website riêng không?
TopGit chưa ghi nhận URL trang chủ cho sbt/sbt-buildinfo. Phần README ở tab phía trên thường có link demo, hoặc xem mô tả GitHub của repo.
sbt/sbt-buildinfo dùng license gì?
sbt/sbt-buildinfo phát hành theo license MIT. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
sbt/sbt-buildinfo là gì?
sbt/sbt-buildinfo (sbt/sbt-buildinfo) là dự án Scala trên GitHub. Theo mô tả gốc: I know this because build.sbt knows this.
Đọc đầy đủ README ở tab phía trên.
Chưa chắc sbt-buildinfo có hợp với bạn?
Để ChatGPT, Claude hoặc Perplexity tìm hiểu giúp — bấm bên dưới và xem AI nói gì về sbt-buildinfo.