LoginSignup
6
8

More than 5 years have passed since last update.

gradleでコマンド結果をキャプチャする

Last updated at Posted at 2014-10-22
"${実行するコマンド}".execute().text

でコマンド結果をキャプチャ出来る

versionにgitのブランチ名を付与する例

def branch = "git rev-parse --abbrev-ref HEAD".execute().text.trim()
version = "1.0-" + branch.replaceAll('/','-').trim()

ビルド時の最新コミットログをファイルに出力する

  task versionInfo(dependsOn: compileJava) {
      def buildrevision = new File("$projectDir/build_revision.txt")
      buildrevision.text = "git log -1 --decorate=full".execute().text
  }
6
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
8