Wartbarkeit, Stabilität und Effektivität

gradle - mercurial

2012-05 05
Sa, 2012-05-05 16:21 -- mig

apply plugin: 'java'
 
description 'Versioned Project with info-tokens in the manifest'
 
ext.mercurial = mercurial('{node};{branch};{date|isodate};{tags}').tokenize(';')
ext.revision = mercurial.get(0)
ext.tags = mercurial.get(3)
ext.date = mercurial.get(2)
ext.branch = mercurial.get(1)
 
jar {
  manifest {
   attributes(
      'Implementation-Title': description,
      'Implementation-Version': version,
      'Implementation-Vendor': 'XiLab by norics',
      'Built-By': System.properties['user.name'],
      'Revision': revision,
      'Revision-Branch': branch,
      'Revision-Tags': tags,
      'Revision-Date': date
    )
  }
}
 
/**
 * ask mercurial for revision infos.
 */
String mercurial(tag) {
  ext.stdout = new ByteArrayOutputStream()
  exec {
    commandLine('hg', 'parent', '--template', "$tag")
    standardOutput = stdout
  }
  return stdout as String
}