Skip to content
Docs Try Aspire
Docs Try

JavaAppHostingExtension Methods

Class Methods 15 members
Provides extension methods for adding Java applications to an Hosting.IDistributedApplicationBuilder.
AddJavaApp(IDistributedApplicationBuilder, string, JavaAppContainerResourceOptions) Section titled AddJavaApp(IDistributedApplicationBuilder, string, JavaAppContainerResourceOptions) extension IResourceBuilder<JavaAppContainerResource>
Adds a Java application to the application model. Executes the containerized Java app.
public static class JavaAppHostingExtension
{
public static IResourceBuilder<JavaAppContainerResource> AddJavaApp(
this IDistributedApplicationBuilder builder,
string name,
JavaAppContainerResourceOptions options)
{
// ...
}
}
builder IDistributedApplicationBuilder The Hosting.IDistributedApplicationBuilder to add the resource to.
name string The name of the resource.
options JavaAppContainerResourceOptions The JavaAppContainerResourceOptions to configure the Java application.
IResourceBuilder<JavaAppContainerResource> A reference to the ApplicationModel.IResourceBuilder`1.
AddJavaApp(IDistributedApplicationBuilder, string, string, string, string[]?) Section titled AddJavaApp(IDistributedApplicationBuilder, string, string, string, string[]?) extension IResourceBuilder<JavaAppExecutableResource>
Adds a Java application to the application model. Executes the executable Java app.
public static class JavaAppHostingExtension
{
public static IResourceBuilder<JavaAppExecutableResource> AddJavaApp(
this IDistributedApplicationBuilder builder,
string name,
string workingDirectory,
string jarPath,
string[]? args = null)
{
// ...
}
}
builder IDistributedApplicationBuilder The Hosting.IDistributedApplicationBuilder to add the resource to.
name string The name of the resource.
workingDirectory string The working directory to use for the command.
jarPath string The path to the jar file, relative to the resource working directory.
args string[]? optional The optional arguments to be passed to the executable when it is started.
IResourceBuilder<JavaAppExecutableResource> A reference to the ApplicationModel.IResourceBuilder`1.
AddJavaApp(IDistributedApplicationBuilder, string, string) Section titled AddJavaApp(IDistributedApplicationBuilder, string, string) extension IResourceBuilder<JavaAppExecutableResource>
Adds a Java application to the application model. Executes the executable Java app.
public static class JavaAppHostingExtension
{
public static IResourceBuilder<JavaAppExecutableResource> AddJavaApp(
this IDistributedApplicationBuilder builder,
string name,
string workingDirectory)
{
// ...
}
}
builder IDistributedApplicationBuilder The Hosting.IDistributedApplicationBuilder to add the resource to.
name string The name of the resource.
workingDirectory string The working directory to use for the command.
IResourceBuilder<JavaAppExecutableResource> A reference to the ApplicationModel.IResourceBuilder`1.
Use JavaAppHostingExtension.WithMavenGoal or JavaAppHostingExtension.WithGradleTask to run the application via a build tool, or use the overload that accepts a jarPath parameter to run with java -jar.
AddJavaApp(IDistributedApplicationBuilder, string, string, JavaAppExecutableResourceOptions) Section titled AddJavaApp(IDistributedApplicationBuilder, string, string, JavaAppExecutableResourceOptions) extension IResourceBuilder<JavaAppExecutableResource>
Adds a Java application to the application model. Executes the executable Java app.
public static class JavaAppHostingExtension
{
public static IResourceBuilder<JavaAppExecutableResource> AddJavaApp(
this IDistributedApplicationBuilder builder,
string name,
string workingDirectory,
JavaAppExecutableResourceOptions options)
{
// ...
}
}
builder IDistributedApplicationBuilder The Hosting.IDistributedApplicationBuilder to add the resource to.
name string The name of the resource.
workingDirectory string The working directory to use for the command.
options JavaAppExecutableResourceOptions The JavaAppExecutableResourceOptions to configure the Java application.
IResourceBuilder<JavaAppExecutableResource> A reference to the ApplicationModel.IResourceBuilder`1.
AddJavaContainerApp(IDistributedApplicationBuilder, string, string, string?) Section titled AddJavaContainerApp(IDistributedApplicationBuilder, string, string, string?) extension IResourceBuilder<JavaAppContainerResource>
Adds a Java application to the application model. Executes the containerized Java app.
public static class JavaAppHostingExtension
{
public static IResourceBuilder<JavaAppContainerResource> AddJavaContainerApp(
this IDistributedApplicationBuilder builder,
string name,
string image,
string? imageTag = null)
{
// ...
}
}
builder IDistributedApplicationBuilder The Hosting.IDistributedApplicationBuilder to add the resource to.
name string The name of the resource.
image string The container image name.
imageTag string? optional The container image tag.
IResourceBuilder<JavaAppContainerResource> A reference to the ApplicationModel.IResourceBuilder`1.
AddSpringApp(IDistributedApplicationBuilder, string, JavaAppContainerResourceOptions) Section titled AddSpringApp(IDistributedApplicationBuilder, string, JavaAppContainerResourceOptions) extension IResourceBuilder<JavaAppContainerResource>
Adds a Spring application to the application model. Executes the containerized Spring app.
public static class JavaAppHostingExtension
{
public static IResourceBuilder<JavaAppContainerResource> AddSpringApp(
this IDistributedApplicationBuilder builder,
string name,
JavaAppContainerResourceOptions options)
{
// ...
}
}
builder IDistributedApplicationBuilder The Hosting.IDistributedApplicationBuilder to add the resource to.
name string The name of the resource.
options JavaAppContainerResourceOptions The JavaAppContainerResourceOptions to configure the Java application.
IResourceBuilder<JavaAppContainerResource> A reference to the ApplicationModel.IResourceBuilder`1.
AddSpringApp(IDistributedApplicationBuilder, string, string, JavaAppExecutableResourceOptions) Section titled AddSpringApp(IDistributedApplicationBuilder, string, string, JavaAppExecutableResourceOptions) extension IResourceBuilder<JavaAppExecutableResource>
Adds a Spring application to the application model. Executes the executable Spring app.
public static class JavaAppHostingExtension
{
public static IResourceBuilder<JavaAppExecutableResource> AddSpringApp(
this IDistributedApplicationBuilder builder,
string name,
string workingDirectory,
JavaAppExecutableResourceOptions options)
{
// ...
}
}
builder IDistributedApplicationBuilder The Hosting.IDistributedApplicationBuilder to add the resource to.
name string The name of the resource.
workingDirectory string The working directory to use for the command. If null, the working directory of the current process is used.
options JavaAppExecutableResourceOptions The JavaAppExecutableResourceOptions to configure the Java application.
IResourceBuilder<JavaAppExecutableResource> A reference to the ApplicationModel.IResourceBuilder`1.
WithGradleBuild(IResourceBuilder<JavaAppExecutableResource>, string[]) Section titled WithGradleBuild(IResourceBuilder<JavaAppExecutableResource>, string[]) extension IResourceBuilder<JavaAppExecutableResource>
Adds a Gradle build step to the application model. The wrapper script path defaults to gradlew (or gradlew.bat on Windows) in the resource's working directory, unless overridden with JavaAppHostingExtension.WithWrapperPath.
public static class JavaAppHostingExtension
{
public static IResourceBuilder<JavaAppExecutableResource> WithGradleBuild(
this IResourceBuilder<JavaAppExecutableResource> builder,
params string[] args)
{
// ...
}
}
builder IResourceBuilder<JavaAppExecutableResource> The ApplicationModel.IResourceBuilder`1 to add the Gradle build step to.
args string[] Arguments to pass to the Gradle wrapper. If not provided, defaults to clean build.
IResourceBuilder<JavaAppExecutableResource> A reference to the ApplicationModel.IResourceBuilder`1.
WithGradleTask(IResourceBuilder<JavaAppExecutableResource>, string, string[]) Section titled WithGradleTask(IResourceBuilder<JavaAppExecutableResource>, string, string[]) extension IResourceBuilder<JavaAppExecutableResource>
Configures the Java application to run using a Gradle task (e.g., bootRun). In run mode, the resource command is changed from java to the Gradle wrapper. The wrapper script path defaults to gradlew (or gradlew.bat on Windows) in the resource's working directory, unless overridden with JavaAppHostingExtension.WithWrapperPath.
public static class JavaAppHostingExtension
{
public static IResourceBuilder<JavaAppExecutableResource> WithGradleTask(
this IResourceBuilder<JavaAppExecutableResource> builder,
string task,
params string[] args)
{
// ...
}
}
builder IResourceBuilder<JavaAppExecutableResource> The ApplicationModel.IResourceBuilder`1 to configure.
task string The Gradle task to execute (e.g., bootRun).
args string[] Additional arguments to pass to the Gradle wrapper.
IResourceBuilder<JavaAppExecutableResource> A reference to the ApplicationModel.IResourceBuilder`1.
WithJvmArgs(IResourceBuilder<T>, string[]) Section titled WithJvmArgs(IResourceBuilder<T>, string[]) extension IResourceBuilder<T>
Configures the Java Virtual Machine arguments for the Java application. The arguments are set via the JAVA_TOOL_OPTIONS environment variable, which is recognized by the JVM regardless of how the application is launched (e.g., java -jar, Maven wrapper, or Gradle wrapper).
public static class JavaAppHostingExtension
{
public static IResourceBuilder<T> WithJvmArgs<T>(
this IResourceBuilder<T> builder,
string[] args)
{
// ...
}
}
builder IResourceBuilder<T> The resource builder.
args string[] The JVM arguments.
IResourceBuilder<T> A reference to the ApplicationModel.IResourceBuilder`1.
WithMavenBuild(IResourceBuilder<JavaAppExecutableResource>, MavenOptions) Section titled WithMavenBuild(IResourceBuilder<JavaAppExecutableResource>, MavenOptions) extension IResourceBuilder<JavaAppExecutableResource>
Adds a Maven build step to the application model.
public static class JavaAppHostingExtension
{
public static IResourceBuilder<JavaAppExecutableResource> WithMavenBuild(
this IResourceBuilder<JavaAppExecutableResource> builder,
MavenOptions mavenOptions)
{
// ...
}
}
builder IResourceBuilder<JavaAppExecutableResource> The ApplicationModel.IResourceBuilder`1 to add the Maven build step to.
mavenOptions MavenOptions The MavenOptions to configure the Maven build step.
IResourceBuilder<JavaAppExecutableResource> A reference to the ApplicationModel.IResourceBuilder`1.
WithMavenBuild(IResourceBuilder<JavaAppExecutableResource>, string[]) Section titled WithMavenBuild(IResourceBuilder<JavaAppExecutableResource>, string[]) extension IResourceBuilder<JavaAppExecutableResource>
Adds a Maven build step to the application model. The wrapper script path defaults to mvnw (or mvnw.cmd on Windows) in the resource's working directory, unless overridden with JavaAppHostingExtension.WithWrapperPath.
public static class JavaAppHostingExtension
{
public static IResourceBuilder<JavaAppExecutableResource> WithMavenBuild(
this IResourceBuilder<JavaAppExecutableResource> builder,
params string[] args)
{
// ...
}
}
builder IResourceBuilder<JavaAppExecutableResource> The ApplicationModel.IResourceBuilder`1 to add the Maven build step to.
args string[] Arguments to pass to the Maven wrapper. If not provided, defaults to clean package.
IResourceBuilder<JavaAppExecutableResource> A reference to the ApplicationModel.IResourceBuilder`1.
WithMavenGoal(IResourceBuilder<JavaAppExecutableResource>, string, string[]) Section titled WithMavenGoal(IResourceBuilder<JavaAppExecutableResource>, string, string[]) extension IResourceBuilder<JavaAppExecutableResource>
Configures the Java application to run using a Maven goal (e.g., spring-boot:run). In run mode, the resource command is changed from java to the Maven wrapper. The wrapper script path defaults to mvnw (or mvnw.cmd on Windows) in the resource's working directory, unless overridden with JavaAppHostingExtension.WithWrapperPath.
public static class JavaAppHostingExtension
{
public static IResourceBuilder<JavaAppExecutableResource> WithMavenGoal(
this IResourceBuilder<JavaAppExecutableResource> builder,
string goal,
params string[] args)
{
// ...
}
}
builder IResourceBuilder<JavaAppExecutableResource> The ApplicationModel.IResourceBuilder`1 to configure.
goal string The Maven goal to execute (e.g., spring-boot:run).
args string[] Additional arguments to pass to the Maven wrapper.
IResourceBuilder<JavaAppExecutableResource> A reference to the ApplicationModel.IResourceBuilder`1.
WithOtelAgent(IResourceBuilder<T>, string?) Section titled WithOtelAgent(IResourceBuilder<T>, string?) extension IResourceBuilder<T>
Configures the OpenTelemetry Java Agent for the Java application.
public static class JavaAppHostingExtension
{
public static IResourceBuilder<T> WithOtelAgent<T>(
this IResourceBuilder<T> builder,
string? agentPath = null)
{
// ...
}
}
builder IResourceBuilder<T> The resource builder.
agentPath string? optional The path to the OpenTelemetry Java Agent jar file.
IResourceBuilder<T> A reference to the ApplicationModel.IResourceBuilder`1.
WithWrapperPath(IResourceBuilder<JavaAppExecutableResource>, string) Section titled WithWrapperPath(IResourceBuilder<JavaAppExecutableResource>, string) extension IResourceBuilder<JavaAppExecutableResource>
Configures a custom build tool wrapper script path. This is useful when the wrapper script is not in the default location or has a non-standard name.
public static class JavaAppHostingExtension
{
public static IResourceBuilder<JavaAppExecutableResource> WithWrapperPath(
this IResourceBuilder<JavaAppExecutableResource> builder,
string wrapperScript)
{
// ...
}
}
builder IResourceBuilder<JavaAppExecutableResource> The ApplicationModel.IResourceBuilder`1 to configure.
wrapperScript string The path to the wrapper script, relative to the resource working directory or an absolute path.
IResourceBuilder<JavaAppExecutableResource> A reference to the ApplicationModel.IResourceBuilder`1.