diff --git a/documentation/Functions.md b/documentation/Functions.md index 9ef2396e..01d7fbef 100644 --- a/documentation/Functions.md +++ b/documentation/Functions.md @@ -40,3 +40,12 @@ cobiGenJava("path/to/java/file/MyEntity.java",[1,3,5,6,8]) createDevon4jProject("cobigenexample") *** + +### buildJava +#### parameter +1. The project directory +2. Indicator whether tests should be run +#### example +buildJava("cobigenexample", true) + +*** diff --git a/runners/console/index.ts b/runners/console/index.ts index bb1219db..715c7fb8 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -75,6 +75,20 @@ export class Console extends Runner { return result; } + runBuildJava(step: Step, command: Command): RunResult { + let result = new RunResult(); + result.returnCode = 0; + + let projectDir = path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main", command.parameters[0]) + if(this.platform == ConsolePlatform.WINDOWS) { + this.executeCommandSync("devon mvn clean install -Dmaven.test.skip=" + !command.parameters[1], projectDir, result); + } else { + this.executeCommandSync("~/.devon/devon mvn clean install -Dmaven.test.skip=" + !command.parameters[1], projectDir, result); + } + + return result; + } + runCobiGenJava(step: Step, command: Command): RunResult { return null; } @@ -103,6 +117,17 @@ export class Console extends Runner { .fileExits(path.join(this.getWorkingDirectory(), "devonfw", "software", "cobigen-cli", "cobigen")); } + async assertBuildJava(step: Step, command: Command, result: RunResult) { + let workspaceDir = path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main"); + + new Assertions() + .noErrorCode(result) + .noException(result) + .directoryExits(path.join(workspaceDir, command.parameters[0], "api", "target")) + .directoryExits(path.join(workspaceDir, command.parameters[0], "core", "target")) + .directoryExits(path.join(workspaceDir, command.parameters[0], "server", "target")); + } + async assertCobiGenJava(step: Step, command: Command, result: RunResult) { console.log("there is no assertion yet for the cobiGenJava command"); } @@ -123,7 +148,7 @@ export class Console extends Runner { private executeCommandSync(command: string, directory: string, result: RunResult, input?: string) { if(result.returnCode != 0) return; - let process = child_process.spawnSync(command, { shell: true, cwd: directory, input: input }); + let process = child_process.spawnSync(command, { shell: true, cwd: directory, input: input, maxBuffer: Infinity }); if(process.status != 0) { console.log("Error executing command: " + command + " (exit code: " + process.status + ")"); console.log(process.stderr.toString(), process.stdout.toString());