fix(antd-java): make examples runnable via gradle :examples subproject#80
Merged
Conversation
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
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #71.
The README documented examples being run via
bash gradlew examples:run -PmainClass=..., but no such task existed —settings.gradle.ktsdeclared only the root project, and the example sources sat as loose.javafiles inexamples/with no package and no Gradle module to compile them.Mirror the
antd-kotlinlayout instead.Changes
Structural
:examplessubproject using theapplicationpluginexamples/src/main/java/com/autonomi/examples/with a package declaration on eachexamples/build.gradle.ktsdeclares its ownmavenCentral()repo andimplementation(project(":"))so the example module compiles against the SDKsettings.gradle.ktsgetsinclude("examples")gradlewwas committed without the executable bit —chmod +x'dBug fixes uncovered while moving the sources
The files never compiled before, so these were hidden:
Example03Files.javaassignedclient.fileCost(...)toString, but the SDK returnsUploadCostEstimate. Print individual fields, mirroring the Python / Rust / PHP examples.Example06PrivateData.java— same shape forclient.dataCost(...).How to run
Default
mainClassisExample02PublicData, so just./gradlew :examples:runworks for the round-trip smoke check.Test plan
./gradlew :examples:buildcompiles./gradlew :examples:run -PmainClass=com.autonomi.examples.Example02PublicDataagainst a local devnet — exits 0, stores + retrieves the payload, round-trip OKUploadCostEstimatetype fixSample output
(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.javadoesn'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.