Skip to content

fix(antd-java): make examples runnable via gradle :examples subproject#80

Merged
Nic-dorman merged 1 commit into
mainfrom
fix/java-examples-subproject
May 14, 2026
Merged

fix(antd-java): make examples runnable via gradle :examples subproject#80
Nic-dorman merged 1 commit into
mainfrom
fix/java-examples-subproject

Conversation

@Nic-dorman

Copy link
Copy Markdown
Collaborator

Fixes #71.

The README documented examples being run via bash gradlew examples:run -PmainClass=..., but no such task existed — settings.gradle.kts declared only the root project, and the example sources sat as loose .java files in examples/ with no package and no Gradle module to compile them.

Mirror the antd-kotlin layout instead.

Changes

Structural

  • New :examples subproject using the application plugin
  • Sources moved to examples/src/main/java/com/autonomi/examples/ with a package declaration on each
  • examples/build.gradle.kts declares its own mavenCentral() repo and implementation(project(":")) so the example module compiles against the SDK
  • settings.gradle.kts gets include("examples")
  • gradlew was committed without the executable bit — chmod +x'd

Bug fixes uncovered while moving the sources

The files never compiled before, so these were hidden:

  • Example03Files.java assigned client.fileCost(...) to String, but the SDK returns UploadCostEstimate. Print individual fields, mirroring the Python / Rust / PHP examples.
  • Example06PrivateData.java — same shape for client.dataCost(...).

How to run

cd antd-java
./gradlew :examples:run -PmainClass=com.autonomi.examples.Example02PublicData
# or any other Example0NXxx class

Default mainClass is Example02PublicData, so just ./gradlew :examples:run works for the round-trip smoke check.

Test plan

  • ./gradlew :examples:build compiles
  • ./gradlew :examples:run -PmainClass=com.autonomi.examples.Example02PublicData against a local devnet — exits 0, stores + retrieves the payload, round-trip OK
  • Verified via the cross-SDK e2e harness (Java's example now takes ~7.5 s / ~430 MB RSS — JVM-typical)
  • Example03/06 compile errors gone after the UploadCostEstimate type fix

Sample output

Stored at: 01b06330e4f4a8c565087e4087caabf860bdadbe96b7b8f0447493b0081c2335
Cost:       atto
Retrieved: Hello, Autonomi!

(Empty Cost: is the same daemon-side blank-cost behaviour seen in #74 and #77 — not new from this PR.)

What this does NOT touch

Example04Files.java doesn't exist in the original tree (was numbered 03, 05, 06 — no 04). The 5 existing examples are migrated as-is apart from the two type fixes above.

The README told users to run examples via gradle, but that never worked:

  $ bash gradlew examples:run -PmainClass=...
  FAILURE: Build failed with an exception.
  * What went wrong:
  Cannot locate tasks that match examples:build as project examples not
  found in root project antd-java.

settings.gradle.kts only declared the root project; examples lived as
loose .java files in examples/ with no package and no Gradle module to
compile them. Mirror the antd-kotlin layout instead:

- New examples/ subproject with the application plugin (run via gradle
  :examples:run; pick which example with -PmainClass=...)
- Sources moved to examples/src/main/java/com/autonomi/examples/ with a
  package declaration
- examples/build.gradle.kts declares its own mavenCentral repo and
  implementation(project(:)) so it links against the SDK
- settings.gradle.kts gets include(examples)
- gradlew was committed without the executable bit; chmod +x

While moving the sources, two pre-existing type bugs surfaced (the files
never compiled before so these were hidden):

- Example03Files.java: assigned client.fileCost(...) to String, but the
  SDK returns UploadCostEstimate. Print individual fields, mirroring the
  Python/Rust/PHP examples.
- Example06PrivateData.java: same shape for client.dataCost(...).

Closes #71
@Nic-dorman
Nic-dorman merged commit 67b6a83 into main May 14, 2026
@Nic-dorman
Nic-dorman deleted the fix/java-examples-subproject branch May 14, 2026 11:03
Nic-dorman added a commit that referenced this pull request May 14, 2026
Cuts v0.7.1 atop v0.7.0. Primarily refreshes the upstream `ant-core`
pin to the `ant-cli-v0.2.3` release tag (no API change for antd
consumers). Bundles a substantial round of cross-SDK example/build
fixes, dispatcher improvements, and CI/release workflow hardening.

## antd

- chore(antd): bump ant-core to v0.2.3 (#85)

## SDK example/build fixes

- fix(antd-php): use cost-estimate fields in example 02 (#74)
- fix(antd-elixir): print cost-estimate fields in examples (#75)
- fix(antd-lua): add missing discover module to rockspec (#76)
- fix(antd-kotlin): make put-response cost optional + ship gradle wrapper (#77)
- fix(antd-zig): pass payment_mode to dataPutPublic/dataPutPrivate (#79)
- fix(antd-java): make examples runnable via gradle :examples subproject (#80)
- fix(antd-zig): align stdlib API to declared 0.14.x minimum (#82)
- fix(antd-swift): port to Linux + populate cost-estimate fields (#87)

## ant-dev (developer CLI)

- fix(ant-dev): clean up orphan anvil/antnode and stale node identities on stop (#81)
- fix(ant-dev): tooling cluster — flag alias, sys.executable, anvil preflight, README (#83)
- feat(ant-dev): expand `ant dev example` to dispatch all 15 SDKs (#84)
- fix(ant-dev): dispatcher swift no-skip + lua LUA_PATH wrap (#86)
- feat(ant-dev): expose --preset flag on `ant dev start` (default: small) (#88)

## CI / release

- ci: authenticate arduino/setup-protoc on ci.yml too (#60)
- feat(release): publish antd-linux-arm64 artifact (#89)

## Validation

15/15 SDKs round-tripped end-to-end against a daemon built from this
commit on a Linux dev box (Ubuntu 24.04, 0.7.1 atop ant-core v0.2.3).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

antd-java: examples can't be run via gradle — examples/ not registered as a subproject

1 participant