# JavaAppResource.WithGradleBuild

- Module: [Aspire.Hosting.Java](/reference/api/go/aspire.hosting.java.md)
- Defined on: [JavaAppResource](/reference/api/go/aspire.hosting.java/javaappresource.md)
- Version: `17.0.0-preview.1.26565.2`
- Kind: `method`

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
type JavaAppResource interface {
    // ... omitted for brevity
    WithGradleBuild(args []string) JavaAppResource
}
```

## Signature

```go
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()`.

## Defined on

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