Skip to content

Commit 8c80418

Browse files
authored
Merge pull request #40 from GuentherJulian/feature/consoleBuildJava
Feature/consoleBuildJava
2 parents a31e110 + 743fa9a commit 8c80418

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

documentation/Functions.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,12 @@ cobiGenJava("path/to/java/file/MyEntity.java",[1,3,5,6,8])
4040
createDevon4jProject("cobigenexample")
4141

4242
***
43+
44+
### buildJava
45+
#### parameter
46+
1. The project directory
47+
2. Indicator whether tests should be run
48+
#### example
49+
buildJava("cobigenexample", true)
50+
51+
***

runners/console/index.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,20 @@ export class Console extends Runner {
7575
return result;
7676
}
7777

78+
runBuildJava(step: Step, command: Command): RunResult {
79+
let result = new RunResult();
80+
result.returnCode = 0;
81+
82+
let projectDir = path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main", command.parameters[0])
83+
if(this.platform == ConsolePlatform.WINDOWS) {
84+
this.executeCommandSync("devon mvn clean install -Dmaven.test.skip=" + !command.parameters[1], projectDir, result);
85+
} else {
86+
this.executeCommandSync("~/.devon/devon mvn clean install -Dmaven.test.skip=" + !command.parameters[1], projectDir, result);
87+
}
88+
89+
return result;
90+
}
91+
7892
runCobiGenJava(step: Step, command: Command): RunResult {
7993
return null;
8094
}
@@ -103,6 +117,17 @@ export class Console extends Runner {
103117
.fileExits(path.join(this.getWorkingDirectory(), "devonfw", "software", "cobigen-cli", "cobigen"));
104118
}
105119

120+
async assertBuildJava(step: Step, command: Command, result: RunResult) {
121+
let workspaceDir = path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main");
122+
123+
new Assertions()
124+
.noErrorCode(result)
125+
.noException(result)
126+
.directoryExits(path.join(workspaceDir, command.parameters[0], "api", "target"))
127+
.directoryExits(path.join(workspaceDir, command.parameters[0], "core", "target"))
128+
.directoryExits(path.join(workspaceDir, command.parameters[0], "server", "target"));
129+
}
130+
106131
async assertCobiGenJava(step: Step, command: Command, result: RunResult) {
107132
console.log("there is no assertion yet for the cobiGenJava command");
108133
}
@@ -123,7 +148,7 @@ export class Console extends Runner {
123148
private executeCommandSync(command: string, directory: string, result: RunResult, input?: string) {
124149
if(result.returnCode != 0) return;
125150

126-
let process = child_process.spawnSync(command, { shell: true, cwd: directory, input: input });
151+
let process = child_process.spawnSync(command, { shell: true, cwd: directory, input: input, maxBuffer: Infinity });
127152
if(process.status != 0) {
128153
console.log("Error executing command: " + command + " (exit code: " + process.status + ")");
129154
console.log(process.stderr.toString(), process.stdout.toString());

0 commit comments

Comments
 (0)