Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions dagger-module.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name = "java-sdk"
engineVersion = "v1.0.0-0"
engineVersion = "v1.0.0-beta.10"

[runtime]
source = "dang"

[[dependencies]]
name = "polyfill"
source = "github.com/dagger/polyfill@main"
pin = "e90bbfc4843258a877a3a95b8db1571e7981e65f"
11 changes: 2 additions & 9 deletions dagger.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
{
"name": "java-sdk",
"engineVersion": "latest",
"engineVersion": "v1.0.0-beta.10",
"sdk": {
"source": "dang"
},
"dependencies": [
{
"name": "polyfill",
"source": "github.com/dagger/polyfill@main",
"pin": "e90bbfc4843258a877a3a95b8db1571e7981e65f"
}
]
}
}
1 change: 0 additions & 1 deletion dagger.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[["version","1"]]
["","git.head",["https://github.com/dagger/dang-sdk"],"c724eec4270870aae489daa9f3cb8cbacfb44680","float"]
["","git.head",["https://github.com/dagger/sdk-sdk"],"8c164424b7a8a37b33a77367ef7547490d5b87b5","float"]
["","git.ref",["https://github.com/dagger/polyfill","main"],"ec3ea84a2351b4beb06ecece951f2e5ef66509ff","float"]
12 changes: 3 additions & 9 deletions main.dang
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,8 @@ type JavaSdk {
rawPath.trimSuffix("/")
}

let before = if (modPath == ".") {
ws.directory("/", include: ["**"])
} else {
ws.directory("/", include: [modPath + "/**"])
}

let selectedTemplate = if (template == "") { "default" } else { template }
before.withDirectory(modPath, renderedTemplate(name, selectedTemplate)).changes(before)
ws.fork.withNewDirectory("/" + modPath, renderedTemplate(name, selectedTemplate)).changes
}

"""
Expand Down Expand Up @@ -96,14 +90,14 @@ type JavaSdk {
(currentModule.asSDK.modules). So running from a subdirectory acts on the
project you're in — and the projects beneath it — not the whole workspace.

Discovery is the polyfill's cwd-aware findConfigDirs (dagger/dagger#13688);
Discovery is the engine's cwd-aware Workspace.findConfigDirs;
this maps its cwd-relative results to workspace-root-relative paths and keeps
the ones this SDK manages, whether they use dagger-module.toml or dagger.json.
"""
pub modules(ws: Workspace!): [Mod!]! {
let managed = ws.sdk(name: currentModule.name).modules.{{source}}
let cwd = normalizePath(ws.cwd)
polyfill.workspace(ws)
ws
.findConfigDirs(moduleConfigFilenames, exclude: ["**/target/**"])
.map { dir => moduleRelPath(cwd, dir) }
.uniq
Expand Down
28 changes: 11 additions & 17 deletions mod.dang
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,10 @@ type Mod {
Stage the vendored SDK + generated entrypoint for one module.
"""
let generateModule(ws: Workspace!, modPathArg: String!): Changeset! {
# Native module-source resolution (Directory.asModuleSource, Query.moduleSource)
# fails from module code: SDK and user-defaults loading need the requester's host
# session. The polyfill resolves the source from a nested client that has one.
# Anchor rootPath at "/" so a non-root workspace cwd is not prefixed again.
let modSource = polyfill.workspace(ws).moduleSource("/" + modPathArg)
let name = modSource.core.moduleName
let introspectionJSON = modSource.core.introspectionSchemaJSON
let modSource = ws.moduleSource("/" + modPathArg)
let name = modSource.moduleName
let introspectionJSON = modSource.introspectionSchemaJSON
let vendored = vendoredSdk(introspectionJSON, name)

# the module as committed, with the whole committed sdk/ dropped (source and
Expand All @@ -216,21 +213,18 @@ type Mod {
.withoutDirectory("src/generated")
let entrypoint = generatedEntrypoint(baseDir, name)

let before = if (modPathArg == ".") {
ws.directory("/", include: ["**"])
} else {
ws.directory("/", include: [modPathArg + "/**"])
}
let staged = before
.withDirectory(joinPath(modPathArg, "sdk"), vendored)
.withDirectory(joinPath(modPathArg, "src/generated/java"), entrypoint)
# Stage through a workspace fork: the changeset comes back measured from
# the caller's cwd, the way the client applies it.
let staged = ws.fork
.withNewDirectory("/" + joinPath(modPathArg, "sdk"), vendored)
.withNewDirectory("/" + joinPath(modPathArg, "src/generated/java"), entrypoint)

if (vendorSdkJar) {
staged
.withDirectory(joinPath(modPathArg, "sdk/repo"), vendoredSdkJar(introspectionJSON, name))
.changes(before)
.withNewDirectory("/" + joinPath(modPathArg, "sdk/repo"), vendoredSdkJar(introspectionJSON, name))
.changes
} else {
staged.changes(before)
staged.changes
}
}

Expand Down