Shermans's Notes
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

January 23rd, 2020

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
task createServerAppJar(type: ShadowJar) {
	group "vTime"
	description "Create a .jar of tools"
	baseName  "vTimeServer-${getGitHash}"
	classifier "server"

	from sourceSets.main.output
	configurations = [project.configurations.runtimeClasspath]
	
	manifest {
        attributes(
            'Built-By'       : System.properties['user.name'],
            'Build-Timestamp': LocalDateTime.now(),
            'Build-Revision' : getGitHash(),
            'Created-By'     : "Gradle ${Gradle.GradleVersion}",
            'Build-Jdk'      : "${System.properties['Java.version']} (${System.properties['Java.vendor']} ${System.properties['Java.vm.version']})",
            'Build-OS'       : "${System.properties['os.name']} ${System.properties['os.arch']} ${System.properties['os.version']}",
            'Main-Class'	 : 'starship.mvr.utils.HttpServer',
            'Class-Path'	 : project.configurations.runtimeClasspath.collect { it.getName() }.join(' ')
        )
    }
}
  • Also you can get the commit has with this ditty
1
2
3
4
5
6
7
8
def getGitHash = { ->
    def stdout = new ByteArrayOutputStream()
    exec {
        commandLine 'git', 'rev-parse', '--short', 'HEAD'
        standardOutput = stdout
    }
    return stdout.toString().trim()
}