Make MIN_SPRING_VERSION Dynamic
Fixes: gh-5065 # Conflicts: # core/src/main/java/org/springframework/security/core/SpringSecurityCoreVersion.java
This commit is contained in:
@@ -34,6 +34,17 @@ dependencies {
|
||||
testRuntime 'org.hsqldb:hsqldb'
|
||||
}
|
||||
|
||||
task springVersion(type: versions.VersionsResourceTasks) {
|
||||
versionsFile = file("${buildDir}/versions/spring-security.versions")
|
||||
versions = { project.dependencyManagement.managedVersions }
|
||||
}
|
||||
|
||||
tasks.processResources {
|
||||
into('META-INF') {
|
||||
from project.tasks.springVersion.outputs
|
||||
}
|
||||
}
|
||||
|
||||
tasks.jar.from { includeProject.sourceSets.main.output }
|
||||
|
||||
tasks.sourcesJar.from {includeProject.sourceSets.main.java}
|
||||
|
||||
+21
-1
@@ -20,6 +20,9 @@ import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.core.SpringVersion;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Internal class used for checking version compatibility in a deployed application.
|
||||
*
|
||||
@@ -40,7 +43,7 @@ public class SpringSecurityCoreVersion {
|
||||
*/
|
||||
public static final long SERIAL_VERSION_UID = 500L;
|
||||
|
||||
static final String MIN_SPRING_VERSION = "5.0.5.RELEASE";
|
||||
static final String MIN_SPRING_VERSION = getSpringVersion();
|
||||
|
||||
static {
|
||||
performVersionChecks();
|
||||
@@ -64,6 +67,9 @@ public class SpringSecurityCoreVersion {
|
||||
* @param minSpringVersion
|
||||
*/
|
||||
private static void performVersionChecks(String minSpringVersion) {
|
||||
if (minSpringVersion == null) {
|
||||
return;
|
||||
}
|
||||
// Check Spring Compatibility
|
||||
String springVersion = SpringVersion.getVersion();
|
||||
String version = getVersion();
|
||||
@@ -95,4 +101,18 @@ public class SpringSecurityCoreVersion {
|
||||
}
|
||||
return Boolean.getBoolean(DISABLE_CHECKS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the spring version or null if it cannot be found.
|
||||
* @return
|
||||
*/
|
||||
private static String getSpringVersion() {
|
||||
Properties properties = new Properties();
|
||||
try {
|
||||
properties.load(SpringSecurityCoreVersion.class.getClassLoader().getResourceAsStream("META-INF/spring-security.versions"));
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
return properties.getProperty("org.springframework:spring-core");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user