function PLUGIN:PostInstall(ctx)
local file = require("file")
local root_path = ctx.rootPath
local version = nil
for _, info in pairs(ctx.sdkInfo) do
version = info.version
break
end
if not version then
error("Could not determine version from sdkInfo")
end
local temp_path = root_path .. "-temp"
local target_path = file.join_path(root_path, "cmdline-tools", version)
os.execute("mv " .. root_path .. " " .. temp_path)
os.execute("mkdir -p " .. target_path)
os.execute("mv " .. temp_path .. "/* " .. target_path .. "/")
os.execute("rm -rf " .. temp_path)
local sdkmanager_path = file.join_path(target_path, "bin", "sdkmanager")
if not file.exists(sdkmanager_path) then
error("Installation verification failed: sdkmanager not found at " .. sdkmanager_path)
end
os.execute("chmod +x " .. file.join_path(target_path, "bin", "*") .. " 2>/dev/null || true")
end