mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-28 17:11:11 -09:00
GP-3111: Enforcing maximum supported Gradle version
This commit is contained in:
@@ -33,17 +33,14 @@ file(ghidraDir + "/application.properties").withReader { reader ->
|
||||
project.ext.ghidra_version = ghidraProps.getProperty('application.version')
|
||||
project.ext.RELEASE_NAME = ghidraProps.getProperty('application.release.name')
|
||||
project.ext.DISTRO_PREFIX = "ghidra_${ghidra_version}"
|
||||
project.ext.GRADLE_MINIMUM_VERSION = ghidraProps.getProperty('application.gradle.min')
|
||||
project.ext.GRADLE_MIN = ghidraProps.getProperty('application.gradle.min')
|
||||
project.ext.GRADLE_MAX = ghidraProps.getProperty('application.gradle.max')
|
||||
}
|
||||
|
||||
/***************************************************************************************
|
||||
* Make sure the correct version of gradle is being used
|
||||
* Make sure a supported version of Gradle is being used
|
||||
***************************************************************************************/
|
||||
import org.gradle.util.GradleVersion;
|
||||
final GradleVersion minimum_version = GradleVersion.version("${GRADLE_MINIMUM_VERSION}")
|
||||
if (GradleVersion.current() < minimum_version) {
|
||||
throw new GradleException("Requires at least $minimum_version, but was run with $gradle.gradleVersion")
|
||||
}
|
||||
checkGradleVersion()
|
||||
|
||||
configurations {
|
||||
helpPath
|
||||
@@ -331,3 +328,36 @@ def getCurrentDate() {
|
||||
return formattedDate
|
||||
}
|
||||
|
||||
/*********************************************************************************
|
||||
* Throws a GradleException if the current Gradle version is outside of the supported
|
||||
* Gradle version range defined in application.properties
|
||||
*********************************************************************************/
|
||||
import org.gradle.util.GradleVersion;
|
||||
def checkGradleVersion() {
|
||||
GradleVersion min = null;
|
||||
GradleVersion max = null;
|
||||
try {
|
||||
min = GradleVersion.version("${rootProject.GRADLE_MIN}")
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
String defaultMin = "1.0"
|
||||
println "Invalid minimum Gradle version specified in application.properties...using ${defaultMin}"
|
||||
min = GradleVersion.version(defaultMin)
|
||||
}
|
||||
try {
|
||||
if (rootProject.GRADLE_MAX) {
|
||||
max = GradleVersion.version("${rootProject.GRADLE_MAX}")
|
||||
}
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
println "Invalid maximum Gradle version specified in application.properties...ignoring"
|
||||
}
|
||||
String gradleRange = "at least ${min}"
|
||||
if (max) {
|
||||
gradleRange += " and less than ${max}"
|
||||
}
|
||||
if (GradleVersion.current() < min || (max && GradleVersion.current() >= max)) {
|
||||
throw new GradleException("Requires ${gradleRange}, but was run with $gradle.gradleVersion")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user