mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-21 19:42:14 +00:00
GP-3111: Enforcing maximum supported Gradle version
This commit is contained in:
parent
8242c31c4a
commit
50a3bc30d2
@ -58,14 +58,23 @@ public class ApplicationProperties extends Properties {
|
||||
public static final String APPLICATION_GRADLE_MIN_PROPERTY = "application.gradle.min";
|
||||
|
||||
/**
|
||||
* The minimum major version of Java required to run the application. For example, "8".
|
||||
* The earliest version of gradle after {@link #APPLICATION_GRADLE_MIN_PROPERTY} that is
|
||||
* unsupported.
|
||||
* <p>
|
||||
* If all versions of Gradle greater than or equal to {@link #APPLICATION_GRADLE_MIN_PROPERTY}
|
||||
* are supported, this property should not be set.
|
||||
*/
|
||||
public static final String APPLICATION_GRADLE_MAX_PROPERTY = "application.gradle.max";
|
||||
|
||||
/**
|
||||
* The minimum major version of Java required to run the application.
|
||||
*/
|
||||
public static final String APPLICATION_JAVA_MIN_PROPERTY = "application.java.min";
|
||||
|
||||
/**
|
||||
* The maximum major version of Java the application will run under. For example, "8".
|
||||
* The maximum major version of Java the application will run under.
|
||||
* <p>
|
||||
* If all versions of Java greater than {@link #APPLICATION_JAVA_MIN_PROPERTY} are
|
||||
* If all versions of Java greater than or equal to {@link #APPLICATION_JAVA_MIN_PROPERTY} are
|
||||
* supported, this property should not be set.
|
||||
*/
|
||||
public static final String APPLICATION_JAVA_MAX_PROPERTY = "application.java.max";
|
||||
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ application.version=10.3
|
||||
application.release.name=DEV
|
||||
application.layout.version=1
|
||||
application.gradle.min=7.3
|
||||
application.gradle.max=
|
||||
application.java.min=17
|
||||
application.java.max=
|
||||
application.java.compiler=17
|
||||
|
40
build.gradle
40
build.gradle
@ -25,10 +25,7 @@ apply from: "gradle/support/loadApplicationProperties.gradle"
|
||||
***************************************************************************************/
|
||||
import org.gradle.util.GradleVersion;
|
||||
println "Gradle: " + GradleVersion.current().version
|
||||
final GradleVersion minimum_version = GradleVersion.version("${rootProject.GRADLE_MINIMUM_VERSION}")
|
||||
if (GradleVersion.current() < minimum_version) {
|
||||
throw new GradleException("Requires at least $minimum_version, but was run with $gradle.gradleVersion")
|
||||
}
|
||||
checkGradleVersion()
|
||||
|
||||
/***************************************************************************************
|
||||
* Define the location of JAVA_HOME
|
||||
@ -113,6 +110,41 @@ clean {
|
||||
delete "$buildDir"
|
||||
}
|
||||
|
||||
/*********************************************************************************
|
||||
* Throws a GradleException if the current Gradle version is outside of the supported
|
||||
* Gradle version range defined in application.properties.
|
||||
*
|
||||
* NOTE: This function is duplicated in buildExtension.gradle
|
||||
*********************************************************************************/
|
||||
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")
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************************
|
||||
*
|
||||
* Utility methods used by multiple build.gradle files
|
||||
|
@ -26,7 +26,8 @@ file("Ghidra/application.properties").withReader { reader ->
|
||||
project.ext.RELEASE_VERSION = version
|
||||
project.ext.RELEASE_NAME = ghidraProps.getProperty('application.release.name')
|
||||
project.ext.JAVA_COMPILER = ghidraProps.getProperty('application.java.compiler')
|
||||
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')
|
||||
project.ext.DISTRO_PREFIX = "ghidra_${version}_${RELEASE_NAME}"
|
||||
|
||||
// Build dates may or may not be already present in the application.properties file.
|
||||
|
Loading…
Reference in New Issue
Block a user