Skip to content

Commit dbc06fa

Browse files
committed
Polish
See gh-37878
1 parent 42ee6b9 commit dbc06fa

File tree

2 files changed

+3
-19
lines changed

2 files changed

+3
-19
lines changed

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootArchiveSupport.java

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ private Integer getMode(CopySpec copySpec, String methodName, Supplier<Integer>
147147
try {
148148
Object filePermissions = ((Property<Object>) copySpec.getClass().getMethod(methodName).invoke(copySpec))
149149
.getOrNull();
150-
return getMode(filePermissions);
150+
return (filePermissions != null)
151+
? (int) filePermissions.getClass().getMethod("toUnixNumeric").invoke(filePermissions) : null;
151152
}
152153
catch (Exception ex) {
153154
throw new GradleException("Failed to get permissions", ex);
@@ -156,23 +157,6 @@ private Integer getMode(CopySpec copySpec, String methodName, Supplier<Integer>
156157
return fallback.get();
157158
}
158159

159-
private Integer getMode(Object permissions) throws Exception {
160-
if (permissions == null) {
161-
return null;
162-
}
163-
String user = asIntegerString(permissions.getClass().getMethod("getUser").invoke(permissions));
164-
String group = asIntegerString(permissions.getClass().getMethod("getGroup").invoke(permissions));
165-
String other = asIntegerString(permissions.getClass().getMethod("getOther").invoke(permissions));
166-
return Integer.parseInt("0" + user + group + other, 8);
167-
}
168-
169-
private String asIntegerString(Object permissions) throws Exception {
170-
boolean read = (boolean) permissions.getClass().getMethod("getRead").invoke(permissions);
171-
boolean write = (boolean) permissions.getClass().getMethod("getWrite").invoke(permissions);
172-
boolean execute = (boolean) permissions.getClass().getMethod("getExecute").invoke(permissions);
173-
return Integer.toString(((read) ? 4 : 0) + ((write) ? 2 : 0) + ((execute) ? 1 : 0));
174-
}
175-
176160
private boolean isUsingDefaultLoader(Jar jar) {
177161
return DEFAULT_LAUNCHER_CLASSES.contains(jar.getManifest().getAttributes().get("Main-Class"));
178162
}

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ private int getPermissions(FileCopyDetails details) {
422422
if (GradleVersion.current().compareTo(GradleVersion.version("8.3")) >= 0) {
423423
try {
424424
Object permissions = ((Provider<Object>) details.getClass()
425-
.getMethod("getImmutablePermissions")
425+
.getMethod("getPermissions")
426426
.invoke(details)).get();
427427
return ((Provider<Integer>) permissions.getClass().getMethod("toUnixNumeric").invoke(permissions))
428428
.get();

0 commit comments

Comments
 (0)