Skip to content

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

Open
Nic-dorman wants to merge 1 commit into
mainfrom
fix/java-examples-subproject
Open

fix(antd-java): make examples runnable via gradle :examples subproject#80
Nic-dorman wants to merge 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
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