mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Polish
See gh-37878
This commit is contained in:
parent
42ee6b9e74
commit
dbc06faed8
@ -147,7 +147,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);
|
||||
@ -156,23 +157,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"));
|
||||
}
|
||||
|
@ -422,7 +422,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();
|
||||
|
Loading…
Reference in New Issue
Block a user