# `gradle_workspace`

Discover the main Java compilation of a supported single-project Gradle Java-library build. Gradle evaluates declarations offline; Struo selects and fetches the compile classpath through graph actions and invokes `javac` directly.

## Usage

With Gradle 8.14.3, Java 17 and `javac` available, native `build.gradle` or `build.gradle.kts` discovery exposes `compileJava`. Run `struo build compileJava` from the project directory. Native wrappers and user-home init scripts are not invoked.

An explicit seed can supply toolchain homes or an authorized metadata refresh:

```toml
[[target]]
name = "gradle"
kind = "gradle_workspace"
[target.attrs]
resolver_inputs = ["*.gradle", "*.gradle.kts", "gradle.properties", "gradle.lockfile", "gradle/*.toml", "gradle/verification-metadata.xml", "src/**/*.java"]
metadata_refresh = "reviewed-update-2"
```

`java_home` and `gradle_home` default to `JAVA_HOME`, `GRADLE_HOME` or their resolved executables. The default metadata generation derives from lock and verification bytes; it does not implement Gradle's time-based refresh. Active native locking uses standard `gradle.lockfile` pins, with STRICT requiring state for `compileClasspath`. DEFAULT without that configuration's state selects without pins. Inactive locking ignores leftover lock state. Optional `lock_mode = "locked"` or `"update"` overrides that choice without writing source files.

External requirements require native verification metadata. Empty configurations can compile without it. Compilation waits only for its settled compile classpath, not runtime-only dependencies. The output is a deterministic classes-only archive.

## Limits

This is not the Gradle `build` lifecycle: resources, configured JAR packaging, test execution and runtime products are not exposed. Multiproject builds, external plugins, annotation processors, module-info sources, generated sources, custom task actions, compiler argument providers, custom source paths and alternate compilers are unsupported. Java sources must be captured UTF-8 files; non-UTF-8 sources fail instead of disappearing from the compilation. Existing native declaration restrictions also apply.

Selected AARs are rejected for native Java compilation, which does not extract their nested classes. Explicit Android graphs retain their separate AAR transformation support.

Executable evaluation is uncached because complete executable-input authority is unavailable. Read-only native affected queries fail closed instead of claiming precise results. Native-derived source publication remains refused. Use explicit [`gradle_dependencies`](/reference/prelude/gradle_dependencies) declarations for guarded lock proposals.
