Merge branch '3.1.x'

This commit is contained in:
Andy Wilkinson 2023-10-13 20:42:15 +01:00
commit 2231244d2c
2 changed files with 3 additions and 19 deletions

View File

@ -161,7 +161,8 @@ class BootArchiveSupport {
try {
Object filePermissions = ((Property<Object>) copySpec.getClass().getMethod(methodName).invoke(copySpec))
.getOrNull();
return getMode(filePermissions);
return (filePermissions != null)
? (int) filePermissions.getClass().getMethod("toUnixNumeric").invoke(filePermissions) : null;
}
catch (Exception ex) {
throw new GradleException("Failed to get permissions", ex);
@ -170,23 +171,6 @@ class BootArchiveSupport {
return fallback.get();
}
private Integer getMode(Object permissions) throws Exception {
if (permissions == null) {
return null;
}
String user = asIntegerString(permissions.getClass().getMethod("getUser").invoke(permissions));
String group = asIntegerString(permissions.getClass().getMethod("getGroup").invoke(permissions));
String other = asIntegerString(permissions.getClass().getMethod("getOther").invoke(permissions));
return Integer.parseInt("0" + user + group + other, 8);
}
private String asIntegerString(Object permissions) throws Exception {
boolean read = (boolean) permissions.getClass().getMethod("getRead").invoke(permissions);
boolean write = (boolean) permissions.getClass().getMethod("getWrite").invoke(permissions);
boolean execute = (boolean) permissions.getClass().getMethod("getExecute").invoke(permissions);
return Integer.toString(((read) ? 4 : 0) + ((write) ? 2 : 0) + ((execute) ? 1 : 0));
}
private boolean isUsingDefaultLoader(Jar jar) {
return DEFAULT_LAUNCHER_CLASSES.contains(jar.getManifest().getAttributes().get("Main-Class"));
}

View File

@ -471,7 +471,7 @@ class BootZipCopyAction implements CopyAction {
if (GradleVersion.current().compareTo(GradleVersion.version("8.3")) >= 0) {
try {
Object permissions = ((Provider<Object>) details.getClass()
.getMethod("getImmutablePermissions")
.getMethod("getPermissions")
.invoke(details)).get();
return ((Provider<Integer>) permissions.getClass().getMethod("toUnixNumeric").invoke(permissions))
.get();