Skip to content

Commit

Permalink
fix: use relative path in gradle codegen task (#980)
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanZhengYP authored Mar 6, 2020
1 parent 15a66c7 commit ef017ef
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion codegen/sdk-codegen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ tasks.register("generate-smithy-build") {
doLast {
val projectionsBuilder = Node.objectNodeBuilder()
val modelsDirProp: String by project
val models = File(modelsDirProp)
val models = project.file(modelsDirProp);

fileTree(models).filter { it.isFile }.files.forEach { file ->
val (sdkId, version, remaining) = file.name.split(".")
Expand Down
3 changes: 3 additions & 0 deletions scripts/generate-clients/code-gen-dir.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const { join, normalize } = require("path");

const CODE_GEN_ROOT = normalize(join(__dirname, "..", "..", "codegen"));

const CODE_GEN_TASK_ROOT = join(CODE_GEN_ROOT, "sdk-codegen");

const TEMP_CODE_GEN_INPUT_DIR = normalize(join(__dirname, ".aws-models"));

const CODE_GEN_OUTPUT_DIR = normalize(
Expand All @@ -19,6 +21,7 @@ const CODE_GEN_OUTPUT_DIR = normalize(

module.exports = {
CODE_GEN_ROOT,
CODE_GEN_TASK_ROOT,
CODE_GEN_OUTPUT_DIR,
TEMP_CODE_GEN_INPUT_DIR
};
13 changes: 11 additions & 2 deletions scripts/generate-clients/code-gen.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ const path = require("path");
const { copyFileSync, emptyDirSync } = require("fs-extra");
const { readdirSync, lstatSync } = require("fs");
const { spawnProcess } = require("./spawn-process");
const { CODE_GEN_ROOT, TEMP_CODE_GEN_INPUT_DIR } = require("./code-gen-dir");
const {
CODE_GEN_ROOT,
CODE_GEN_TASK_ROOT,
TEMP_CODE_GEN_INPUT_DIR
} = require("./code-gen-dir");
const Glob = require("glob");

async function generateClients(models) {
Expand Down Expand Up @@ -47,7 +51,12 @@ async function generateClients(models) {
}
const options = [":sdk-codegen:clean", ":sdk-codegen:build"];
if (designatedModels) {
options.push(`-PmodelsDirProp=${TEMP_CODE_GEN_INPUT_DIR}`);
options.push(
`-PmodelsDirProp=${path.relative(
CODE_GEN_TASK_ROOT,
TEMP_CODE_GEN_INPUT_DIR
)}`
);
}
await spawnProcess("./gradlew", options, {
cwd: CODE_GEN_ROOT
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate-clients/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const CLIENTS_DIR = path.normalize(path.join(__dirname, "..", "..", "clients"));
const { models, globs, output: clientsDir } = yargs
.alias("m", "models")
.string("m")
.describe("m", "The directory of models.")
.describe("m", "The path to directory with models.")
.alias("g", "globs")
.array("g")
.describe("g", "A list of smithy model globs")
Expand Down

0 comments on commit ef017ef

Please sign in to comment.