# WithGradleBuild

- Module: [Aspire.Hosting.Java](/reference/api/go/aspire.hosting.java.md)
- Version: `17.0.0-preview.1.26565.2`
- Kind: `method`
- Defined on: [`JavaAppResource`](/reference/api/go/aspire.hosting.java/javaappresource.md)
- Source: [GitHub](https://github.com/microsoft/aspire/tree/bcfa151cdca6d0a573f22d5d9c23f9c727cb3b2f)

Runs a Gradle build before the Java application starts.

## Remarks

When the application launches with `WithGradleTask`,
that task performs the local compilation, so these arguments normally configure publishing without adding a
second run-mode build. Otherwise, the build step is a child resource that the application waits for.
No child is created when publishing because the generated container image performs the build.
This runs a build before the application starts. To launch the application through Gradle,
use `WithGradleTask` instead.

## Definition

```go
func (JavaAppResource) WithGradleBuild(args []string) JavaAppResource
```

## Parameters

- `args` (`[]string`) -- Arguments passed to the Gradle wrapper. Defaults to `clean build`.

## Returns

[`JavaAppResource`](/reference/api/go/aspire.hosting.java/javaappresource.md) -- A reference to the `IResourceBuilder`.

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

## Applies to

- [`JavaAppResource`](/reference/api/go/aspire.hosting.java/javaappresource.md)
