Skip to content

Commit 81aa674

Browse files
committed
Remove support for embedded launch scripts
Closes gh-47666
1 parent de39cc6 commit 81aa674

File tree

99 files changed

+18
-3511
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+18
-3511
lines changed

build-plugin/spring-boot-gradle-plugin/src/docs/antora/modules/gradle-plugin/examples/packaging/boot-jar-custom-launch-script.gradle

Lines changed: 0 additions & 32 deletions
This file was deleted.

build-plugin/spring-boot-gradle-plugin/src/docs/antora/modules/gradle-plugin/examples/packaging/boot-jar-custom-launch-script.gradle.kts

Lines changed: 0 additions & 18 deletions
This file was deleted.

build-plugin/spring-boot-gradle-plugin/src/docs/antora/modules/gradle-plugin/examples/packaging/boot-jar-include-launch-script.gradle

Lines changed: 0 additions & 30 deletions
This file was deleted.

build-plugin/spring-boot-gradle-plugin/src/docs/antora/modules/gradle-plugin/examples/packaging/boot-jar-include-launch-script.gradle.kts

Lines changed: 0 additions & 16 deletions
This file was deleted.

build-plugin/spring-boot-gradle-plugin/src/docs/antora/modules/gradle-plugin/examples/packaging/boot-jar-launch-script-properties.gradle

Lines changed: 0 additions & 32 deletions
This file was deleted.

build-plugin/spring-boot-gradle-plugin/src/docs/antora/modules/gradle-plugin/examples/packaging/boot-jar-launch-script-properties.gradle.kts

Lines changed: 0 additions & 18 deletions
This file was deleted.

build-plugin/spring-boot-gradle-plugin/src/docs/antora/modules/gradle-plugin/pages/packaging.adoc

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -246,75 +246,6 @@ The closure is passed a `FileTreeElement` and should return a `boolean` indicati
246246

247247

248248

249-
[[packaging-executable.configuring.launch-script]]
250-
=== Making an Archive Fully Executable
251-
252-
Spring Boot provides support for fully executable archives.
253-
An archive is made fully executable by prepending a shell script that knows how to launch the application.
254-
On Unix-like platforms, this launch script allows the archive to be run directly like any other executable or to be installed as a service.
255-
256-
NOTE: Currently, some tools do not accept this format so you may not always be able to use this technique.
257-
For example, `jar -xf` may silently fail to extract a jar or war that has been made fully-executable.
258-
It is recommended that you only enable this option if you intend to execute it directly, rather than running it with `java -jar` or deploying it to a servlet container.
259-
260-
To use this feature, the inclusion of the launch script must be enabled:
261-
262-
[tabs]
263-
======
264-
Groovy::
265-
+
266-
[source,groovy,indent=0,subs="verbatim,attributes"]
267-
----
268-
include::example$packaging/boot-jar-include-launch-script.gradle[tags=include-launch-script]
269-
----
270-
Kotlin::
271-
+
272-
[source,kotlin,indent=0,subs="verbatim,attributes"]
273-
----
274-
include::example$packaging/boot-jar-include-launch-script.gradle.kts[tags=include-launch-script]
275-
----
276-
======
277-
278-
This will add Spring Boot's default launch script to the archive.
279-
The default launch script includes several properties with sensible default values.
280-
The values can be customized using the `properties` property:
281-
282-
[tabs]
283-
======
284-
Groovy::
285-
+
286-
[source,groovy,indent=0,subs="verbatim,attributes"]
287-
----
288-
include::example$packaging/boot-jar-launch-script-properties.gradle[tags=launch-script-properties]
289-
----
290-
Kotlin::
291-
+
292-
[source,kotlin,indent=0,subs="verbatim,attributes"]
293-
----
294-
include::example$packaging/boot-jar-launch-script-properties.gradle.kts[tags=launch-script-properties]
295-
----
296-
======
297-
298-
If the default launch script does not meet your needs, the `script` property can be used to provide a custom launch script:
299-
300-
[tabs]
301-
======
302-
Groovy::
303-
+
304-
[source,groovy,indent=0,subs="verbatim,attributes"]
305-
----
306-
include::example$packaging/boot-jar-custom-launch-script.gradle[tags=custom-launch-script]
307-
----
308-
Kotlin::
309-
+
310-
[source,kotlin,indent=0,subs="verbatim,attributes"]
311-
----
312-
include::example$packaging/boot-jar-custom-launch-script.gradle.kts[tags=custom-launch-script]
313-
----
314-
======
315-
316-
317-
318249
[[packaging-executable.configuring.properties-launcher]]
319250
=== Using the PropertiesLauncher
320251

build-plugin/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootArchive.java

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import java.util.Set;
2020

21-
import org.gradle.api.Action;
2221
import org.gradle.api.JavaVersion;
2322
import org.gradle.api.Project;
2423
import org.gradle.api.Task;
@@ -30,7 +29,6 @@
3029
import org.gradle.api.specs.Spec;
3130
import org.gradle.api.tasks.Classpath;
3231
import org.gradle.api.tasks.Input;
33-
import org.gradle.api.tasks.Nested;
3432
import org.gradle.api.tasks.Optional;
3533
import org.jspecify.annotations.Nullable;
3634

@@ -65,28 +63,6 @@ public interface BootArchive extends Task {
6563
*/
6664
void requiresUnpack(Spec<FileTreeElement> spec);
6765

68-
/**
69-
* Returns the {@link LaunchScriptConfiguration} that will control the script that is
70-
* prepended to the archive.
71-
* @return the launch script configuration, or {@code null} if the launch script has
72-
* not been configured.
73-
*/
74-
@Nested
75-
@Optional
76-
@Nullable LaunchScriptConfiguration getLaunchScript();
77-
78-
/**
79-
* Configures the archive to have a prepended launch script.
80-
*/
81-
void launchScript();
82-
83-
/**
84-
* Configures the archive to have a prepended launch script, customizing its
85-
* configuration using the given {@code action}.
86-
* @param action the action to apply
87-
*/
88-
void launchScript(Action<LaunchScriptConfiguration> action);
89-
9066
/**
9167
* Returns the classpath that will be included in the archive.
9268
* @return the classpath

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ class BootArchiveSupport {
7575

7676
private final Function<FileCopyDetails, ZipCompression> compressionResolver;
7777

78-
private @Nullable LaunchScriptConfiguration launchScript;
79-
8078
BootArchiveSupport(String loaderMainClass, Spec<FileCopyDetails> librarySpec,
8179
Function<FileCopyDetails, ZipCompression> compressionResolver) {
8280
this.loaderMainClass = loaderMainClass;
@@ -129,13 +127,12 @@ CopyAction createCopyAction(Jar jar, ResolvedDependencies resolvedDependencies,
129127
boolean includeDefaultLoader = isUsingDefaultLoader(jar);
130128
Spec<FileTreeElement> requiresUnpack = this.requiresUnpack.getAsSpec();
131129
Spec<FileTreeElement> exclusions = this.exclusions.getAsExcludeSpec();
132-
LaunchScriptConfiguration launchScript = this.launchScript;
133130
Spec<FileCopyDetails> librarySpec = this.librarySpec;
134131
Function<FileCopyDetails, ZipCompression> compressionResolver = this.compressionResolver;
135132
String encoding = jar.getMetadataCharset();
136133
CopyAction action = new BootZipCopyAction(output, manifest, preserveFileTimestamps, dirPermissions,
137-
filePermissions, includeDefaultLoader, jarmodeToolsLocation, requiresUnpack, exclusions, launchScript,
138-
librarySpec, compressionResolver, encoding, resolvedDependencies, supportsSignatureFile, layerResolver);
134+
filePermissions, includeDefaultLoader, jarmodeToolsLocation, requiresUnpack, exclusions, librarySpec,
135+
compressionResolver, encoding, resolvedDependencies, supportsSignatureFile, layerResolver);
139136
return action;
140137
}
141138

@@ -175,14 +172,6 @@ private boolean isUsingDefaultLoader(Jar jar) {
175172
return DEFAULT_LAUNCHER_CLASSES.contains(jar.getManifest().getAttributes().get("Main-Class"));
176173
}
177174

178-
@Nullable LaunchScriptConfiguration getLaunchScript() {
179-
return this.launchScript;
180-
}
181-
182-
void setLaunchScript(LaunchScriptConfiguration launchScript) {
183-
this.launchScript = launchScript;
184-
}
185-
186175
void requiresUnpack(String... patterns) {
187176
this.requiresUnpack.include(patterns);
188177
}

build-plugin/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootJar.java

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -166,21 +166,6 @@ public void requiresUnpack(Spec<FileTreeElement> spec) {
166166
this.support.requiresUnpack(spec);
167167
}
168168

169-
@Override
170-
public @Nullable LaunchScriptConfiguration getLaunchScript() {
171-
return this.support.getLaunchScript();
172-
}
173-
174-
@Override
175-
public void launchScript() {
176-
enableLaunchScriptIfNecessary();
177-
}
178-
179-
@Override
180-
public void launchScript(Action<LaunchScriptConfiguration> action) {
181-
action.execute(enableLaunchScriptIfNecessary());
182-
}
183-
184169
/**
185170
* Returns the spec that describes the layers in a layered jar.
186171
* @return the spec for the layers
@@ -273,15 +258,6 @@ protected boolean isLibrary(FileCopyDetails details) {
273258
return path.startsWith(LIB_DIRECTORY);
274259
}
275260

276-
private LaunchScriptConfiguration enableLaunchScriptIfNecessary() {
277-
LaunchScriptConfiguration launchScript = this.support.getLaunchScript();
278-
if (launchScript == null) {
279-
launchScript = new LaunchScriptConfiguration(this);
280-
this.support.setLaunchScript(launchScript);
281-
}
282-
return launchScript;
283-
}
284-
285261
/**
286262
* Syntactic sugar that makes {@link CopySpec#into} calls a little easier to read.
287263
* @param <T> the result type

0 commit comments

Comments
 (0)