// SPDX-FileCopyrightText: Copyright 2020-2025 Mark Rotteveel
// SPDX-License-Identifier: LGPL-2.1-or-later
import java.time.LocalDateTime

// Property configuration for build

// Standard version information config from build.properties
def buildProperties = new Properties()
file('build.properties').withInputStream {
    buildProperties.load(it)
}
// Optional local environment config from build-local.properties
def localBuildPropertiesFile = file('build-local.properties')
if (localBuildPropertiesFile.exists()) {
    localBuildPropertiesFile.withInputStream {
        buildProperties.load(it)
    }
}
buildProperties.stringPropertyNames().each {
    ext.set(it, buildProperties[it])
}

def buildTime = LocalDateTime.now()
ext.'build.id' = buildTime.format('yyyyMMddHHmm')
ext.YEAR = buildTime.format('yyyy')

// Build profile
ext.'maven.jdkversion' = 'java17'
ext.'specification.version' = '4.3'

ext.'version.simple' = "${project.'version.major'}.${project.'version.minor'}.${project.'version.revision'}".toString()
ext.'version.maven' = "${project.'version.simple'}${project.'version.tag'}".toString()

ext.'signing.password' = credentials.forKey('signing.password')
ext.centralPassword = credentials.forKey('centralPassword')

ext.isReleaseVersion = provider {
    !version.endsWith("SNAPSHOT")
}

ext.sourceDocumentation = file('src/documentation')
ext.buildDocs = layout.buildDirectory.dir("docs")
