mirror of https://github.com/sbt/sbt.git
Print version in help message
This commit is contained in:
parent
cf45a924a8
commit
58c8cb4192
24
build.sbt
24
build.sbt
|
|
@ -1,3 +1,4 @@
|
|||
import java.io.FileOutputStream
|
||||
|
||||
lazy val releaseSettings = Seq(
|
||||
publishMavenStyle := true,
|
||||
|
|
@ -110,7 +111,28 @@ lazy val commonSettings = baseCommonSettings ++ Seq(
|
|||
lazy val core = crossProject
|
||||
.settings(commonSettings: _*)
|
||||
.settings(
|
||||
name := "coursier"
|
||||
name := "coursier",
|
||||
resourceGenerators.in(Compile) += {
|
||||
(target, version).map { (dir, ver) =>
|
||||
import sys.process._
|
||||
|
||||
val f = dir / "coursier.properties"
|
||||
dir.mkdirs()
|
||||
|
||||
val p = new java.util.Properties()
|
||||
|
||||
p.setProperty("version", ver)
|
||||
p.setProperty("commit-hash", Seq("git", "rev-parse", "HEAD").!!.trim)
|
||||
|
||||
val w = new FileOutputStream(f)
|
||||
p.store(w, "Coursier properties")
|
||||
w.close()
|
||||
|
||||
println(s"Wrote $f")
|
||||
|
||||
Seq(f)
|
||||
}.taskValue
|
||||
}
|
||||
)
|
||||
.jvmSettings(
|
||||
libraryDependencies ++=
|
||||
|
|
|
|||
|
|
@ -574,4 +574,5 @@ case class Bootstrap(
|
|||
object Coursier extends CommandAppOf[CoursierCommand] {
|
||||
override def appName = "Coursier"
|
||||
override def progName = "coursier"
|
||||
override def appVersion = coursier.util.Properties.version
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
package coursier.util
|
||||
|
||||
import java.util.Properties
|
||||
|
||||
object Properties {
|
||||
|
||||
private lazy val props = {
|
||||
val p = new Properties()
|
||||
p.load(
|
||||
getClass
|
||||
.getClassLoader
|
||||
.getResourceAsStream("coursier.properties")
|
||||
)
|
||||
p
|
||||
}
|
||||
|
||||
lazy val version = props.getProperty("version")
|
||||
lazy val commitHash = props.getProperty("commit-hash")
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue