Skip to content

Commit 1551bde

Browse files
authored
Merge branch 'main' into feature/createproject
2 parents ae466ec + 6144899 commit 1551bde

File tree

5 files changed

+83
-5
lines changed

5 files changed

+83
-5
lines changed

build - Shortcut.lnk

1.26 KB
Binary file not shown.

documentation/Functions.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ The following functions are already implemented:
77

88
***
99

10-
### installDevonIde
10+
### installDevonfwIde
1111
#### parameter
1212
1. The tools you want to install within the devonfw ide: string array
13+
2. Optional: The version of the ide to install
1314
#### example
14-
installDevonfwIde(["java","mvn"])
15+
installDevonfwIde(["java","mvn"], "2020.08.001")
1516

1617
***
1718

@@ -40,3 +41,12 @@ cobiGenJava("path/to/java/file/MyEntity.java",[1,3,5,6,8])
4041
createDevon4jProject("cobigenexample")
4142

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

runners/console/index.ts

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,16 @@ export class Console extends Runner {
3636
let installDir = path.join(this.getWorkingDirectory(), "devonfw");
3737
this.createFolder(installDir, true);
3838

39+
let downloadUrl = "https://bit.ly/2BCkFa9";
40+
if(command.parameters.length > 1 && command.parameters[1] != "") {
41+
downloadUrl = "https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=com.devonfw.tools.ide&a=devonfw-ide-scripts&p=tar.gz&v=" + command.parameters[1];
42+
}
3943
if(this.platform == ConsolePlatform.WINDOWS) {
40-
this.executeCommandSync("powershell.exe Invoke-WebRequest -OutFile devonfw.tar.gz https://bit.ly/2BCkFa9", installDir, result);
44+
this.executeCommandSync("powershell.exe \"Invoke-WebRequest -OutFile devonfw.tar.gz '" + downloadUrl + "'\"", installDir, result);
4145
this.executeCommandSync("powershell.exe tar -xvzf devonfw.tar.gz", installDir, result);
4246
this.executeCommandSync("powershell.exe ./setup " + path.join(settingsDir, "settings.git").replace(/\\/g, "/"), installDir, result, "yes");
4347
} else {
44-
this.executeCommandSync("wget -c https://bit.ly/2BCkFa9 -O - | tar -xz", installDir, result);
48+
this.executeCommandSync("wget -c \"" + downloadUrl + "\" -O - | tar -xz", installDir, result);
4549
this.executeCommandSync("bash setup " + path.join(settingsDir, "settings.git").replace(/\\/g, "/"), installDir, result, "yes");
4650
}
4751

@@ -75,6 +79,20 @@ export class Console extends Runner {
7579
return result;
7680
}
7781

82+
runBuildJava(step: Step, command: Command): RunResult {
83+
let result = new RunResult();
84+
result.returnCode = 0;
85+
86+
let projectDir = path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main", command.parameters[0])
87+
if(this.platform == ConsolePlatform.WINDOWS) {
88+
this.executeCommandSync("devon mvn clean install -Dmaven.test.skip=" + !command.parameters[1], projectDir, result);
89+
} else {
90+
this.executeCommandSync("~/.devon/devon mvn clean install -Dmaven.test.skip=" + !command.parameters[1], projectDir, result);
91+
}
92+
93+
return result;
94+
}
95+
7896
runCobiGenJava(step: Step, command: Command): RunResult {
7997
return null;
8098
}
@@ -103,6 +121,17 @@ export class Console extends Runner {
103121
.fileExits(path.join(this.getWorkingDirectory(), "devonfw", "software", "cobigen-cli", "cobigen"));
104122
}
105123

124+
async assertBuildJava(step: Step, command: Command, result: RunResult) {
125+
let workspaceDir = path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main");
126+
127+
new Assertions()
128+
.noErrorCode(result)
129+
.noException(result)
130+
.directoryExits(path.join(workspaceDir, command.parameters[0], "api", "target"))
131+
.directoryExits(path.join(workspaceDir, command.parameters[0], "core", "target"))
132+
.directoryExits(path.join(workspaceDir, command.parameters[0], "server", "target"));
133+
}
134+
106135
async assertCobiGenJava(step: Step, command: Command, result: RunResult) {
107136
console.log("there is no assertion yet for the cobiGenJava command");
108137
}
@@ -121,10 +150,11 @@ export class Console extends Runner {
121150
}
122151

123152

153+
124154
private executeCommandSync(command: string, directory: string, result: RunResult, input?: string) {
125155
if(result.returnCode != 0) return;
126156

127-
let process = child_process.spawnSync(command, { shell: true, cwd: directory, input: input });
157+
let process = child_process.spawnSync(command, { shell: true, cwd: directory, input: input, maxBuffer: Infinity });
128158
if(process.status != 0) {
129159
console.log("Error executing command: " + command + " (exit code: " + process.status + ")");
130160
console.log(process.stderr.toString(), process.stdout.toString());

runners/katacoda/index.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,31 @@ export class Katacoda extends Runner {
138138
return null;
139139
}
140140

141+
runCreateDevon4jProject(step: Step, command: Command): RunResult{
142+
return null;
143+
}
144+
145+
runBuildJava(step: Step, command: Command): RunResult{
146+
147+
//cdCommand needs to be added
148+
let cdCommand = "";
149+
150+
let skipTestDescr = "";
151+
let skipTest = "";
152+
153+
if(command.parameters[1] == true){
154+
skipTest = '-Dmaven.test.skip=' + command.parameters[1];
155+
skipTestDescr = "We do not need to execute the test cases, so we can skip them by using the option '-Dmaven.test.skip=true'."
156+
}
157+
this.steps.push({
158+
"title": "Build the java project",
159+
"text": "step" + this.stepsCount + ".md"
160+
});
161+
this.renderTemplate("buildJava.md", this.outputPathTutorial + "step" + (this.stepsCount++) + ".md", { text: step.text, textAfter: step.textAfter, cdCommand: cdCommand, skipTest: skipTest, skipTestDescr: skipTestDescr});
162+
return null;
163+
164+
}
165+
141166
private renderTemplate(name: string, targetPath: string, variables) {
142167
let template = fs.readFileSync(path.join(this.getRunnerDirectory(),"templates", name), 'utf8');
143168
let result = ejs.render(template, variables);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<%= text; %>
2+
3+
<%= cdCommand; %>
4+
5+
Use the following devon command to build the java project.
6+
7+
`devon mvn clean install <%= skipTest; %>`{{execute}}
8+
9+
The maven command 'clean' will clear the target directory beforehand.
10+
11+
<%= skipTestDescr; %>
12+
13+
<%= textAfter; %>

0 commit comments

Comments
 (0)