Skip to content

Commit 01ff76f

Browse files
author
MansourD
committed
Merge branch 'master' into 860_SQL_files_generation
# Conflicts: # cobigen-eclipse/cobigen-eclipse-test/.classpath
2 parents 32b5707 + 5b1a887 commit 01ff76f

File tree

34 files changed

+565
-485
lines changed

34 files changed

+565
-485
lines changed

.github/workflows/maven-build-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
runs-on: ubuntu-latest
3030
steps:
3131
- name: Clone Repository
32-
uses: actions/checkout@v2
32+
uses: actions/checkout@v3
3333

3434
- uses: devonfw-actions/java-maven-setup@main
3535
with:

.github/workflows/spellcheck.yml renamed to .github/workflows/spellchecker.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: spellcheck
22
on:
33
push:
4+
paths:
5+
- '**.asciidoc'
6+
- '**.adoc'
47
workflow_dispatch:
58
jobs:
69
spellchecker:

README.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
= CobiGen (Code-based incremental Generator)
44

5-
image:https://maven-badges.herokuapp.com/maven-central/com.devonfw.cobigen/cobigen-maven-plugin/badge.svg[https://maven-badges.herokuapp.com/maven-central/com.devonfw.cobigen/cobigen-maven-plugin] image:https://github.com/devonfw/cobigen/actions/workflows/maven-build-test.yml/badge.svg?branch=master&event=push["Build Status", link="https://github.com/devonfw/cobigen/actions/workflows/maven-build-test.yml"]
5+
image:https://maven-badges.herokuapp.com/maven-central/com.devonfw.cobigen/cobigen-maven-plugin/badge.svg[https://maven-badges.herokuapp.com/maven-central/com.devonfw.cobigen/cobigen-maven-plugin] image:https://github.com/devonfw/cobigen/actions/workflows/maven-build-test.yml/badge.svg?branch=master&event=push["Build Status", link="https://github.com/devonfw/cobigen/actions/workflows/maven-build-test.yml?query=branch%3Amaster"]
66

77
== Usage
88

cobigen-cli/cli-systemtest/src/test/java/com/devonfw/cobigen/cli/systemtest/GenerateCommandIT.java

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import java.io.File;
66
import java.io.IOException;
7+
import java.nio.charset.Charset;
78
import java.nio.file.Path;
89

910
import org.apache.commons.io.FileUtils;
@@ -296,4 +297,68 @@ public void generateFromArgsWithQuote() throws Exception {
296297
assertThat(outputRootPath.resolve("docs")).exists();
297298
}
298299

300+
/**
301+
* Integration test of the generation and validation of the class path cache. The test will execute a generation twice
302+
* this requires some cleanup.A deleted dependencies will be detected by the validating process in MavenUtil and will
303+
* reload the needed dependency and not prevent the second generation
304+
*
305+
* @throws Exception test fails
306+
*/
307+
@Test
308+
public void generateFromEntityTwiceToTestCache() throws Exception {
309+
310+
// prepare
311+
File outputRootFile = this.tempFolder.newFolder("playground2", "rootoutput");
312+
File openApiFile = new File(testFileRootPath + "openAPI.yml");
313+
314+
String args[] = new String[6];
315+
args[0] = "generate";
316+
args[1] = openApiFile.getAbsolutePath();
317+
args[2] = "--out";
318+
args[3] = outputRootFile.getAbsolutePath();
319+
args[4] = "--increments";
320+
args[5] = "ionic_component,OpenAPI_Docs,services";
321+
322+
execute(args, true);
323+
324+
Path rootPath = outputRootFile.toPath();
325+
assertThat(rootPath.resolve("../../devon4ng-ionic-application-template"));
326+
327+
// cleanup for a second execution of generate to test the correct cache usage
328+
File cli_config = this.tempFolder.getRoot().toPath().resolve("cobigen-test-home").toFile();
329+
File bin = cli_config.toPath().resolve("cobigen-test-home/bin").toFile();
330+
if (bin.exists()) {
331+
FileUtils.deleteDirectory(bin);
332+
}
333+
File lib = cli_config.toPath().resolve("cobigen-test-home/lib").toFile();
334+
if (lib.exists()) {
335+
FileUtils.deleteDirectory(lib);
336+
}
337+
File license = cli_config.toPath().resolve("cobigen-test-home/LICENSE.txt").toFile();
338+
if (license.exists()) {
339+
FileUtils.delete(license);
340+
}
341+
File cli = cli_config.toPath().resolve("cli-config").toFile();
342+
// get the saved dependencies in the cache file and delete one
343+
for (File f : cli.listFiles()) {
344+
if (f.getName().startsWith("pom-cp-")) {
345+
String dependenciesFromCache = FileUtils.readFileToString(f, Charset.defaultCharset());
346+
String osName = System.getProperty("os.name");
347+
String[] dependenciesFromCacheArray;
348+
if (osName.contains("Windows")) {
349+
dependenciesFromCacheArray = dependenciesFromCache.split(";");
350+
} else {
351+
dependenciesFromCacheArray = dependenciesFromCache.split(":");
352+
}
353+
for (int i = 0; i >= 0; i--) { // reverse
354+
if (dependenciesFromCacheArray[i].contains("javax.persistence")) {
355+
FileUtils.delete(new File(dependenciesFromCacheArray[i])); // delete a randomly picked dependency
356+
}
357+
}
358+
}
359+
}
360+
FileUtils.delete(cli_config.toPath().resolve("cli.tar.gz").toFile());
361+
execute(args, true);
362+
}
363+
299364
}

cobigen-cli/cli/src/main/java/com/devonfw/cobigen/cli/utils/CobiGenUtils.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,13 @@ public class CobiGenUtils {
5353
public static CobiGen initializeCobiGen(Path templatesProject) {
5454

5555
registerPlugins();
56+
CobiGen cg;
5657
if (templatesProject != null) {
57-
return CobiGenFactory.create(templatesProject.toUri());
58+
cg = CobiGenFactory.create(templatesProject.toUri());
5859
} else {
59-
return CobiGenFactory.create();
60+
cg = CobiGenFactory.create();
6061
}
62+
return cg;
6163
}
6264

6365
/**
@@ -79,7 +81,7 @@ public static ClassLoader registerPlugins() {
7981
Path rootCLIPath = getCliHomePath();
8082
File pomFile = extractArtificialPom();
8183

82-
String pomFileHash = MavenUtil.generatePomFileHash(pomFile.toPath());
84+
String pomFileHash = MavenUtil.generatePomFileHash(pomFile.toPath(), MavenUtil.determineMavenRepositoryPath());
8385

8486
Path cpFile = rootCLIPath.resolve(String.format(MavenConstants.CLASSPATH_CACHE_FILE, pomFileHash));
8587

cobigen-eclipse/cobigen-eclipse-feature/.project

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,15 @@
2727
<nature>org.eclipse.jdt.core.javanature</nature>
2828
<nature>org.eclipse.pde.FeatureNature</nature>
2929
</natures>
30+
<filteredResources>
31+
<filter>
32+
<id>1664574669497</id>
33+
<name></name>
34+
<type>30</type>
35+
<matcher>
36+
<id>org.eclipse.core.resources.regexFilterMatcher</id>
37+
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
38+
</matcher>
39+
</filter>
40+
</filteredResources>
3041
</projectDescription>

cobigen-eclipse/cobigen-eclipse-test/.classpath

Lines changed: 0 additions & 34 deletions
This file was deleted.

cobigen-eclipse/cobigen-eclipse-test/.project

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,15 @@
3131
<nature>org.eclipse.pde.PluginNature</nature>
3232
<nature>org.eclipse.jdt.core.javanature</nature>
3333
</natures>
34+
<filteredResources>
35+
<filter>
36+
<id>1664574669506</id>
37+
<name></name>
38+
<type>30</type>
39+
<matcher>
40+
<id>org.eclipse.core.resources.regexFilterMatcher</id>
41+
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
42+
</matcher>
43+
</filter>
44+
</filteredResources>
3445
</projectDescription>

cobigen-eclipse/cobigen-eclipse-updatesite/.project

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,15 @@
2222
<nature>org.eclipse.m2e.core.maven2Nature</nature>
2323
<nature>org.eclipse.jdt.core.javanature</nature>
2424
</natures>
25+
<filteredResources>
26+
<filter>
27+
<id>1664574669516</id>
28+
<name></name>
29+
<type>30</type>
30+
<matcher>
31+
<id>org.eclipse.core.resources.regexFilterMatcher</id>
32+
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
33+
</matcher>
34+
</filter>
35+
</filteredResources>
2536
</projectDescription>

cobigen-eclipse/cobigen-eclipse/.classpath

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)