File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -161,4 +161,30 @@ type E2e {
161161
162162 null
163163 }
164+
165+ """
166+ Generation from a subdirectory must resolve managed module root paths from
167+ the workspace root, not relative to the caller's cwd.
168+ """
169+ pub generateCwdCheck(ws: Workspace!): Void @check {
170+ # Prepare a valid module in memory and remove the fixture-wide skip marker
171+ # so this check can exercise generation without changing committed fixtures.
172+ let initialized = javaSdk.initModule(ws, name: "generate-app", path: generateModulePath)
173+ let root = ws
174+ .directory("/", exclude: [fixtureRoot + "/.dagger-java-sdk-skip-generate"])
175+ .withDirectory(".", initialized.layer)
176+ let fromParent = javaSdk.generateAll(
177+ root.asWorkspace(cwd: fixtureRoot + "/generate"),
178+ )
179+ assertAdded(fromParent, generateModulePath + "/sdk/src/main/java/io/dagger/client/Dagger.java")
180+ assertAdded(fromParent, generateModulePath + "/src/generated/java/io/dagger/gen/entrypoint/Entrypoint.java")
181+
182+ let fromModule = javaSdk.generateAll(
183+ root.asWorkspace(cwd: generateModulePath),
184+ )
185+ assertAdded(fromModule, generateModulePath + "/sdk/src/main/java/io/dagger/client/Dagger.java")
186+ assertAdded(fromModule, generateModulePath + "/src/generated/java/io/dagger/gen/entrypoint/Entrypoint.java")
187+
188+ null
189+ }
164190}
Original file line number Diff line number Diff line change @@ -201,7 +201,8 @@ type Mod {
201201 # Native module-source resolution (Directory.asModuleSource, Query.moduleSource)
202202 # fails from module code: SDK and user-defaults loading need the requester's host
203203 # session. The polyfill resolves the source from a nested client that has one.
204- let modSource = polyfill.workspace(ws).moduleSource(modPathArg)
204+ # Anchor rootPath at "/" so a non-root workspace cwd is not prefixed again.
205+ let modSource = polyfill.workspace(ws).moduleSource("/" + modPathArg)
205206 let name = modSource.core.moduleName
206207 let introspectionJSON = modSource.core.introspectionSchemaJSON
207208 let vendored = vendoredSdk(introspectionJSON, name)
You can’t perform that action at this time.
0 commit comments