Class ApplicationBuilder
- All Implemented Interfaces:
Generator, Renamable, ResourceProvider, ResourceRetriever
The ApplicationBuilder generates application distributions as
resources of type ApplicationZipFile or ApplicationTarFile.
Both resource types represent runnable application distributions consisting 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 added to the
classpath when running the application. In addition, the application
builder adds the resources obtained from the providers specified
with addFrom(Stream), using a request for resources of type LibraryJarFile
with all intents.
Special handling is provided for resources of type MvnRepoJarFile.
For these resources the associated MvnRepoResource information is
collected first. The collected coordinates are then used to resolve
the corresponding jar files from the Maven repository. The resolved
JAR files are then added to the generated distribution. This prevents
different versions of the same library to be included in the
distribution.
A request for Cleanliness removes any generated distribution
archives from the configured destination directory.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(Stream<? extends ClasspathElement> resources) Adds the given classpath resources to the application.addFrom(Stream<ResourceProvider> providers) Adds the given providers as sources for resources.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, resourcesMethods inherited from interface ResourceRetriever
addFrom
-
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
-
addFrom
Description copied from interface:ResourceRetrieverAdds the given providers as sources for resources. The stream must not be consumed before the generators' provide method is invoked.- Specified by:
addFromin interfaceResourceRetriever- Parameters:
providers- the providers to retrieve resources from- Returns:
- the resource retriever
-
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
-