ApplicationSpec
, Named
public abstract class Application extends Object implements ApplicationSpec, Named
Application
is a specification for building a runnable JAR (meaning one that java -jar
is able to
execute directly). Based on the specification, Gradle will make an exact copy of an existing Jar
task's
output, add the necessary attributes to the copy's Manifest
, and set up a Distribution
to bundle this
enhanced JAR with its dependencies.ApplicationJar
,
JAR Files as ApplicationsNamed.Namer
Modifier and Type | Field | Description |
---|---|---|
static String |
APPLICATION |
Identifier to be used in names.
|
static String |
LIBRARY_ELEMENTS_APPLICATION_JAR |
LibraryElements attribute value indicating a JAR artifact that can be started
directly as an application (using the java -jar command). |
static String |
MAIN_APPLICATION_CONFIGURATION_NAME |
Name of the main application configuration.
|
static String |
MAIN_APPLICATION_JAR_TASK_NAME |
Name of the main application JAR task.
|
static String |
MAIN_APPLICATION_NAME |
Name of the main application.
|
Constructor | Description |
---|---|
Application(Project project,
String name) |
Creates an
Application instance. |
Modifier and Type | Method | Description |
---|---|---|
void |
applicationJar(Action<? super ApplicationJar> action) |
Configures the
ApplicationJar for the application. |
void |
configuration(Action<? super Configuration> action) |
Configures the
Configuration for the application. |
void |
distribution(Action<? super Distribution> action) |
Configures the
Distribution for the application. |
void |
finalizeProperties() |
Finalizes and validates the properties of this application.
|
abstract Property<String> |
getApplicationBaseName() |
The base name of this application, used in naming the application JAR and the distribution archives.
|
TaskProvider<ApplicationJar> |
getApplicationJar() |
Returns the
ApplicationJar for the application. |
NamedDomainObjectProvider<Configuration> |
getConfiguration() |
Returns the
Configuration for the application, representing its runtime elements
(application JAR artifact and its dependencies). |
String |
getDescription() |
Returns the description of the application (for informational purposes).
|
NamedDomainObjectProvider<Distribution> |
getDistribution() |
Returns the
Distribution for the application. |
String |
getName() |
Returns the name of this application.
|
Project |
getProject() |
Returns the project this application belongs to.
|
void |
setDescription(String description) |
Sets the description of the application (for informational purposes).
|
String |
toString() |
Returns the display name of this
Application that can be used in log and error messages. |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
fromSourceSet, fromSourceSet, getDependencies, getDependencyDirectoryName, getMainClass, getRawJar, locateDependencies, locateDependencies, locateRawJar, locateRawJar
public static final String APPLICATION
public static final String MAIN_APPLICATION_NAME
public static final String MAIN_APPLICATION_JAR_TASK_NAME
public static final String MAIN_APPLICATION_CONFIGURATION_NAME
public static final String LIBRARY_ELEMENTS_APPLICATION_JAR
LibraryElements
attribute value indicating a JAR
artifact that can be started
directly as an application (using the java -jar
command).@Inject public Application(@Nonnull Project project, @Nonnull String name)
Application
instance.project
- The project that the application belongs to.name
- The name of the application.@Nonnull public Project getProject()
getProject
in interface ApplicationSpec
@Nonnull public String toString()
Application
that can be used in log and error messages.toString
in class Object
Application
.@Nullable public String getDescription()
public void setDescription(@Nullable String description)
description
- The description of the application.@Nonnull public abstract Property<String> getApplicationBaseName()
The base name of this application, used in naming the application JAR and the distribution archives.
The default value is as follows:
"${project.name}"
."${project.name}-${this.name}"
.Property
object specifying the application's base name.Distribution.getDistributionBaseName()
@Nonnull public TaskProvider<ApplicationJar> getApplicationJar()
ApplicationJar
for the application.ApplicationJar
for the application.public void applicationJar(@Nonnull Action<? super ApplicationJar> action)
ApplicationJar
for the application.action
- Action to configure the ApplicationJar
.@Nonnull public NamedDomainObjectProvider<Configuration> getConfiguration()
Configuration
for the application, representing its runtime elements
(application JAR artifact and its dependencies).Configuration
for the application.applicationJar
,
dependencies
public void configuration(@Nonnull Action<? super Configuration> action)
Configuration
for the application.action
- Action to configure the Configuration
.@Nonnull public NamedDomainObjectProvider<Distribution> getDistribution()
Distribution
for the application.Distribution
for the application.public void distribution(@Nonnull Action<? super Distribution> action)
Distribution
for the application.action
- Action to configure the Distribution
.public void finalizeProperties()
IllegalStateException
.GradleException
- If the application's configuration is invalid.Property.finalizeValue()