Aspirerelease/17.0
Watch Aspire live streamsDocsTry Aspire

JavaAppResource

Handle
📦 Aspire.Hosting.Java v17.0.0-preview.1.26565.2

Represents a Java application resource in the distributed application model.

type JavaAppResource interface {
IComputeResource
IContainerFilesDestinationResource
IJavaAppResource
Resource
ResourceWithArgs
ResourceWithEndpoints
ResourceWithEnvironment
ResourceWithWaitSupport
}

Properties

propertyResourceTypeDisplayNamestringget
Gets the ResourceTypeDisplayName property
ResourceTypeDisplayName() (string, error)

Methods

methodWithGradleBuildbuilder
Runs a Gradle build before the Java application starts.
WithGradleBuild(args []string) JavaAppResource
args[]stringArguments passed to the Gradle wrapper. Defaults to clean build.
JavaAppResource

A reference to the IResourceBuilder.

Returns a handle; failures surface later via Err().

methodWithGradleTaskbuilder
Launches the Java application through a Gradle task instead of java, for example bootRun.
WithGradleTask(
task string,
args []string,
) JavaAppResource
taskstringThe Gradle task to execute.
args[]stringAdditional arguments passed to the Gradle wrapper after the task.
JavaAppResource

A reference to the IResourceBuilder.

Returns a handle; failures surface later via Err().

methodWithJarArtifactbuilder
Selects the JAR the generated container image runs, for projects whose build produces more than one.
WithJarArtifact(jarPath string) JavaAppResource
jarPathstringThe path to the JAR produced by the build, relative to the application directory, for example target/app.jar.
JavaAppResource

A reference to the IResourceBuilder.

Returns a handle; failures surface later via Err().

methodWithMainClassbuilder
Sets the main class an IDE launches when running or debugging this application. Has no effect on how Aspire starts the process, which is decided by the JAR path, Maven goal, or Gradle task.
WithMainClass(mainClass string) JavaAppResource
mainClassstringThe fully qualified name of the class declaring main, for example com.example.Application.
JavaAppResource

A reference to the IResourceBuilder.

Returns a handle; failures surface later via Err().

methodWithMavenBuildbuilder
Runs a Maven build before the Java application starts.
WithMavenBuild(args []string) JavaAppResource
args[]stringArguments passed to the Maven wrapper. Defaults to clean package.
JavaAppResource

A reference to the IResourceBuilder.

Returns a handle; failures surface later via Err().

methodWithMavenGoalbuilder
Launches the Java application through a Maven goal instead of java, for example spring-boot:run.
WithMavenGoal(
goal string,
args []string,
) JavaAppResource
goalstringThe Maven goal to execute.
args[]stringAdditional arguments passed to the Maven wrapper after the goal.
JavaAppResource

A reference to the IResourceBuilder.

Returns a handle; failures surface later via Err().

methodWithOtelAgentbuilder
Runs the application with the OpenTelemetry Java agent so it exports traces, metrics, and logs to Aspire.
WithOtelAgent(agentPath string) JavaAppResource
agentPathstringThe path to the opentelemetry-javaagent.jar file.
JavaAppResource

A reference to the IResourceBuilder.

Returns a handle; failures surface later via Err().

Runs the application with the OpenTelemetry Java agent from the location the build tool writes it to.
WithOtelAgentDefaultPath() JavaAppResource
JavaAppResource

A reference to the IResourceBuilder.

Returns a handle; failures surface later via Err().

methodWithWrapperPathbuilder
Overrides the build tool wrapper script path, for repositories whose wrapper is not in the default location or does not use the default name.
WithWrapperPath(wrapperPath string) JavaAppResource
wrapperPathstringThe path to the wrapper script, absolute or relative to the resource's working directory.
JavaAppResource

A reference to the IResourceBuilder.

Returns a handle; failures surface later via Err().