mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-17 11:07:35 -05:00
Co-authored-by: denny <dennis.sheirer@gmail.com>
This commit is contained in:
41
build.gradle
41
build.gradle
@@ -52,8 +52,44 @@ plugins {
|
||||
id 'org.beryx.runtime' version '2.0.1'
|
||||
}
|
||||
|
||||
//Version is defined in gradle.properties so that we can CLI override it for nightly builds.
|
||||
version = project.findProperty('projectVersion')
|
||||
/**
|
||||
* Version is derived from the most recent 'v<version>' git tag (e.g. v1.0.0-beta-1 -> 1.0.0-beta-1). Commits after
|
||||
* the tag produce a version like 1.0.0-beta-1-14-g4626d567 and uncommitted changes append '-dirty'. The moving
|
||||
* 'nightly' tag is ignored. Override with -PprojectVersion=<version> (the nightly build uses 'nightly' so that the
|
||||
* nightly release asset names stay the same). Falls back to 'unknown' when built outside a git checkout.
|
||||
*/
|
||||
String gitDescribe = describeGitVersion()
|
||||
version = project.findProperty('projectVersion') ?: (gitDescribe ? gitDescribe.substring(1) : 'unknown')
|
||||
|
||||
String describeGitVersion()
|
||||
{
|
||||
try
|
||||
{
|
||||
def describe = providers.exec {
|
||||
commandLine 'git', 'describe', '--tags', '--match', 'v[0-9]*', '--dirty'
|
||||
ignoreExitValue = true
|
||||
}
|
||||
|
||||
if(describe.result.get().exitValue == 0)
|
||||
{
|
||||
return describe.standardOutput.asText.get().trim()
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
logger.warn("Unable to determine version from git tags: " + e.message)
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
tasks.register('printVersion') {
|
||||
description = 'Prints the project version'
|
||||
def projectVersion = version
|
||||
doLast {
|
||||
println projectVersion
|
||||
}
|
||||
}
|
||||
|
||||
//Java 27 is required for this version of the Project Panama preview/incubator feature
|
||||
java {
|
||||
@@ -202,6 +238,7 @@ jar {
|
||||
attributes (
|
||||
'Implementation-Title' : 'sdrtrunk project',
|
||||
'Implementation-Version' : archiveVersion,
|
||||
'Git-Describe' : gitDescribe ?: 'unknown',
|
||||
'Created-By' : "Gradle ${gradle.gradleVersion}",
|
||||
'Build-Timestamp' : new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date()),
|
||||
'Build-JDK' : "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']}",
|
||||
|
||||
Reference in New Issue
Block a user