Skip to content

Make module discovery cwd-aware and resolve dagger-module.toml#8

Open
TomChv wants to merge 5 commits into
mainfrom
feat/make-module-discovery-cwd-aware
Open

Make module discovery cwd-aware and resolve dagger-module.toml#8
TomChv wants to merge 5 commits into
mainfrom
feat/make-module-discovery-cwd-aware

Conversation

@TomChv

@TomChv TomChv commented Jul 22, 2026

Copy link
Copy Markdown
Member

What

Ports the cwd-aware module discovery change to the Java SDK, matching the sibling SDK PRs:

Tracking issue: dagger/dagger#13688.

Changes

  • Mod.pathMod.rootPath — the workspace-root-relative path is the module's stable identity. A new computed Mod.path is a cwd-relative view (".", "sub/mod", "..") so listings read the way a shell user sees them.
  • JavaSdk.modules(ws) — new cwd-aware discovery. It goes through the polyfill's findConfigDirs (anchored at the client's cwd, not the workspace root) and intersects the result with the engine-owned currentModule.asSDK.modules list. generateAll now goes through it, so running from a subdirectory acts on the project you're in and the projects beneath it.
  • dagger-module.toml resolution — module roots are discovered by either the CLI 1.0 dagger-module.toml or the legacy dagger.json (moduleConfigFilenames).
  • Polyfill bump — points the polyfill dependency in dagger-module.toml (the effective module config, which still pointed at the old sdk-sdk/polyfill) at github.com/dagger/polyfill@main, which provides findConfigDirs.
  • Workspace wiring — rewrites the stale workspace dagger.toml (it still referenced a Go-based runtime that has since moved to Dang) to register the e2e module and the java SDK with its fixtures.

Tests

Adds modulesCheck and modulesCwdCheck to the e2e module, covering discovery of both config formats, cwd walk-down/find-up scoping, and exclusion of modules this SDK doesn't manage.

Verified against a v1.0.0-beta.7 engine:

✔ e-2-e:modules-check OK
✔ e-2-e:modules-cwd-check OK
✔ e-2-e:init-check OK
✔ e-2-e:skip-generate-filename-check OK
✔ e-2-e:target-runtime-check OK
✔ dang-sdk:generate-all OK

Signed-off-by: Tom Chauveau tom@dagger.io

@TomChv

This comment was marked as outdated.

@TomChv
TomChv requested a review from tiborvass July 22, 2026 12:18
Mirror the cwd-aware discovery change already landed in the Go, Python and
TypeScript SDKs (dagger/dagger#13688): modules are discovered relative to
the client's current directory rather than the whole workspace, and both
the CLI 1.0 dagger-module.toml and the legacy dagger.json mark a module
root.

- Mod.path becomes rootPath (workspace-root-relative, the module's stable
  identity); a new cwd-relative Mod.path renders listings the way a shell
  user sees them.
- JavaSdk.modules(ws) discovers managed modules through the polyfill's
  cwd-aware findConfigDirs, intersected with the engine-owned asSDK list,
  and generateAll now goes through it — so running from a subdirectory
  acts on the project you're in and the projects beneath it.
- Point the polyfill dependency in dagger-module.toml (the effective
  module config) at github.com/dagger/polyfill@main, which provides
  findConfigDirs.
- Wire the workspace dagger.toml for e2e (register java-sdk as the "java"
  SDK with fixtures) and add modulesCheck / modulesCwdCheck covering both
  config formats and cwd scoping.

Signed-off-by: Tom Chauveau <tom@dagger.io>
Signed-off-by: Vasek - Tom C <tom.chauveau@epitech.eu>
@TomChv
TomChv force-pushed the feat/make-module-discovery-cwd-aware branch from fb14696 to e279505 Compare July 22, 2026 13:13
TomChv added 4 commits July 22, 2026 15:48
`dagger generate` runs java-sdk:generate-all, which Maven-builds every
managed module. The e2e fixtures are config-only discovery stubs, so mark
them with the skip-generate marker: modules() still lists them, generate
never tries to build them (building a stub with no pom fails, which broke
`dagger generate`).

Also make packager:generate byte-reproducible by stripping Maven's
install-time timestamps from the committed prebuilt repo — the comment
lines in _remote.repositories (keeping the ">=" local-install markers) and
<lastUpdated> in maven-metadata-local.xml. They re-timestamped on every run
and made the generate-check report perpetual drift.

Signed-off-by: Tom Chauveau <tom@dagger.io>
CI provisions its engine from the legacy dagger.json (the CI CLI is 0.21.7
and predates dagger-module.toml), and "latest" resolved to the 0.21.7
stable engine — which lacks the cwd-aware APIs (Directory.asWorkspace(cwd:),
Workspace.cwd, findConfigDirs). That made modules-check and modules-cwd-check
error while the other checks passed. Pin the same v1.0.0-0 floor the root
dagger-module.toml and the sibling SDK repos already declare, so CI runs a
1.0 engine.

Signed-off-by: Tom Chauveau <tom@dagger.io>
CI eagerly loads workspace modules (session --load-workspace-modules). The
dang SDK was managing .dagger/modules/e2e, packager and runtime in addition
to ".", double-registering e2e (which is also [modules.e2e]). That left the
workspace in a state where currentModule.asSDK inside JavaSdk.modules()
failed with "get current workspace: no current workspace: workspace not
loaded", erroring modules-check and modules-cwd-check while every other
check passed.

go-sdk uses byte-identical modules() code, manages only "." under its dang
SDK, and passes the same checks in the same CI — match that.

Signed-off-by: Tom Chauveau <tom@dagger.io>
On the CI engine, currentModule.asSDK inside JavaSdk.modules() fails with
"get current workspace: no current workspace: workspace not loaded",
erroring modules-check and modules-cwd-check (every other check passes).
Read the managed-module list from the passed workspace instead —
ws.sdk(name: currentModule.name).modules — which never touches the ambient
current workspace. This mirrors the Python SDK, whose discovery check passes
in this same CI.

modules-cwd-check now snapshots the whole workspace (ws.directory("/")) so
the re-anchored workspace keeps its dagger.toml for ws.sdk to read.

Signed-off-by: Tom Chauveau <tom@dagger.io>
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.

2 participants