Skip to content
DocsTry Aspire
DocsTry

JavaAppHostingExtension Methods

ClassMethods15 members
Provides extension methods for adding Java applications to an Hosting.IDistributedApplicationBuilder.
AddJavaApp(IDistributedApplicationBuilder, string, JavaAppContainerResourceOptions)Section titled AddJavaApp(IDistributedApplicationBuilder, string, JavaAppContainerResourceOptions)extensionIResourceBuilder<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)
{
// ...
}
}
builderIDistributedApplicationBuilderThe Hosting.IDistributedApplicationBuilder to add the resource to.
namestringThe name of the resource.
optionsJavaAppContainerResourceOptionsThe 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[]?)extensionIResourceBuilder<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)
{
// ...
}
}
builderIDistributedApplicationBuilderThe Hosting.IDistributedApplicationBuilder to add the resource to.
namestringThe name of the resource.
workingDirectorystringThe working directory to use for the command.
jarPathstringThe path to the jar file, relative to the resource working directory.
argsstring[]?optionalThe 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)extensionIResourceBuilder<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)
{
// ...
}
}
builderIDistributedApplicationBuilderThe Hosting.IDistributedApplicationBuilder to add the resource to.
namestringThe name of the resource.
workingDirectorystringThe 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)extensionIResourceBuilder<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)
{
// ...
}
}
builderIDistributedApplicationBuilderThe Hosting.IDistributedApplicationBuilder to add the resource to.
namestringThe name of the resource.
workingDirectorystringThe working directory to use for the command.
optionsJavaAppExecutableResourceOptionsThe 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?)extensionIResourceBuilder<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)
{
// ...
}
}
builderIDistributedApplicationBuilderThe Hosting.IDistributedApplicationBuilder to add the resource to.
namestringThe name of the resource.
imagestringThe container image name.
imageTagstring?optionalThe container image tag.
IResourceBuilder<JavaAppContainerResource>A reference to the ApplicationModel.IResourceBuilder`1.
AddSpringApp(IDistributedApplicationBuilder, string, JavaAppContainerResourceOptions)Section titled AddSpringApp(IDistributedApplicationBuilder, string, JavaAppContainerResourceOptions)extensionIResourceBuilder<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)
{
// ...
}
}
builderIDistributedApplicationBuilderThe Hosting.IDistributedApplicationBuilder to add the resource to.
namestringThe name of the resource.
optionsJavaAppContainerResourceOptionsThe 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)extensionIResourceBuilder<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)
{
// ...
}
}
builderIDistributedApplicationBuilderThe Hosting.IDistributedApplicationBuilder to add the resource to.
namestringThe name of the resource.
workingDirectorystringThe working directory to use for the command. If null, the working directory of the current process is used.
optionsJavaAppExecutableResourceOptionsThe 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[])extensionIResourceBuilder<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)
{
// ...
}
}
builderIResourceBuilder<JavaAppExecutableResource>The ApplicationModel.IResourceBuilder`1 to add the Gradle build step to.
argsstring[]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[])extensionIResourceBuilder<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)
{
// ...
}
}
builderIResourceBuilder<JavaAppExecutableResource>The ApplicationModel.IResourceBuilder`1 to configure.
taskstringThe Gradle task to execute (e.g., bootRun).
argsstring[]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[])extensionIResourceBuilder<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)
{
// ...
}
}
builderIResourceBuilder<T>The resource builder.
argsstring[]The JVM arguments.
IResourceBuilder<T>A reference to the ApplicationModel.IResourceBuilder`1.
WithMavenBuild(IResourceBuilder<JavaAppExecutableResource>, MavenOptions)Section titled WithMavenBuild(IResourceBuilder<JavaAppExecutableResource>, MavenOptions)extensionIResourceBuilder<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)
{
// ...
}
}
builderIResourceBuilder<JavaAppExecutableResource>The ApplicationModel.IResourceBuilder`1 to add the Maven build step to.
mavenOptionsMavenOptionsThe 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[])extensionIResourceBuilder<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)
{
// ...
}
}
builderIResourceBuilder<JavaAppExecutableResource>The ApplicationModel.IResourceBuilder`1 to add the Maven build step to.
argsstring[]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[])extensionIResourceBuilder<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)
{
// ...
}
}
builderIResourceBuilder<JavaAppExecutableResource>The ApplicationModel.IResourceBuilder`1 to configure.
goalstringThe Maven goal to execute (e.g., spring-boot:run).
argsstring[]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?)extensionIResourceBuilder<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)
{
// ...
}
}
builderIResourceBuilder<T>The resource builder.
agentPathstring?optionalThe 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)extensionIResourceBuilder<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)
{
// ...
}
}
builderIResourceBuilder<JavaAppExecutableResource>The ApplicationModel.IResourceBuilder`1 to configure.
wrapperScriptstringThe path to the wrapper script, relative to the resource working directory or an absolute path.
IResourceBuilder<JavaAppExecutableResource>A reference to the ApplicationModel.IResourceBuilder`1.