Class ApplicationBuilder
- All Implemented Interfaces:
Generator, Renamable, ResourceProvider
The ApplicationBuilder generates resources of type
ApplicationZipFile or ApplicationTarFile.
Both resource types are runnable application distributions built from a set of classpath resources and a generated start script that launches the application.
The application can be configured using methods that control:
- the output directory for the generated distribution,
- the base name of the generated archive file,
- the executable (start script) name,
- the main class to execute (mandatory),
- and the JVM options required by the application and included in the generated start script.
Method add(Stream) is used to specify the classpath resources to
be included in the generated distribution and to be added to the
classpath when running the application.
A request for Cleanliness removes any generated distribution
archives from the configured destination directory.
The ApplicationBuilder avoids duplicate libraries in the distribution
by deduplicating JarFiles based on their file path. If the same jar
file is added multiple times, only one copy will be included in the
generated distribution.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(Stream<? extends ClasspathElement> resources) Adds the given classpath resources to the application.applicationJvmOpts(Consumer<List<String>> modifier) Passes the mutable list of JVM options to the given consumer for modification.Returns the destination directory.destination(Path destination) Sets the destination directory.destination(Supplier<Path> destination) Sets the destination directory.Returns the base name of the generated TAR or ZIP file.distributionBaseName(Supplier<String> distributionBaseName) Sets the supplier for obtaining the name of the generated ZIP or TAR file's base name inResourceProviderSpi.provide(ResourceRequest).protected <T extends Resource>
Collection<T> doProvide(ResourceRequest<T> request) Invoked byResourceProviderSpi.provide(ResourceRequest)after checking if the invocation is allowed.Returns the name of the script that starts the application.executableName(String name) Sets the executable name.Returns the main class name.mainClassName(String name) Sets the name of the main class (the application entry point).Set the new name.Methods inherited from class AbstractGenerator
cleanup, project, toStringMethods inherited from class AbstractProvider
context, name, of, rename, vavrStreamMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ResourceProvider
context, name, of, resources
-
Constructor Details
-
ApplicationBuilder
Initializes a new application builder.- Parameters:
project- the project
-
-
Method Details
-
name
Description copied from interface:RenamableSet the new name.- Specified by:
namein interfaceRenamable- Overrides:
namein classAbstractGenerator- Parameters:
name- the name- Returns:
- the renamable
-
executableName
Returns the name of the script that starts the application. The script for Windows has.batappended to this name.- Returns:
- the string
-
executableName
Sets the executable name.- Parameters:
name- the name- Returns:
- the application builder
-
destination
Returns the destination directory. Defaults to sub directoryapplicationsin the project's build directory (seeProject.buildDirectory()).- Returns:
- the destination
-
destination
Sets the destination directory. ThePathis resolved against the project's build directory (seeProject.buildDirectory()).- Parameters:
destination- the new destination- Returns:
- the application builder
-
destination
Sets the destination directory.- Parameters:
destination- the new destination- Returns:
- the jar generator
-
distributionBaseName
Returns the base name of the generated TAR or ZIP file. The base name is the file name without the extension. Defaults to the project's name followed by its version.- Returns:
- the string
-
distributionBaseName
Sets the supplier for obtaining the name of the generated ZIP or TAR file's base name inResourceProviderSpi.provide(ResourceRequest).- Parameters:
distributionBaseName- the distribution base name- Returns:
- the application builder
-
mainClassName
-
mainClassName
Sets the name of the main class (the application entry point).- Parameters:
name- the new main class name- Returns:
- the jar generator for method chaining
-
applicationJvmOpts
Passes the mutable list of JVM options to the given consumer for modification. The start script distinguishes between these options, which reflect settings required by the application, and theJAVA_OPTSthat may be used when starting the application to tune the JVM for specific environments.- Parameters:
modifier- the modifier- Returns:
- the list
-
add
Adds the given classpath resources to the application.- Parameters:
resources- the resources- Returns:
- the application builder
-
doProvide
Description copied from class:AbstractProviderInvoked byResourceProviderSpi.provide(ResourceRequest)after checking if the invocation is allowed.- Specified by:
doProvidein classAbstractProvider- Type Parameters:
T- the generic type- Parameters:
request- the request for resources- Returns:
- the stream
-