From b9195ae3342a8b36871891518693b217c32f2970 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 Dec 2022 12:23:51 +0100 Subject: [PATCH 01/12] Bump jackson-databind from 2.10.0 to 2.12.6.1 (#1524) Bumps [jackson-databind](https://github.com/FasterXML/jackson) from 2.10.0 to 2.12.6.1. - [Release notes](https://github.com/FasterXML/jackson/releases) - [Commits](https://github.com/FasterXML/jackson/commits) --- updated-dependencies: - dependency-name: com.fasterxml.jackson.core:jackson-databind dependency-type: direct:production ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Malte Brunnlieb --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bd7abc08d2..581a7a5cd3 100644 --- a/pom.xml +++ b/pom.xml @@ -139,7 +139,7 @@ com.fasterxml.jackson.core jackson-databind - 2.10.0 + 2.12.6.1 com.google.code.gson From 4e00a5f160164c0d2da26671f9b655a19e06ee14 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 Dec 2022 12:24:28 +0100 Subject: [PATCH 02/12] Bump gson from 2.8.6 to 2.8.9 (#1537) Bumps [gson](https://github.com/google/gson) from 2.8.6 to 2.8.9. - [Release notes](https://github.com/google/gson/releases) - [Changelog](https://github.com/google/gson/blob/master/CHANGELOG.md) - [Commits](https://github.com/google/gson/compare/gson-parent-2.8.6...gson-parent-2.8.9) --- updated-dependencies: - dependency-name: com.google.code.gson:gson dependency-type: direct:production ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: jan-vcapgemini <59438728+jan-vcapgemini@users.noreply.github.com> Co-authored-by: Malte Brunnlieb --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 581a7a5cd3..5e2779e28b 100644 --- a/pom.xml +++ b/pom.xml @@ -144,7 +144,7 @@ com.google.code.gson gson - 2.8.6 + 2.8.9 jaxen From 1aeb08900d88e9801ef43b6a39bfc7d91724ac49 Mon Sep 17 00:00:00 2001 From: Malte Brunnlieb Date: Fri, 16 Dec 2022 19:53:26 +0100 Subject: [PATCH 03/12] constant changes of eclipse for proper project setup --- .../cobigen-eclipse-feature/.project | 11 +++++++++++ cobigen-eclipse/cobigen-eclipse-test/.project | 11 +++++++++++ .../cobigen-eclipse-updatesite/.project | 11 +++++++++++ cobigen-eclipse/cobigen-eclipse/.project | 11 +++++++++++ cobigen-templates/templates-devon4j/.classpath | 17 +++++++++++++++++ cobigen-templates/templates-devon4j/.project | 11 +++++++++++ 6 files changed, 72 insertions(+) diff --git a/cobigen-eclipse/cobigen-eclipse-feature/.project b/cobigen-eclipse/cobigen-eclipse-feature/.project index 9e0f4f468f..7a6654cc23 100644 --- a/cobigen-eclipse/cobigen-eclipse-feature/.project +++ b/cobigen-eclipse/cobigen-eclipse-feature/.project @@ -27,4 +27,15 @@ org.eclipse.jdt.core.javanature org.eclipse.pde.FeatureNature + + + 1664574669497 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + diff --git a/cobigen-eclipse/cobigen-eclipse-test/.project b/cobigen-eclipse/cobigen-eclipse-test/.project index f8ccf86205..7c40ecd24c 100644 --- a/cobigen-eclipse/cobigen-eclipse-test/.project +++ b/cobigen-eclipse/cobigen-eclipse-test/.project @@ -31,4 +31,15 @@ org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature + + + 1664574669506 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + diff --git a/cobigen-eclipse/cobigen-eclipse-updatesite/.project b/cobigen-eclipse/cobigen-eclipse-updatesite/.project index 22137c8720..631967f7bd 100644 --- a/cobigen-eclipse/cobigen-eclipse-updatesite/.project +++ b/cobigen-eclipse/cobigen-eclipse-updatesite/.project @@ -22,4 +22,15 @@ org.eclipse.m2e.core.maven2Nature org.eclipse.jdt.core.javanature + + + 1664574669516 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + diff --git a/cobigen-eclipse/cobigen-eclipse/.project b/cobigen-eclipse/cobigen-eclipse/.project index ebab284bab..533bae1e4d 100644 --- a/cobigen-eclipse/cobigen-eclipse/.project +++ b/cobigen-eclipse/cobigen-eclipse/.project @@ -31,4 +31,15 @@ org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature + + + 1664574669486 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + diff --git a/cobigen-templates/templates-devon4j/.classpath b/cobigen-templates/templates-devon4j/.classpath index f92549f551..f5e7776dd7 100644 --- a/cobigen-templates/templates-devon4j/.classpath +++ b/cobigen-templates/templates-devon4j/.classpath @@ -46,5 +46,22 @@ + + + + + + + + + + + + + + + + + diff --git a/cobigen-templates/templates-devon4j/.project b/cobigen-templates/templates-devon4j/.project index 2a415ddb74..fccd2e4b05 100644 --- a/cobigen-templates/templates-devon4j/.project +++ b/cobigen-templates/templates-devon4j/.project @@ -21,4 +21,15 @@ org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature + + + 1664574669524 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + From a430130cb2f4bd0ba9286cbc280320759b9e198a Mon Sep 17 00:00:00 2001 From: Malte Brunnlieb Date: Mon, 2 Jan 2023 15:43:52 +0100 Subject: [PATCH 04/12] Rename workflow as off config file name collision --- .github/workflows/{spellcheck.yml => spellchecker.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{spellcheck.yml => spellchecker.yml} (100%) diff --git a/.github/workflows/spellcheck.yml b/.github/workflows/spellchecker.yml similarity index 100% rename from .github/workflows/spellcheck.yml rename to .github/workflows/spellchecker.yml From eda873e23501cf0b204cc11a6921033d43119f5b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Jan 2023 16:24:46 +0100 Subject: [PATCH 05/12] Bump jackson-databind from 2.12.6.1 to 2.12.7.1 (#1620) Bumps [jackson-databind](https://github.com/FasterXML/jackson) from 2.12.6.1 to 2.12.7.1. - [Release notes](https://github.com/FasterXML/jackson/releases) - [Commits](https://github.com/FasterXML/jackson/commits) --- updated-dependencies: - dependency-name: com.fasterxml.jackson.core:jackson-databind dependency-type: direct:production ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5e2779e28b..029605ecaf 100644 --- a/pom.xml +++ b/pom.xml @@ -139,7 +139,7 @@ com.fasterxml.jackson.core jackson-databind - 2.12.6.1 + 2.12.7.1 com.google.code.gson From 574bcc18a8b0ac45782753ab3c557d4dc2a6af18 Mon Sep 17 00:00:00 2001 From: Malte Brunnlieb Date: Tue, 3 Jan 2023 09:39:25 +0100 Subject: [PATCH 06/12] Some corrections of spelling --- documentation/mgmt_ide-setup.asciidoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/mgmt_ide-setup.asciidoc b/documentation/mgmt_ide-setup.asciidoc index 9cf348135e..e16ae99e43 100644 --- a/documentation/mgmt_ide-setup.asciidoc +++ b/documentation/mgmt_ide-setup.asciidoc @@ -27,8 +27,8 @@ This downloads all the necessary files for CobiGen development. . Now open eclipse using the eclipse-main.bat file or by executing `devon eclipse` on the console and import the CobiGen projects. .. Switch to the "Project Explorer" view (Window->Show View->Project Explorer). This extra step is required because an import from the default view "Package Explorer" doesn't work properly. .. Now we need to re-import the CobiGen project. This extra step is required because the automatic project import from devonfw doesn't work properly. -... Rightclick on your CobiGen root project and choose `Delete`. -... Tick `Delete xx nested Projects` and make sure to untick `Delete project content on disc` +... Right click on your CobiGen root project and choose `Delete`. +... Tick `Delete xx nested Projects` and make sure to deselect `Delete project content on disc` .. Click on File->import...->Maven->Existing Maven Project and entering `/workspaces/main/cobigen` (Should be the default location when clicking on "Browse...") . After you have have finished your installation run a maven update. To do so right click on a project, select maven and afterwards update project. Select all projects and the checkbox Force Update of Snapshot/Releases. You might be asked to install some Tycho-plugins. You need those, if you want to debug eclipse-plugins. From 0cf660991c707e2c30506391dc9aeab12a27204d Mon Sep 17 00:00:00 2001 From: Malte Brunnlieb Date: Tue, 3 Jan 2023 09:55:47 +0100 Subject: [PATCH 07/12] corrections of spellings --- documentation/_Footer.asciidoc | 2 +- documentation/cobigen-htmlplugin.asciidoc | 14 +++++++------- documentation/cobigen-tsplugin.asciidoc | 12 ++++++------ documentation/cobigen-usecases.asciidoc | 2 +- .../howto_create-external-plugin.asciidoc | 4 ++-- .../howto_ionic-client-generation.asciidoc | 4 ++-- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/documentation/_Footer.asciidoc b/documentation/_Footer.asciidoc index 3936aa0760..142984a19c 100644 --- a/documentation/_Footer.asciidoc +++ b/documentation/_Footer.asciidoc @@ -9,4 +9,4 @@ image:http://i.creativecommons.org/l/by-nd/4.0/88x31.png[] This documentation is licensed under the link:http://creativecommons.org/licenses/by-nd/4.0/[Creative Commons License (`Attribution-NoDerivatives 4.0 International`)] -//To change the footnote in the pdf, change https://github.com/devonfw/devonfw-docgen/blob/master/src/main/docbook/xsl/cobigen-pdf.xsl +//To change the footnote in the PDF, change https://github.com/devonfw/devonfw-docgen/blob/master/src/main/docbook/xsl/cobigen-pdf.xsl diff --git a/documentation/cobigen-htmlplugin.asciidoc b/documentation/cobigen-htmlplugin.asciidoc index 0b56efae02..088a23ff48 100644 --- a/documentation/cobigen-htmlplugin.asciidoc +++ b/documentation/cobigen-htmlplugin.asciidoc @@ -19,13 +19,13 @@ The merging of two Angular2 files will be processed as follows: The merge algorithm handles the following AST nodes: -* md-nav-list -* a -* form -* md-input-container -* input -* name (for name attribute) -* ngIf +* `md-nav-list` +* `a` +* `form` +* `md-input-container` +* `input` +* `name` (for name attribute) +* `ngIf` WARNING: Be aware, that the HTML merger is not generic and only handles the described tags needed for merging code of a basic Angular client implementation. For future versions, it is planned to implement a more generic solution. diff --git a/documentation/cobigen-tsplugin.asciidoc b/documentation/cobigen-tsplugin.asciidoc index 70007f9035..92575aede5 100644 --- a/documentation/cobigen-tsplugin.asciidoc +++ b/documentation/cobigen-tsplugin.asciidoc @@ -52,7 +52,7 @@ The TypeScript input reader is based on the one that the link:https://github.com `module: null` specifies a standard entity or type as `string` or `number`. === Object model -To get a first impression of the created object after parsing, let us start with analyzing a small example, namely the parsing of a simple link:https://typeorm.io/#/[type-orm] model written in TypeScript. +To get a first impression of the created object after parsing, let us start with analyzing a small example, namely the parsing of a simple link:https://typeorm.io/#/[TypeORM] model written in TypeScript. ```Typescript import {Entity, PrimaryGeneratedColumn, Column} from "typeorm"; @@ -192,10 +192,10 @@ Returning to the general case, independently from the given TypeScript file, an * *`importDeclarations`*: A list of import statement as described above * *`exportDeclarations`*: A list of export declarations -* *classes*: A list of classes extracted from the given file, where each entry is full of class specific fields, describing its properties and decorator for example. -* *interfaces*: A list of interfaces. -* *variables*: A list of variables. -* *functions*: A list of functions. -* *enums*: A list of enumerations. +* *`classes`*: A list of classes extracted from the given file, where each entry is full of class specific fields, describing its properties and decorator for example. +* *`interfaces`*: A list of interfaces. +* *`variables`*: A list of variables. +* *`functions`*: A list of functions. +* *`enums`*: A list of enumerations. diff --git a/documentation/cobigen-usecases.asciidoc b/documentation/cobigen-usecases.asciidoc index bda7e58f5a..ca936bbf26 100644 --- a/documentation/cobigen-usecases.asciidoc +++ b/documentation/cobigen-usecases.asciidoc @@ -15,7 +15,7 @@ For the server, the required files for all architectural layers (data access, lo === CRUD client application for devon4ng -Based on the REST services on the server, you can generate an link:https://angularjs.org/[Angular] client or even an link:https://ionicframework.com/[Ionic] mobile client based on link:https://github.com/devonfw/devon4ng[devon4ng]. With the help of link:https://nodejs.org/[Node.js], you have a working client application for displaying your entities within minutes! +Based on the REST services on the server, you can generate an link:https://angularjs.org/[Angular] client or even an link:https://ionicframework.com/[Ionic] mobile client based on link:https://github.com/devonfw/devon4ng[devon4ng]. With the help of link:https://nodejs.org/[NodeJS], you have a working client application for displaying your entities within minutes! === Test data Builder for devon4j diff --git a/documentation/howto_create-external-plugin.asciidoc b/documentation/howto_create-external-plugin.asciidoc index ad9fd59412..f3bbea4954 100644 --- a/documentation/howto_create-external-plugin.asciidoc +++ b/documentation/howto_create-external-plugin.asciidoc @@ -23,7 +23,7 @@ Basically, when a new input file was sent to CobiGen, it called the input reader Afterwards, the template engine generated a new file which had to be merged with the original one. All this code was implemented in Java. -On the new version, we have implemented a handler (`ExternalProcessHandler`) which connects through TCP/IP connection to a server (normally on localhost:5000). This server can be implemented in any language (.Net, Node.js, Python...) it just needs to implement a REST API defined link:https://github.com/devonfw/cobigen-template-plugin/blob/master/APIContract.yml[here]. The most important services are the input reading and merging: +On the new version, we have implemented a handler (`ExternalProcessHandler`) which connects through TCP/IP connection to a server (normally on localhost:5000). This server can be implemented in any language (.NET, NodeJS, Python...) it just needs to implement a REST API defined link:https://github.com/devonfw/cobigen-template-plugin/blob/master/APIContract.yml[here]. The most important services are the input reading and merging: image::images/howtos/todo-plugin/newCobiGen.png[New CobiGen,width="450"link="images/howtos/todo-plugin/newCobiGen.png"] @@ -313,7 +313,7 @@ c. If that worked, now you can send any arguments to the CLI in order to generat 3. Use the CLI jar to execute commands: + -a. The `mvn clean install -DskipTests` command will have created a Cobigen.jar inside your target folder (_cobigen-cli/cli/target_). Open the jar with any unzipper and extract to the current location _class-loader-agent.jar_, _cobigen.bat_ and _cg.bat_: +a. The `mvn clean install -DskipTests` command will have created a `cli.jar` inside your target folder (`cobigen-cli/cli/target`). Open the jar with any unzipper and extract to the current location `class-loader-agent.jar`, `cobigen.bat` and `cg.bat`: + image::images/howtos/todo-plugin/extractFilesCLI.png[Extract files,width="450"link="images/howtos/todo-plugin/extractFilesCLI.png"] + diff --git a/documentation/howto_ionic-client-generation.asciidoc b/documentation/howto_ionic-client-generation.asciidoc index d23199b846..ba8b0a9502 100644 --- a/documentation/howto_ionic-client-generation.asciidoc +++ b/documentation/howto_ionic-client-generation.asciidoc @@ -14,7 +14,7 @@ Before starting, make sure you have the following things already installed on yo - link:https://ionicframework.com/docs/installation/cli[Ionic]: follow the steps described on the Ionic page. It includes the installation of: -** link:https://nodejs.org/en/[Node.js]: We have to use the `npm` package manager for downloading packages. +** link:https://nodejs.org/en/[NodeJS]: We have to use the `npm` package manager for downloading packages. ** Ionic CLI. - link:https://capacitor.ionicframework.com/docs/getting-started/[Capacitor]: Necessary to access to native device features. @@ -36,7 +36,7 @@ After that, please create a link:https://github.com/devonfw/devon4ng/wiki/tutori As you can see, `TableEto` contains 3 attributes: 2 of them are `Long` and the third one `TableState` is an enum that you will find link:https://github.com/devonfw/devon4j/blob/develop/samples/core/src/main/java/io/devonfw/gastronomy/restaurant/tablemanagement/common/api/datatype/TableState.java[here]. -The Ionic generation works fine for any Java primitive attribute (Strings, floats, chars, boolean...) and enums. However, if you want to use your own objects, you should +The Ionic generation works fine for any Java primitive attribute (string, float, char, boolean...) and enums. However, if you want to use your own objects, you should override the `toString()` method, as explained link:https://stackoverflow.com/questions/35361482/typescript-override-tostring[here]. The attributes explained above will be used for generating a page that shows a list. Each item of that list From 9e75ac9c7a013d93eff0627f5d807c94e4786343 Mon Sep 17 00:00:00 2001 From: EduardKrieger <79975016+EduardKrieger@users.noreply.github.com> Date: Tue, 3 Jan 2023 13:59:53 +0100 Subject: [PATCH 08/12] Optimize class path cache files (#1613) * added new hash generation and validation of cached files * added pom to test resources * reworked test after failing in the pipeline cause of problems with the m2 repo * changed testGeneratePomFileHash to run in pipeline * reworked testcases, test running without multiple maven repositories now * adding a cli test that runs a generation twice to check correct caching * added cli generation test as an integrationtest * adjusting doc and log according to suggestions * adjusted javadoc --- .../cli/systemtest/GenerateCommandIT.java | 65 ++++++++++ .../cobigen/cli/utils/CobiGenUtils.java | 8 +- .../cobigen-eclipse-test/.classpath | 36 ------ cobigen-eclipse/cobigen-eclipse/.classpath | 54 -------- cobigen/cobigen-core-api/pom.xml | 2 +- .../devonfw/cobigen/api/util/MavenUtil.java | 62 ++++++++-- .../devonfw/cobigen/api/MavenUtilTest.java | 117 ++++++++++++++++++ .../testdata/unittest/MavenUtilTest/pom.xml | 66 ++++++++++ .../generator/GenerationProcessorImpl.java | 2 +- 9 files changed, 306 insertions(+), 106 deletions(-) delete mode 100644 cobigen-eclipse/cobigen-eclipse-test/.classpath delete mode 100644 cobigen-eclipse/cobigen-eclipse/.classpath create mode 100644 cobigen/cobigen-core-api/src/test/java/com/devonfw/cobigen/api/MavenUtilTest.java create mode 100644 cobigen/cobigen-core-api/src/test/resources/testdata/unittest/MavenUtilTest/pom.xml diff --git a/cobigen-cli/cli-systemtest/src/test/java/com/devonfw/cobigen/cli/systemtest/GenerateCommandIT.java b/cobigen-cli/cli-systemtest/src/test/java/com/devonfw/cobigen/cli/systemtest/GenerateCommandIT.java index c1e0b21c6f..4d4a45505f 100644 --- a/cobigen-cli/cli-systemtest/src/test/java/com/devonfw/cobigen/cli/systemtest/GenerateCommandIT.java +++ b/cobigen-cli/cli-systemtest/src/test/java/com/devonfw/cobigen/cli/systemtest/GenerateCommandIT.java @@ -4,6 +4,7 @@ import java.io.File; import java.io.IOException; +import java.nio.charset.Charset; import java.nio.file.Path; import org.apache.commons.io.FileUtils; @@ -296,4 +297,68 @@ public void generateFromArgsWithQuote() throws Exception { assertThat(outputRootPath.resolve("docs")).exists(); } + /** + * Integration test of the generation and validation of the class path cache. The test will execute a generation twice + * this requires some cleanup.A deleted dependencies will be detected by the validating process in MavenUtil and will + * reload the needed dependency and not prevent the second generation + * + * @throws Exception test fails + */ + @Test + public void generateFromEntityTwiceToTestCache() throws Exception { + + // prepare + File outputRootFile = this.tempFolder.newFolder("playground2", "rootoutput"); + File openApiFile = new File(testFileRootPath + "openAPI.yml"); + + String args[] = new String[6]; + args[0] = "generate"; + args[1] = openApiFile.getAbsolutePath(); + args[2] = "--out"; + args[3] = outputRootFile.getAbsolutePath(); + args[4] = "--increments"; + args[5] = "ionic_component,OpenAPI_Docs,services"; + + execute(args, true); + + Path rootPath = outputRootFile.toPath(); + assertThat(rootPath.resolve("../../devon4ng-ionic-application-template")); + + // cleanup for a second execution of generate to test the correct cache usage + File cli_config = this.tempFolder.getRoot().toPath().resolve("cobigen-test-home").toFile(); + File bin = cli_config.toPath().resolve("cobigen-test-home/bin").toFile(); + if (bin.exists()) { + FileUtils.deleteDirectory(bin); + } + File lib = cli_config.toPath().resolve("cobigen-test-home/lib").toFile(); + if (lib.exists()) { + FileUtils.deleteDirectory(lib); + } + File license = cli_config.toPath().resolve("cobigen-test-home/LICENSE.txt").toFile(); + if (license.exists()) { + FileUtils.delete(license); + } + File cli = cli_config.toPath().resolve("cli-config").toFile(); + // get the saved dependencies in the cache file and delete one + for (File f : cli.listFiles()) { + if (f.getName().startsWith("pom-cp-")) { + String dependenciesFromCache = FileUtils.readFileToString(f, Charset.defaultCharset()); + String osName = System.getProperty("os.name"); + String[] dependenciesFromCacheArray; + if (osName.contains("Windows")) { + dependenciesFromCacheArray = dependenciesFromCache.split(";"); + } else { + dependenciesFromCacheArray = dependenciesFromCache.split(":"); + } + for (int i = 0; i >= 0; i--) { // reverse + if (dependenciesFromCacheArray[i].contains("javax.persistence")) { + FileUtils.delete(new File(dependenciesFromCacheArray[i])); // delete a randomly picked dependency + } + } + } + } + FileUtils.delete(cli_config.toPath().resolve("cli.tar.gz").toFile()); + execute(args, true); + } + } diff --git a/cobigen-cli/cli/src/main/java/com/devonfw/cobigen/cli/utils/CobiGenUtils.java b/cobigen-cli/cli/src/main/java/com/devonfw/cobigen/cli/utils/CobiGenUtils.java index db556185f9..d62b624f88 100644 --- a/cobigen-cli/cli/src/main/java/com/devonfw/cobigen/cli/utils/CobiGenUtils.java +++ b/cobigen-cli/cli/src/main/java/com/devonfw/cobigen/cli/utils/CobiGenUtils.java @@ -53,11 +53,13 @@ public class CobiGenUtils { public static CobiGen initializeCobiGen(Path templatesProject) { registerPlugins(); + CobiGen cg; if (templatesProject != null) { - return CobiGenFactory.create(templatesProject.toUri()); + cg = CobiGenFactory.create(templatesProject.toUri()); } else { - return CobiGenFactory.create(); + cg = CobiGenFactory.create(); } + return cg; } /** @@ -79,7 +81,7 @@ public static ClassLoader registerPlugins() { Path rootCLIPath = getCliHomePath(); File pomFile = extractArtificialPom(); - String pomFileHash = MavenUtil.generatePomFileHash(pomFile.toPath()); + String pomFileHash = MavenUtil.generatePomFileHash(pomFile.toPath(), MavenUtil.determineMavenRepositoryPath()); Path cpFile = rootCLIPath.resolve(String.format(MavenConstants.CLASSPATH_CACHE_FILE, pomFileHash)); diff --git a/cobigen-eclipse/cobigen-eclipse-test/.classpath b/cobigen-eclipse/cobigen-eclipse-test/.classpath deleted file mode 100644 index 8d0ae98bfc..0000000000 --- a/cobigen-eclipse/cobigen-eclipse-test/.classpath +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cobigen-eclipse/cobigen-eclipse/.classpath b/cobigen-eclipse/cobigen-eclipse/.classpath deleted file mode 100644 index 4946a86405..0000000000 --- a/cobigen-eclipse/cobigen-eclipse/.classpath +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cobigen/cobigen-core-api/pom.xml b/cobigen/cobigen-core-api/pom.xml index 7f8555d058..8924f9bbc9 100644 --- a/cobigen/cobigen-core-api/pom.xml +++ b/cobigen/cobigen-core-api/pom.xml @@ -27,7 +27,7 @@ com.google.guava guava - + org.zeroturnaround diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/util/MavenUtil.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/util/MavenUtil.java index 0b221f9a63..9cf83b73a1 100644 --- a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/util/MavenUtil.java +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/util/MavenUtil.java @@ -3,6 +3,7 @@ import java.io.File; import java.io.IOException; import java.net.MalformedURLException; +import java.net.URISyntaxException; import java.net.URL; import java.net.URLClassLoader; import java.nio.file.Files; @@ -115,6 +116,9 @@ public static Path createCachedPomFromJar(Path pomFile, Path outputPath) { Path cachedPomXml = outputPath.resolve("cached-pom.xml"); try { + if (Files.exists(cachedPomXml)) { + Files.delete(cachedPomXml); + } Files.copy(pomFile, cachedPomXml); } catch (IOException e) { throw new CobiGenRuntimeException("Unable to extract " + pomFile.toUri() + " from JAR to " + cachedPomXml, e); @@ -143,7 +147,6 @@ public static URLClassLoader addURLsFromCachedClassPathsFile(Path classPathCache } else { LOG.debug("Taking cached class paths from: {}", classPathCacheFile); } - try (Stream fileLinesStream = Files.lines(classPathCacheFile)) { URL[] classPathEntries = fileLinesStream .flatMap(e -> Arrays.stream(e.split(SystemUtil.getOS().contains("win") ? ";" : ":"))).map(path -> { @@ -155,6 +158,9 @@ public static URLClassLoader addURLsFromCachedClassPathsFile(Path classPathCache return null; }).toArray(size -> new URL[size]); + if (!validateCachedClassPaths(classPathEntries)) { + cacheMavenClassPath(pomFile, classPathCacheFile); + } return new URLClassLoader(classPathEntries, parentClassLoader); } catch (IOException e) { throw new CobiGenRuntimeException("Unable to read " + classPathCacheFile, e); @@ -162,16 +168,51 @@ public static URLClassLoader addURLsFromCachedClassPathsFile(Path classPathCache } /** - * Generates a hash for the provided POM file + * Validates the cached classpath entries and resolves missing files and dependencies with an update of the classpath + * cache. Also, the dependencies are checked, if they belong to the correct local maven repository. + * + * @param classPathEntries URLs of the cached classPath entries + * @return true if files exists and they are located in the correct repository, otherwise false + */ + private static boolean validateCachedClassPaths(URL[] classPathEntries) { + + Path repo = determineMavenRepositoryPath(); + for (URL classPath : classPathEntries) { + try { + Path cp = Paths.get(classPath.toURI()); + if (!cp.startsWith(repo)) { + LOG.warn( + "Cached {} file pointing to another maven Repository, this could cause some problems, the dependencies will be resolved again", + cp.toString()); + return false; + } + if (!Files.exists(cp)) { + LOG.warn("Cached {} file does not exist, the dependencies will be resolved again", cp.toString()); + return false; + } + } catch (URISyntaxException e) { + LOG.warn("Error while reading files from Cache, the dependencies will be resolved again"); + return false; + } + } + return true; + } + + /** + * Generates a hash for the provided POM file and the current local maven repository * * @param pomFile to generate hash from + * @param m2RepoPath Path to the local maven repository * @return String generated hash */ - public static String generatePomFileHash(Path pomFile) { + public static String generatePomFileHash(Path pomFile, Path m2RepoPath) { String pomFileHash; try { - pomFileHash = ByteSource.wrap(Files.readAllBytes(pomFile)).hash(Hashing.murmur3_128()).toString(); + // concat pom.xml and m2repo Path bytes + ByteSource m2repo = ByteSource.wrap(m2RepoPath.toString().getBytes()); + ByteSource m2repoAndPom = ByteSource.concat(m2repo, ByteSource.wrap(Files.readAllBytes(pomFile))); + pomFileHash = m2repoAndPom.hash(Hashing.murmur3_128()).toString(); } catch (IOException e) { LOG.warn("Could not calculate hash of {}", pomFile.toUri()); pomFileHash = ""; @@ -184,12 +225,11 @@ public static String generatePomFileHash(Path pomFile) { */ public static Path determineMavenRepositoryPath() { - LOG.info("Determine maven repository path"); - String m2Repo = runCommand(SystemUtils.getUserHome().toPath(), - Lists.newArrayList(SystemUtil.determineMvnPath().toString(), "help:evaluate", - "-Dexpression=settings.localRepository", "-DforceStdout")); + Path m2Repo = Paths + .get(runCommand(SystemUtils.getUserHome().toPath(), Lists.newArrayList(SystemUtil.determineMvnPath().toString(), + "help:evaluate", "-Dexpression=settings.localRepository", "-DforceStdout"))); LOG.debug("Determined {} as maven repository path.", m2Repo); - return Paths.get(m2Repo); + return m2Repo; } /** @@ -221,7 +261,6 @@ private static String runCommand(Path execDir, List args) { Future future = process.getFuture(); ProcessResult processResult = future.get(); - if (processResult.getExitValue() != 0) { LOG.error("Error while getting all the needed transitive dependencies. Please check your internet connection."); throw new CobiGenRuntimeException("Unable to build cobigen dependencies"); @@ -337,4 +376,5 @@ public static Path getProjectRoot(Path inputFile, boolean topLevel) { LOG.debug("Project root could not be found."); return null; } -} + +} \ No newline at end of file diff --git a/cobigen/cobigen-core-api/src/test/java/com/devonfw/cobigen/api/MavenUtilTest.java b/cobigen/cobigen-core-api/src/test/java/com/devonfw/cobigen/api/MavenUtilTest.java new file mode 100644 index 0000000000..3af031e88b --- /dev/null +++ b/cobigen/cobigen-core-api/src/test/java/com/devonfw/cobigen/api/MavenUtilTest.java @@ -0,0 +1,117 @@ +package com.devonfw.cobigen.api; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.File; +import java.nio.charset.Charset; +import java.nio.file.Path; + +import org.apache.commons.io.FileUtils; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import com.devonfw.cobigen.api.util.MavenUtil; + +/** + * Test class for maven utilities + */ +public class MavenUtilTest { + + /** + * Temp folder for test execution + */ + @Rule + public TemporaryFolder temp = new TemporaryFolder(); + + /** Testdata root path */ + private static final String testdataRoot = "src/test/resources/testdata/unittest/MavenUtilTest"; + + /** + * Tests to check if a correct cache will be validated right + * + * @throws Exception + */ + @Test + public void testValidateCacheSuccess() throws Exception { + + File cli_pom = this.temp.newFolder("playground", "cli-pom"); + Path m2repo = MavenUtil.determineMavenRepositoryPath(); + FileUtils.copyFileToDirectory(new File(testdataRoot, "pom.xml"), cli_pom); + String hash = MavenUtil.generatePomFileHash(cli_pom.toPath().resolve("pom.xml"), m2repo); + File cache = this.temp.newFile("playground/cli-pom/pom-cp-" + hash + ".txt"); + MavenUtil.cacheMavenClassPath(cli_pom.toPath().resolve("pom.xml"), cache.toPath()); + String result = FileUtils.readFileToString(cache, Charset.defaultCharset()); + MavenUtil.addURLsFromCachedClassPathsFile(cache.toPath(), cli_pom.toPath().resolve("pom.xml"), + this.getClass().getClassLoader()); + assertThat(FileUtils.readFileToString(cache, Charset.defaultCharset())).contains(result); + + } + + /** + * Tests to check if a dependency in the cache pointing to a wrong repository will be detected and the cache will be + * updated + * + * @throws Exception + */ + @Test + public void testValidateCacheWrongRepository() throws Exception { + + File cli_pom = this.temp.newFolder("playground", "cli-pom"); + Path m2repo = MavenUtil.determineMavenRepositoryPath(); + FileUtils.copyFileToDirectory(new File(testdataRoot, "pom.xml"), cli_pom); + String hash = MavenUtil.generatePomFileHash(cli_pom.toPath().resolve("pom.xml"), m2repo); + File cache = this.temp.newFile("playground/cli-pom/pom-cp-" + hash + ".txt"); + MavenUtil.cacheMavenClassPath(cli_pom.toPath().resolve("pom.xml"), cache.toPath()); + String result = FileUtils.readFileToString(cache, Charset.defaultCharset()); + String cacheWithWrongRepo = result.replace(m2repo.getFileName().toString(), "WrongRepository"); + FileUtils.writeStringToFile(cache, cacheWithWrongRepo, Charset.defaultCharset()); + MavenUtil.addURLsFromCachedClassPathsFile(cache.toPath(), cli_pom.toPath().resolve("pom.xml"), + this.getClass().getClassLoader()); + assertThat(FileUtils.readFileToString(cache, Charset.defaultCharset())).doesNotContain(cacheWithWrongRepo); + } + + /** + * Tests to check if a missing dependency file from the cache will be detected and the cache will be updated + * + * @throws Exception + */ + @Test + public void testValidateCacheFileNotExistend() throws Exception { + + File cli_pom = this.temp.newFolder("playground", "cli-pom"); + Path m2repo = MavenUtil.determineMavenRepositoryPath(); + FileUtils.copyFileToDirectory(new File(testdataRoot, "pom.xml"), cli_pom); + String hash = MavenUtil.generatePomFileHash(cli_pom.toPath().resolve("pom.xml"), m2repo); + File cache = this.temp.newFile("playground/cli-pom/pom-cp-" + hash + ".txt"); + MavenUtil.cacheMavenClassPath(cli_pom.toPath().resolve("pom.xml"), cache.toPath()); + String result = FileUtils.readFileToString(cache, Charset.defaultCharset()); + String cacheWithNotExistingFile = result + ";" + m2repo.toString() + "/SomeNonExistingFile.jar"; + FileUtils.writeStringToFile(cache, cacheWithNotExistingFile, Charset.defaultCharset()); + MavenUtil.addURLsFromCachedClassPathsFile(cache.toPath(), cli_pom.toPath().resolve("pom.xml"), + this.getClass().getClassLoader()); + assertThat(FileUtils.readFileToString(cache, Charset.defaultCharset())).doesNotContain("SomeNonExistingFile.jar"); + + } + + /** + * Testing if the current maven repository is taken into account to calculate the hash for the cache + * + * @throws Exception + * + */ + @Test + public void testGeneratePomFileHash() throws Exception { + + File repo1 = this.temp.newFolder("playground", "repo1"); + File repo2 = this.temp.newFolder("playground", "repo2"); + FileUtils.copyFileToDirectory(new File(testdataRoot, "pom.xml"), repo2.getParentFile()); + String hash1 = MavenUtil.generatePomFileHash(repo1.getParentFile().toPath().resolve("pom.xml"), repo1.toPath()); + String hash2 = MavenUtil.generatePomFileHash(repo2.getParentFile().toPath().resolve("pom.xml"), repo2.toPath()); + assertThat(hash1).isNotEmpty(); + assertThat(hash2).isNotEmpty(); + assertThat(hash1).isNotEqualTo(hash2); + + } + +} diff --git a/cobigen/cobigen-core-api/src/test/resources/testdata/unittest/MavenUtilTest/pom.xml b/cobigen/cobigen-core-api/src/test/resources/testdata/unittest/MavenUtilTest/pom.xml new file mode 100644 index 0000000000..8eb656fc8a --- /dev/null +++ b/cobigen/cobigen-core-api/src/test/resources/testdata/unittest/MavenUtilTest/pom.xml @@ -0,0 +1,66 @@ + + 4.0.0 + com.devonfw.cobigen + cli + 2021.12.006 + cobigen-cli + + + UTF-8 + + + + + com.devonfw.cobigen + javaplugin + 2021.12.006 + + + com.devonfw.cobigen + tsplugin + 2021.12.006 + + + com.devonfw.cobigen + xmlplugin + 2021.12.006 + + + com.devonfw.cobigen + textmerger + 2021.12.006 + + + com.devonfw.cobigen + openapiplugin + 2021.12.006 + + + com.devonfw.cobigen + tempeng-freemarker + 2021.12.006 + + + com.devonfw.cobigen + htmlplugin + 2021.12.006 + + + com.devonfw.cobigen + propertyplugin + 2021.12.006 + + + com.devonfw.cobigen + jsonplugin + 2021.12.006 + + + com.devonfw.cobigen + templates-devon4j + 2021.12.006 + + + + \ No newline at end of file diff --git a/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/generator/GenerationProcessorImpl.java b/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/generator/GenerationProcessorImpl.java index a89671570a..1f6cab3e3c 100644 --- a/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/generator/GenerationProcessorImpl.java +++ b/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/generator/GenerationProcessorImpl.java @@ -268,7 +268,7 @@ private ClassLoader prependTemplatesClassloader(Path configLocation, ClassLoader if (Files.exists(pomFile)) { LOG.debug("Found templates to be configured by maven."); - String pomFileHash = MavenUtil.generatePomFileHash(pomFile); + String pomFileHash = MavenUtil.generatePomFileHash(pomFile, MavenUtil.determineMavenRepositoryPath()); if (this.configurationHolder.isJarConfig()) { cpCacheFile = configLocation From b00e269354455d7bb9b8d04d4f4966ea88c31c8c Mon Sep 17 00:00:00 2001 From: Malte Brunnlieb Date: Tue, 3 Jan 2023 13:42:24 +0100 Subject: [PATCH 09/12] Merge branch 'master' into template-set-deployables # Conflicts: # cobigen-cli/cli/src/main/java/com/devonfw/cobigen/cli/utils/CobiGenUtils.java # cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/generator/GenerationProcessorImpl.java --- .../cobigen-core_configuration.asciidoc | 85 ++++- .../cobigen-maven_configuration.asciidoc | 2 +- documentation/cobigen-textmerger.asciidoc | 4 +- .../guide_dev_troubleshooting.asciidoc | 2 +- ...howto-devonfw-ide-CobiGen-PoC-E2E.asciidoc | 339 ++++-------------- .../howto_create-external-plugin.asciidoc | 18 +- documentation/master-cobigen.asciidoc | 43 --- ...t__release_and_deployment_process.asciidoc | 4 +- documentation/setup-jre.asciidoc | 18 - 9 files changed, 159 insertions(+), 356 deletions(-) delete mode 100644 documentation/setup-jre.asciidoc diff --git a/documentation/cobigen-core_configuration.asciidoc b/documentation/cobigen-core_configuration.asciidoc index f226e0e0c3..68ab762cff 100644 --- a/documentation/cobigen-core_configuration.asciidoc +++ b/documentation/cobigen-core_configuration.asciidoc @@ -24,14 +24,93 @@ Within the configuration jar or directory you will find the following structure: ``` CobiGen_Templates |- templateFolder1 - |- templates.xml + |- src + |- main + |- templates + |- template1 + |- templates + |- templates.xml |- templateFolder2 - |- templates.xml |- context.xml ``` +Since: CobiGen 2021.12.007: + +``` +template-sets + |- downloaded + |- template-set1.jar + |- template-set2.jar + |- template-set-utilities.jar + |- adapted + |- template-set1 + |- src + |- main + |- templates + |- templates + |- context.xml + |- templates.xml + |- template-set2 +``` + Find some examples https://github.com/devonfw/cobigen/tree/master/cobigen-templates[here]. +== CobiGen Configuration File + +The CobiGen configuration file located at: `$home/.cobigen` can be used to set the path to the custom `templates` as well as the `template sets` project. +You can also specify attributes to control the behaviour of your template sets. + +=== Templates + +For a custom templates folder simply set the `templates` parameter like this: + +``` +templates=C:\\project\\ide\\conf\\templates +``` + +For a custom templates jar simply set the `templates` parameter like this: + +``` +templates=C:\\project\\ide\\conf\\templates\\my-custom-templates-devon4j-2021.06.001.jar +``` + +=== Template Sets +Since: CobiGen 2021.12.006 + +For a custom template-sets folder simply set the `template-sets` parameter like this: + +``` +template-sets=C:\\project\\ide\\conf\\template-sets +``` + +=== Template set attributes +Since: CobiGen 2021.12.006 + +You can specify `template-sets` attributes f.e. to restrict the teams to ask for default templates provided by CobiGen. There are `four` custom template-sets attributes: + +* `template-sets.groupIds`: Search for template-set artifacts by that configuration key +configure multiple (comma separated) `groupIds`. By default, (public) CobiGen `groupId` will be used. + +* `template-sets.allow-snapshots`: Allow snapshots of template-sets to be offered for template-set development purposes. By default, no snapshots should be queried. + +* `template-sets.disable-default-lookup`: Disable by default querying of default public `groupIds` configured in CobiGen. + +* `template-sets.hide:` Hide very specific template sets or versions of template sets. + +* `template-sets.installed:` Template sets will be available at CobiGen startup if template sets are not already adapted. + +The key `template-sets.hide` and `template-sets.installed` accept maven coordinate with the following format: `groupID:artifactID:version` the version is optional and if omitted the **LATEST** version will be used. You can specify multiple maven coordinates separated with *,*. + +* An example of how such a configuration should look like: + +``` +template-sets.groupIds=com.devonfw.cobigen.templates,jaxen,jakarta.xml.bind +template-sets.allow-snapshots=true +template-sets.disable-default-lookup=false +template-sets.hide=com.devonfw.cobigen.templates:crud-angular-client-app:2021.12.007-SNAPSHOT +template-sets.installed=com.devonfw.cobigen.templates:crud-angular-client-app:2021.12.007-SNAPSHOT, com.devonfw.cobigen.templates:crud-java-server-app: +``` + == Context Configuration The context configuration (`context.xml`) always has the following root structure: @@ -197,7 +276,7 @@ A template declaration consist of multiple information: ** `?lower_case` analogue to http://freemarker.org/docs/ref_builtins_string.html#ref_builtin_lower_case[FreeMarker] ** `?upper_case` analogue to http://freemarker.org/docs/ref_builtins_string.html#ref_builtin_upper_case[FreeMarker] ** `?replace(regex, replacement)` - Replaces all occurrences of the regular expression `regex` in the variable's value with the given `replacement` string. (since `cobigen-core v1.1.0`) -** `?removeSuffix(suffix)` - Removes the given `suffix` in the variable's value iff the variable's value ends with the given `suffix`. Otherwise nothing will happen. (since `cobigen-core v1.1.0`) +** `?removeSuffix(suffix)` - Removes the given `suffix` in the variable's value if and only if the variable's value ends with the given `suffix`. Otherwise nothing will happen. (since `cobigen-core v1.1.0`) ** `?removePrefix(prefix)` - Analogue to `?removeSuffix` but removes the prefix of the variable's value. (since `cobigen-core v1.1.0`) * The attribute `templateFile` describes the relative path dependent on the template folder specified in the xref:trigger-node[trigger] to the template file to be generated. * The attribute `mergeStrategy` _(optional)_ can be _optionally_ specified and declares the type of merge mechanism to be used, when the `destinationPath` points to an already existing file. CobiGen by itself just comes with a `mergeStrategy` `override`, which enforces file regeneration in total. Additional available merge strategies have to be obtained from the different plug-in's documentations (see here for link:cobigen-javaplugin#merger-extensions[java], link:cobigen-xmlplugin#merger-extensions[XML], link:cobigen-propertyplugin#merger-extensions[properties], and link:cobigen-textmerger#merger-extensions[text]). Default: _not set_ (means not mergeable) diff --git a/documentation/cobigen-maven_configuration.asciidoc b/documentation/cobigen-maven_configuration.asciidoc index 91b608a905..4e503a4bc5 100644 --- a/documentation/cobigen-maven_configuration.asciidoc +++ b/documentation/cobigen-maven_configuration.asciidoc @@ -81,7 +81,7 @@ We currently provide a generic deployed version of the templates on the devonfw- Using the following configuration you will be able to customize your generation as follows: -* `` specifies the root directory the relative `destinationPath` of link:cobigen-core_configuration#Templates-configuration[CobiGen templates configuration] should depend on. _Default ${basedir}_ +* `` specifies the root directory the relative `destinationPath` of link:cobigen-core_configuration#Templates-configuration[CobiGen templates configuration] should depend on. Default `${basedir}` * `` declares a package name to be used as input for batch generation. This refers directly to the CobiGen Java Plug-in link:cobigen-javaplugin#`ContainerMatcher`-types[container matchers of type package] configuration. * `` declares a file to be used as input. The CobiGen maven plug-in will try to parse this file to get an appropriate input to be interpreted by any CobiGen plug-in. * `` specifies an link:cobigen-core_configuration#increment-node[increment] ID to be generated. You can specify one single increment with content `ALL` to generate all increments matching the input(s). diff --git a/documentation/cobigen-textmerger.asciidoc b/documentation/cobigen-textmerger.asciidoc index b1d6f0292b..a3602420fb 100644 --- a/documentation/cobigen-textmerger.asciidoc +++ b/documentation/cobigen-textmerger.asciidoc @@ -59,7 +59,7 @@ _Remark:_ Only works with appending strategies, not merging/replacing ones. Thes == Usage Examples === General -Below you can see how a file with anchors might look like (using Asciidoc comment tags), with examples of what you might want to use the different functions for. +Below you can see how a file with anchors might look like (using AsciiDoc comment tags), with examples of what you might want to use the different functions for. -------- // anchor:header:append:anchorend @@ -75,7 +75,7 @@ Table entries // anchor:part2:nomerge:anchorend Document Separators -Asciidoc table definitions +AsciiDoc table definitions // anchor:part3:override:anchorend diff --git a/documentation/guide_dev_troubleshooting.asciidoc b/documentation/guide_dev_troubleshooting.asciidoc index 0cb6c6e094..bccb41bb16 100644 --- a/documentation/guide_dev_troubleshooting.asciidoc +++ b/documentation/guide_dev_troubleshooting.asciidoc @@ -31,7 +31,7 @@ ic (https://devon.s2-eu.capgemini.com/nexus/content/groups/public/): Not authori ==== Solution -Please note the message Not authorized , ReasonPhrase: Unauthorized. -> [Help 2]! +Please note the message `Not authorized , ReasonPhrase: Unauthorized. -> [Help 2]!` 1. Please check, that you run the command by using the console.bat or a similar console initialized with the IDE environment variables. 2. Please check your corporate login in the variables-customized.bat to be correct (`DEVON_NEXUS_USER` and `DEVON_NEXUS_PASSWD`). Make sure, that you restart the console.bat you are working in after changing the variables-customized.bat. Same holds for eclipse instances running. Please restart to make the new values accessible. diff --git a/documentation/howto-devonfw-ide-CobiGen-PoC-E2E.asciidoc b/documentation/howto-devonfw-ide-CobiGen-PoC-E2E.asciidoc index 92fde7aa50..85b9ba389b 100644 --- a/documentation/howto-devonfw-ide-CobiGen-PoC-E2E.asciidoc +++ b/documentation/howto-devonfw-ide-CobiGen-PoC-E2E.asciidoc @@ -1,54 +1,40 @@ -:doctype: book :toc: toc::[] = End to End POC Code generation using Entity class This article helps to create a sample application using CobiGen. == Prerequisites -Download and install devonfw IDE https://devonfw.com/website/pages/docs/devonfw-ide-introduction.asciidoc.html#setup.asciidoc[here], +Download and install devonfw IDE by this https://devonfw.com/website/pages/docs/devonfw-guide_ide.wiki_setup.asciidoc.html[tutorial]. == Steps to create a Sample Project using CobiGen The `HOW_TO` is divided in 2 parts: -[arabic] -. `BE`-Backend generator (`DB` + `DAO` + services) – CONTRACT FIRST APPROACH -. `FE`-Frontend generator (Web App Angular + Ionic App) – CONTRACT FIRST APPROACH + +. `BE`-Backend generator (`DB` + `DAO` + services) +. `FE`-Frontend generator (Web App Angular + Ionic App) image:images/howtos/e2e_gen/image63.png[CobiGen code-first generation] -So, ready to go! We’re going to start from the `BE` part … +So, ready to go! We’re going to start with the `BE` part. === Backend -Under your path installation of devonfw, you can find the _eclipse-main.bat_ script and you can run it: + -run _installation_path_\eclipse-main.bat - -It will open eclipse - -[arabic] -Create a project using a command from the command prompt. + -To made it, it's necessary to open a CMD and open the folder where it's installed devonfw and launch this command under the path `_workspaces/main_`. + +1.Under your path installation of devonfw, you can find the _eclipse-main.bat_ script. To run it, execute _installation_path_\eclipse-main.bat.This will open eclipse. -NOTE: To facilitate this step, you can go from your "_File Explorer_" under `*workspaces/main*` folder and with the right button of the mouse, choose "_Open devonfw CMD shell here_" -image:images/howtos/e2e_gen/image85.png[eclipse devon] +2.Create a project: Navigate in the folder containing the devonfw installation and then to `*workspaces/main*`. Right-click and choose "_Open devonfw CMD shell here_". Next, launch this command in the shell: -Then launch this command from CMD: [source, java] ---- devon java create com.example.domain.myapp ---- -Import the project to eclipse as maven project -image:images/howtos/e2e_gen/image14.png[eclipse devon] +3.In eclipse, import the project as a maven project as specified in the image below: -Click *FINISH* +image:images/howtos/e2e_gen/image14.png[eclipse devon] -Now We have the following 4 projects. +4.Click *FINISH*. Now you should have the following 4 projects: image:images/howtos/e2e_gen/image15.png[eclipse package explorer] -*BEFORE to start to create an Entity class, remember to create the tables, for this POC it's used an H2 Database!* - -[arabic] -Create a new *SQL* *file* (`i.e: V0002__CreateTables_myapp.sql`) inside _`myapp-core`_ , under the folder path _`/myapp-core/src/main/resources/db/migration/1.0`_ and insert the following script: +5.Create a new *SQL* *file* `V0002__CreateTables_myapp.sql` inside _`myapp-core`_ , under the folder path _`/myapp-core/src/main/resources/db/migration/1.0`_ and insert the following script: [source] ---- @@ -62,38 +48,30 @@ PRIMARY KEY (employeeid) ); ---- -*_WARNING 1_*: please note that there in that folder is present only one file, 0001, and you have to add the other files in progressive number order (i.e. 0002)! + -*_WARNING 2_*: please note that there are 2 underscore in the name! +*_WARNING 1_*: In this folder there is only one file (0001). You have to add the other files in progressive number order (i.e. 0002)! + +*_WARNING 2_*: There are 2 underscores in the name! image:images/howtos/e2e_gen/image64.png[SQL file] -[arabic] -Now create another SQL file (`i.e: V0003__PopulateTables-myapp.sql`) and add following script about the INSERT in order to populate the table created before. -The script must be inserted at the same path used before: _`/myapp-core/src/main/resources/db/migration/1.0`_ - -*_WARNING 1_*: please note that there in that folder is present only one file, 0001, and you have to add the other files in progressive number order (i.e. 0003)! + -*_WARNING 2_*: please note that there are 2 underscore in the name! +6.Create another SQL file analogously named `V0003__PopulateTables-myapp.sql` in the same folder and add following script about the INSERT to populate the table created before. Please note the warnings from the previous step here, as well. [source] ---- -INSERT INTO EMPLOYEE (id, modificationCounter, employeeid, name, surname,email) VALUES (1, 1, 1, 'John','Doe','john.doe@example.com'); -INSERT INTO EMPLOYEE (id, modificationCounter, employeeid, name, surname,email) VALUES (2, 2, 2, 'Tom','Smith', 'tom.smith@example.com'); -INSERT INTO EMPLOYEE (id, modificationCounter, employeeid, name, surname,email) VALUES (3, 3, 3, 'Joe','Schmoe', 'joe.schmoe@example.com'); +INSERT INTO EMPLOYEE (id, modificationCounter, employeeid, name, surname,email) VALUES (1, 1, 1, 'John', 'Doe', 'john.doe@example.com'); +INSERT INTO EMPLOYEE (id, modificationCounter, employeeid, name, surname,email) VALUES (2, 2, 2, 'Tom', 'Smith', 'tom.smith@example.com'); +INSERT INTO EMPLOYEE (id, modificationCounter, employeeid, name, surname,email) VALUES (3, 3, 3, 'Joe', 'Schmoe', 'joe.schmoe@example.com'); ---- image:images/howtos/e2e_gen/image65.png[SQL insert] -*Let's create the Entity Class for the code generation* -[arabic] -Create a package ```*employeemanagement.dataaccess.api*``` under the folder _`myapp-core`_. + -Note: It is important to follow this naming convention for CobiGen to work properly. +7.We will now create the Entity Class for the code generation. For this, create a package named `com.example.domain.myapp.employeemanagement.dataaccess.api` in the folder _`myapp-core/src/main/java`_. + +*_WARNING_*: It's important to follow this naming convention to ensure CobiGen is working properly. image:images/howtos/e2e_gen/image66.png[package] -Now create a `JPA` Entity class in this package +Now create a new class named `EmployeeEntity` in this package and paste the code below to turn it into a `JPA` Entity. -[source, java] ---- package com.example.domain.myapp.employeemanagement.dataaccess.api; @@ -116,52 +94,31 @@ public class EmployeeEntity { } ---- -then generate `getters` and `setters` for all attribute, as you can see in the image below: +8.Generate `getters` and `setters` for all attributes, as you can see in the image below: image:images/howtos/e2e_gen/image67.png[`getter & setter`] image:images/howtos/e2e_gen/image68.png[`getter & setter`] -[arabic] -Use CobiGen to generate code. Right click on `EmployeeEntity`. CobiGen -> Generate - -If it will ask you to download the templates, click on _update_: - -image:images/howtos/e2e_gen/image19.png[CobiGen generate] - -It will automatically download the latest version of _CobiGen_Templates_. - -*Attention:* If you want to adapt the CobiGen_Templates, (normally this is not necessary), you will find at the end of this document (in a separate chapter) a tutorial on how to import them and adapt them! - -[arabic] -Click on all the option selected as below: +9.Now we can use CobiGen to generate code! First, right-click in the package explorer on `EmployeeEntity.java` -> `CobiGen` and select `Update Template`. Next, right-click on `EmployeeEntity.java` -> CobiGen -> Generate and tick the boxes as can be seen in the picture: image:images/howtos/e2e_gen/image20.png[CobiGen option selection] -[arabic] -Click on finish. Below Screen would be seen. Click on continue - -image:images/howtos/e2e_gen/image21.png[CobiGen finish] - -*The entire [.underline]#`BE` layer# structure having `CRUD` operation methods will be auto generated.* - -Some classes will be generated on the API part (_`myapp-api`)_, normally it will be interfaces, as shown below: +10.Click on *Finish* to complete the process. *The entire [.underline]#`BE` layer# structure including `CRUD` operation methods was auto generated.* + +Some classes are generated in the API part (_`myapp-api`)_, e.g. interfaces, as shown below: image:images/howtos/e2e_gen/image22.png[be layer] -Some other classes will be generated on the core part (_`myapp-core`)_, normally it will be implementations as shown below: +Other classes are generated in the core part (_`myapp-core`)_, like implementations, as shown below: image:images/howtos/e2e_gen/image23.png[core folder] -[arabic] -The last step is to add the Cross Domain process, because when you are developing JavaScript client and server application separately, you have to deal with cross domain issues. - -So, we need to prepare server side to accept request from other domains. We need to cover the following points: +11.The last step is to add the cross-domain process, as we are developing the JavaScript client and the server application separately. For this, we need to prepare the server side to accept requests from other domains, covering the following points: * Accept request from other domains. * Accept devonfw used headers like `X-CSRF-TOKEN` or `correlationId`. * Be prepared to receive secured request (cookies). -To do this it's necessary to add two kind of dependencies in the pom.xml of the _`myapp-core`_ folder, at the end of the list of dependencies: +Add these two kind of dependencies in the pom.xml of the _`myapp-core`_ folder, at the end of the list of dependencies: [source, xml] ---- @@ -177,7 +134,7 @@ To do this it's necessary to add two kind of dependencies in the pom.xml of the image:images/howtos/e2e_gen/image70.png[pom xml] -Next step is to add some properties under your _application.properties_ file, in the `myapp-core` folder in the _resources/config_: +12.Add these properties in your _application.properties_ file, in the `myapp-core` folder in the _resources/config_: [source, properties] ---- @@ -190,121 +147,72 @@ security.cors.pathPattern=/** image:images/howtos/e2e_gen/image71.png[application properties] -*BEFORE to generate the `FE`*, please start the Tomcat server to check that `BE` Layer has been generated properly. - -To start a server you just have to right click on _`SpringBootApp.java`_ -> _run as -> Java Application_ - -image:images/howtos/e2e_gen/image24.png[Eclipse run as] +13.To check if the `BE` layer has been generated properly, start the server by right-clicking on _`SpringBootApp.java`_ -> _run as -> Java Application_. If it looks like the image below, the `BE` part is done! image:images/howtos/e2e_gen/image69.png[Spring boot run] image:images/howtos/e2e_gen/image26.png[Spring boot run] -*`BE` DONE* - -Last but not least: We make a quick REST services test ! - -See in the _application.properties_ the TCP Port and the `PATH` - -image:images/howtos/e2e_gen/image27.png[application properties] - -Now compose the Rest service URL: +Optional step: + +14.To test if the `Backend` works properly, we perform a REST service test! For this, we use Postman. You can download it https://www.postman.com/downloads/[here]. + -*service class /* - -* refers to server with port no. (i.e: `localhost:8081`) -* is in the _application.properties_ (empty in our case, see above) -* refers to `EmployeemanagementRestService`: (i.e: `/employeemanagement/v1`) -* /employee/\{id} (i.e: for `getEmployee` method) - -image:images/howtos/e2e_gen/image28.png[URL mapping] - -URL of `getEmployee` for this example is: - -For all employees (`POST`) -[source, URL] ----- -http://localhost:8081/services/rest/employeemanagement/v1/employee/search ----- - -For the specific employee (`GET`) -[source, URL] +First send a POST request for the body with the URL [source, URL]. ---- http://localhost:8081/services/rest/employeemanagement/v1/employee/1 ---- -Now download https://www.getpostman.com/apps[Postman] to test the rest services. - -Once done, you have to create a `POST` Request for the LOGIN and insert in the body the JSON containing the username and password _admin_ - -image:images/howtos/e2e_gen/image72.png[postman] - -*_WARNING_*: please note that the body of the request must be JSON type! +Under `Body`, insert the JSON containing -Once done with success (*Status: 200 OK*) - _you can see the status of the response in the top right corner of Postman_ - we can create a NEW `GET` Request in order to get one employee. -To do this you have to create a new request in Postman, `GET` type, and insert the URL specified before: +---- +{ + "j_username":"admin", + "j_password":"admin" +} +---- +Click on send. "Status:200 OK" means it worked. + +Next, we create a new request, this time `GET` type with the URL [source, URL] ---- http://localhost:8081/services/rest/employeemanagement/v1/employee/1 ---- - -Then click on *"SEND"* button... - -Now you have to check that response has got *Status: 200 OK* and to see the below Employee +Click on send. If you get "Status:200 OK" again and see employee "John Doe" as you can see in the image below, the Backend works fine! image:images/howtos/e2e_gen/image73.png[postman] -Now that We have successfully tested the `BE` is time to go to create the `FE` ! - === Frontend -Let’s start now with angular Web and then Ionic app. +Let's start with the Frontend! We want to create an *Angular Web App*: -==== Angular Web App -[arabic] -To generate angular structure, download or clone *devon4ng-application-template* from +1.To generate angular structure, download or clone *devon4ng-application-template* from [source, URL] https://github.com/devonfw/devon4ng-application-template image:images/howtos/e2e_gen/image74.png[devon dist folder] -[arabic] -IMPORTANT when you download the zip of the source code of your `FE` application, the name of the app MUST BE *devon4ng-application-template* and you can extract it in your devonfw folder, under `_workspaces/main_` +*IMPORTANT* if you download the zip of the source code, the name of the app MUST BE *devon4ng-application-template*. Extract it into your devonfw folder, under `_workspaces/main_`. -Once downloaded the `APP`, you can open the application with your favorite IDE (IntelliJ, Visual Studio Code, ...) + -Instead, if you want to open this project with Eclipse, you have to follow these steps: + -[arabic] -. Right click on the left part of Eclipse, and click on "Import": +2.After downloading the `APP`, open the application in Eclipse. For this, right click on the left part of Eclipse and click "Import" + image:images/howtos/e2e_gen/image83.png[import] -. Click on "Projects from Folder or Archive" +Then choose "Projects from Folder or Archive": + image:images/howtos/e2e_gen/image82.png[import] -. Select your folder where you have saved the Angular `FE` Application, under `_workspaces/main_`. Wait that all the dependencies are charged and then click on "Finish" +Select the folder containing the Angular `FE` Application, under `_workspaces/main_`.Click on *Finish* after all dependencies have been loaded. image:images/howtos/e2e_gen/image84.png[import] -. At the end, you will have a structure like this: +Now, you should have a structure like this: image:images/howtos/e2e_gen/image86.png[import] -[arabic] -Once done, right click on `EmployeeEto`.java file present under the `package _com.devonfw.poc.employeemanagement.logic.api.to_`, in the Backend part (_`myapp-core_ module`). -Click on the selected options as seen in the screenshot: +3.Right click on `EmployeeEto`.java file in the package `_com.example.domain.myapp.employeemanagement.logic.api.to_`, in the `BE` part (_`myapp-api_ module`). Choose `Cobigen -> Generate` and select the options as seen in the screenshot and click on *Finish*: image:images/howtos/e2e_gen/image37.png[eclipse generate] -[arabic] -Click on Finish - -image:images/howtos/e2e_gen/image38.png[eclipse] - -[arabic] -The entire `ANGULAR` structure has been auto generated. The generated code will be merged to the existing. +4.The entire `ANGULAR` structure has been auto generated and the generated code was merged into already existing code. image:images/howtos/e2e_gen/image39.png[angular `ee` layer] -[arabic] -IMPORTANT now you have to check in the *_app-routing.module.ts_* file, if the content corresponding to the code below: +The *_app-routing.module.ts_* file (in `src/app`) should correspond to the code below, so copy the code and replace the existing content in your file with this: [source, ts] ---- @@ -361,7 +269,7 @@ export class AppRoutingModule { } ---- -After that, if you want to make visible the Employee Grid in you `FE` application, you have to modify the `nav-bar.component.html`, to add the Employee grid in the section: +5.To make the Employee Grid in you `FE` application visible, you have to replace the code in `nav-bar.component.html` with the code below: [source, HTML] ---- @@ -409,21 +317,18 @@ After that, if you want to make visible the Employee Grid in you `FE` applicatio ---- -[arabic] -Open the command prompt and execute _devon npm install_ from your application folder (`_workspaces/main/devon4ng-application-template_`), which would download all the required libraries. +6.Open the devon CMD shell and execute `devon npm install` in `_workspaces/main/devon4ng-application-template_`, which will download all the required libraries. -[arabic] -Check the file *environment.ts* if the server path is correct. (for production you will have to change also the environment.prod.ts file) +7.Check in the file *environment.ts* (in `src/app/environments`) if the server path is correct. image:images/howtos/e2e_gen/image42.png[environment] -In order to do that, it’s important to look at the application.properties to see the values as `PATH`, TCP port etc... +The values `PATH`, TCP port etc. in application.properties should match the image below. Set the security field to *CSRF* , if it is not configured this way already image:images/howtos/e2e_gen/image43.png[configure] -For example in this case the URL should be since the context path is empty the server `URLS` should be like: - [source, ts] + ---- export const environment = { production: false, @@ -433,15 +338,13 @@ export const environment = { }; ---- -*Warning*: REMEMBER to set security filed to *CSRF* , if it is not configured already. -[arabic] -Now run the `*devon ng serve -o*` command to run the Angular Application, from your application folder (`_workspaces/main/devon4ng-application-template_`), as done before. + +8.For the last steps, the `BE` server should be running. Then run `*devon ng*` and then `*devon ng serve -o*` to start the Angular Application, in a CMD shell in your application folder (`_workspaces/main/devon4ng-application-template_`). image:images/howtos/e2e_gen/image75.png[ng serve command] -[arabic] -If the command execution is *successful*, the below screen will *appear* and it would be automatically redirected to the URL: +9.If the command execution is *successful*, the screen shown below will appear and you would be automatically redirected to the URL: [source, URL] ---- @@ -450,126 +353,8 @@ http://localhost:4200/login image:images/howtos/e2e_gen/image77.png[angular web app] -You can login in the Web Application, with *_admin_* user and password. + -Obviously, the `BackEnd` part must be up & running during this test! - -*`ANGULAR WebApp DONE`* - - -==== Ionic Mobile App - -[arabic] -To generate Ionic structure, download or clone _*devon4ng-application-template*_ from -[source, URL] ----- -https://github.com/devonfw/devon4ng-ionic-application-template ----- - -[arabic] -IMPORTANT when you download the zip of the source code of your `FE` application, the name of the app MUST BE *devon4ng-ionic-application-template* and you can extract it in your devonfw folder, under `_workspaces/main_` - -Once downloaded the `APP`, you can open the application with your favorite IDE (IntelliJ, Visual Studio Code, ...) + -Instead, if you want to open this project with Eclipse, you have to follow these steps: + -[arabic] -. Right click on the left part of Eclipse, and click on "Import": -image:images/howtos/e2e_gen/image83.png[import] -. Click on "Projects from Folder or Archive" -image:images/howtos/e2e_gen/image82.png[import] -. Select your folder where you have saved the Angular `FE` Application, under `_workspaces/main_`. Wait that all the dependencies are charged and then click on "Finish" -image:images/howtos/e2e_gen/image84.png[import] -. At the end, you will have a structure like this: -image:images/howtos/e2e_gen/image86.png[import] - -Once done, Right click on the *`EmployeeEto`* as you already did before in order to use CobiGen. -Click on the selected options as seen in the screenshot: - -image:images/howtos/e2e_gen/image46.png[CobiGen ionic] - -[arabic] -Click on Finish + -The entire ionic structure will be auto generated. - -image:images/howtos/e2e_gen/image47.png[] - -[arabic] -Change (if necessary) the server URL (with correct serve URL) in _environment.ts_, _environment.prod.ts_ and _environment.android.ts_ files (i.e: `itapoc\devon4ng-ionic-application-template\src\environments\`). - -The `_angular.json_` file inside the project has already a build configuration for android. - -image:images/howtos/e2e_gen/image48.png[] - -The only *TWO* thing that you have to modify, in this IONIC app is in `_employee-list.page.html_` and _business-operator.service.ts_.y + - -*1:* + -You have to change this line: -[source,HTML] - - -with this line: -[source,HTML] - - - -*2:* + -You have to change this line: -[source,ts] ----- -return this.restPath + '/security/v1/csrftoken'; ----- - -with this line: -[source,ts] ----- -return this.restPath + 'csrf/v1/token/'; ----- - -[arabic] -Once checked if all the files are correct, open a CMD devon CLI on the folder of the ionic template application (`_workspaces/main/devon4ng-ionic-application-template_`), under your `devonFW` workspace. + -In this folder: + -Run the command _*devon npm install*_ in the root folder to download the dependencies. + -Once finished, run the command _*devon ionic serve*_ - -image:images/howtos/e2e_gen/image49.png[] - -Once the execution is successful, you can make the LOGIN with *admin/admin* and... - -image:images/howtos/e2e_gen/image50.png[] - -*IONIC Mobile App DONE* - -So: *Well Done!!!* - -`*Starting from an Entity class you have successfully generated the Backend layer (REST, SOAP, `DTO`, Spring services, `Hibernate DAO`), the Angular Web App and the Ionic mobile App!*` - -image:images/howtos/e2e_gen/image51.png[] - - -===== Build `APK` - -Since We’re going to create apk remember the following preconditions: - -* https://gradle.org/install/[Gradle] -* https://developer.android.com/studio[Android Studio] -* https://developer.android.com/studio/#command-tools[Android SDK] -* https://capacitor.ionicframework.com/docs/getting-started/[Capacitor] - - -[arabic] -Now, open CMD and type the path where your _devon4ng-ionic-application-template_ project is present. + -Run the following commands: - -. npx cap init -. ionic build --configuration=android -. npx cap add android -. npx cap copy -. npx cap open android +To log into the web application, you can use the credentials *admin* for user and for password. + -Build the `APK` using Android studio. -image:images/howtos/e2e_gen/image52.png[] -image:images/howtos/e2e_gen/image53.png[] -image:images/howtos/e2e_gen/image54.png[] -image:images/howtos/e2e_gen/image55.png[] +Now the *`ANGULAR WebApp`* is done! -You can find your apk file in: -_/devon4ng-ionic-application-template/android/app/build/outputs/apk/debug_ diff --git a/documentation/howto_create-external-plugin.asciidoc b/documentation/howto_create-external-plugin.asciidoc index f3bbea4954..c98c457534 100644 --- a/documentation/howto_create-external-plugin.asciidoc +++ b/documentation/howto_create-external-plugin.asciidoc @@ -123,7 +123,7 @@ image::images/howtos/todo-plugin/pluginActivator.png[Plugin activator,width="450 * Finally, we will change some properties from the `pom.xml` of the project. These properties define the server (external process) that is going to be used: -.. Inside `pom.xml`, press _Ctrl + F_ to perform a find and replace operation. Replace all `todo` with your plugin name: +.. Inside `pom.xml`, press `Ctrl + F` to perform a find and replace operation. Replace all `todo` with your plugin name: + image::images/howtos/todo-plugin/setPomProperties.png[Pom properties,width="550"link="images/howtos/todo-plugin/setPomProperties.png"] @@ -131,17 +131,17 @@ image::images/howtos/todo-plugin/setPomProperties.png[Pom properties,width="550" ... `artifactId`: This is the name of your plug-in, that will be used for a future release on Maven Central. -... plugin.name: does not need to be changed as it uses the property from the `artifactId`. When connecting to the server, it will send a request to `localhost:5000/{plugin.name}plugin/isConnectionReady`, that is why it is important to use an unique name for the plug-in. +... `plugin.name`: does not need to be changed as it uses the property from the `artifactId`. When connecting to the server, it will send a request to `localhost:5000/{plugin.name}plugin/isConnectionReady`, that is why it is important to use an unique name for the plug-in. -... server.name: This defines how the server executable (_.exe_) file will be named. This _.exe_ file contains all the needed resources for deploying the server. You can use any name you want. +... `server.name`: This defines how the server executable (_.exe_) file will be named. This _.exe_ file contains all the needed resources for deploying the server. You can use any name you want. -... server.version: You will specify here the server version that needs to be used. The _.exe_ file will be named as `{server.name}-{server.version}.exe`. +... `server.version`: You will specify here the server version that needs to be used. The _.exe_ file will be named as `{server.name}-{server.version}.exe`. -... server.url: This will define from where to download the server. We *really* recommend you using NPM which is a package manager we know it works well. We explain <> how to release the server on NPM. This will download the _.exe_ file for Windows. +... `server.url`: This will define from where to download the server. We *really* recommend you using NPM which is a package manager we know it works well. We explain <> how to release the server on NPM. This will download the _.exe_ file for Windows. -... server.url.linux: Same as before, but this should download the _.exe_ file for Linux systems. If you do not want to implement a Linux version of the plug-in, just use the same URL from Windows or MacOS. +... `server.url.linux`: Same as before, but this should download the _.exe_ file for Linux systems. If you do not want to implement a Linux version of the plug-in, just use the same URL from Windows or MacOS. -... server.url.macos: Same as before, but this should download the _.exe_ file for MacOS systems. If you do not want to implement a MacOS version of the plug-in, just use the same URL from Linux or Windows. +... `server.url.macos`: Same as before, but this should download the _.exe_ file for MacOS systems. If you do not want to implement a MacOS version of the plug-in, just use the same URL from Linux or Windows. [[testing_phase]] == Testing phase @@ -174,7 +174,7 @@ image::images/howtos/todo-plugin/useServerTemplate.png[Server CobiGen template,w * Name your repo as `cobigen-name-server` where `name` can be python, rust, go... In our case we will create a `nest` plug-in. It will create a repo with only one commit which contains all the needed files. -* Clone your just created repo and go to folder `cobigen-todo-server`. It will just contain two files: _ExternalProcessContract.yml_ is the OpenAPI definition which you can modify with your own server definition (this step is optional), and _package.json_ is a file needed for NPM in order to define where to publish this package: +* Clone your just created repo and go to folder `cobigen-todo-server`. It will just contain two files: `ExternalProcessContract.yml` is the OpenAPI definition which you can modify with your own server definition (this step is optional), and `package.json` is a file needed for NPM in order to define where to publish this package: + ```JSON { @@ -252,7 +252,7 @@ image::images/howtos/todo-plugin/templatesProject.png[Templates project,width="4 + image::images/howtos/todo-plugin/templatesInside.png[Templates project,width="450"link="images/howtos/todo-plugin/templatesInside.png"] -* Start creating your own templates. Our default templates language is Freemarker, but you can also use Velocity. Add the extension to the file (`.ftl`) and start developing templates! You can find useful documentation link:https://github.com/devonfw/cobigen/wiki/cobigen-templates_helpful-links[here]. +* Start creating your own templates. Our default templates language is FreeMarker, but you can also use Velocity. Add the extension to the file (`.ftl`) and start developing templates! You can find useful documentation link:https://github.com/devonfw/cobigen/wiki/cobigen-templates_helpful-links[here]. * After creating all the templates, you need to modify `context.xml` which is located on the root of `src/main/templates`. There you need to define a trigger, which is used for CobiGen to know when to trigger a plug-in. I recommend you to copy and paste the following trigger: diff --git a/documentation/master-cobigen.asciidoc b/documentation/master-cobigen.asciidoc index fbdaa85d58..228a01a1d9 100644 --- a/documentation/master-cobigen.asciidoc +++ b/documentation/master-cobigen.asciidoc @@ -4,49 +4,6 @@ == Document Description This document contains the documentation of the CobiGen core module as well as all CobiGen plug-ins and the CobiGen eclipse integration. -[IMPORTANT] --- -DISCLAIMER: All CobiGen plugins are compatible with the latest release of Devonfw unless otherwise denoted. --- - -**Current versions:** - -* CobiGen - Eclipse Plug-in v7.1.0 -* CobiGen - Maven Build Plug-in v7.1.0 -* CobiGen CLI v1.2.0 - ---- - -* CobiGen v7.1.0 -* CobiGen - Java Plug-in v7.1.0 -* CobiGen - XML Plug-in v7.0.0 -* CobiGen - TypeScript Plug-in v7.1.0 -* CobiGen - Property Plug-in v7.1.0 -* CobiGen - Text Merger v7.1.1 -* CobiGen - JSON Plug-in v7.0.0 -* CobiGen - HTML Plug-in v7.0.0 -* CobiGen - Open API Plug-in v7.1.0 -* CobiGen - FreeMarker Template Engine v7.0.0 -* CobiGen - Velocity Template Engine v7.0.0 - -**Authors:** - -``` -* Malte Brunnlieb -* Jaime Diaz Gonzalez -* Steffen Holzer -* Ruben Diaz Martinez -* Joerg Hohwiller -* Fabian Kreis -* Lukas Goerlach -* Krati Shah -* Christian Richter -* Erik Grüner -* Mike Schumacher -* Marco Rose -* Mohamed Ghanmi -``` - include::Guide-to-the-Reader.asciidoc[leveloffset=3] include::Home.asciidoc[leveloffset=3] diff --git a/documentation/mgmt__release_and_deployment_process.asciidoc b/documentation/mgmt__release_and_deployment_process.asciidoc index 79f7351e3c..64bd98aa32 100644 --- a/documentation/mgmt__release_and_deployment_process.asciidoc +++ b/documentation/mgmt__release_and_deployment_process.asciidoc @@ -122,7 +122,7 @@ If every of these test scenarios are checked out, then release process can conti To properly test the Ionic and Angular templates we need to follow the next steps: -* Copy the _jwtsample_ project from the worskpaces/examples folder and paste it to the workspaces/main folder, then import it into your workspace. +* Copy the `jwtsample` project from the `workspaces/examples` folder and paste it to the `workspaces/main` folder, then import it into your workspace. * Add to the database of the project the following SQL script, so that we can test the retrieval of data. ```SQL @@ -185,7 +185,7 @@ public class EmployeeEntity { } ``` -* Using the EmployeeEntity, generate increments `CRUD DAO'S, CRUD REST services, CRUD SOAP services, CRUD logic (all in one), Entity infrastructure and TO's`. After generating, follow first the following tutorial related to link:howto_ionic-client-generation#generation[Ionic Client Generation] and afterwards the link:howto_angular-client-generation#generating[Angular tutorial]. +* Using the `EmployeeEntity`, generate increments `CRUD DAO'S, CRUD REST services, CRUD SOAP services, CRUD logic (all in one), Entity infrastructure and TO's`. After generating, follow first the following tutorial related to link:howto_ionic-client-generation#generation[Ionic Client Generation] and afterwards the link:howto_angular-client-generation#generating[Angular tutorial]. * The final step before releasing should be creating an issue with the following Markdown template. If every test scenario is completed, then testing phase is over and you can release. diff --git a/documentation/setup-jre.asciidoc b/documentation/setup-jre.asciidoc deleted file mode 100644 index a35cb2bbe8..0000000000 --- a/documentation/setup-jre.asciidoc +++ /dev/null @@ -1,18 +0,0 @@ -= Set up JRE for development - -CobiGen is supposed to support both java 8 and java 11 even though we are moving to 11. Here is a short description of how to setup the execution environment for developing so that you can test both environments. - -By default, CobiGen development tools come with some installed JREs in `/software/java (11)` and `/software/java/additionalJdk (7 and 8)` - -image:documentation/images/howtos/setup-jre/installed-jre.PNG[] - -In CobiGen, there is a fixed setup of JAVASE-1.8 in maven, which leads to the odd that no matter which Java is currently used, eclipse keeps showing JAVASE-1.8. A temporary reconfiguration of JRE in build path will also be overwritten by a maven update. - -image:documentation/images/howtos/setup-jre/java-11.PNG[] - -Eclipse has a fixed list of execution environments, which is automatically matched with the current most suitable installed JRE, in our case JDK-8 by default. The matching JRE is the actual one, which is used to compile no matter which name eclipse shows - -image:documentation/images/howtos/setup-jre/execution-environments.PNG[] - -As that, to move to 11, just setup the match JRE of JAVASE-1.8 to 11 or any version you need - From 21f28e262ab7caacac210dd59aedebc93e15cd78 Mon Sep 17 00:00:00 2001 From: Malte Brunnlieb Date: Tue, 3 Jan 2023 14:38:21 +0100 Subject: [PATCH 10/12] updated actions/checkout to v3 --- .github/workflows/maven-build-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven-build-test.yml b/.github/workflows/maven-build-test.yml index 3d1bee1c6e..995bc4b748 100644 --- a/.github/workflows/maven-build-test.yml +++ b/.github/workflows/maven-build-test.yml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Clone Repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - uses: devonfw-actions/java-maven-setup@main with: From e361523cc9cd267f7f91a15d4df991fdf2910dc5 Mon Sep 17 00:00:00 2001 From: Malte Brunnlieb Date: Tue, 3 Jan 2023 14:41:47 +0100 Subject: [PATCH 11/12] run spellchecker only on changed asciidoc files --- .github/workflows/spellchecker.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/spellchecker.yml b/.github/workflows/spellchecker.yml index 1010d6c170..3a807b3666 100644 --- a/.github/workflows/spellchecker.yml +++ b/.github/workflows/spellchecker.yml @@ -1,6 +1,9 @@ name: spellcheck on: push: + paths: + - '**.asciidoc' + - '**.adoc' workflow_dispatch: jobs: spellchecker: From 5b1a887cc0773676de3820143b00b93425d0958e Mon Sep 17 00:00:00 2001 From: Malte Brunnlieb Date: Wed, 4 Jan 2023 08:00:34 +0100 Subject: [PATCH 12/12] Update README.asciidoc --- README.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.asciidoc b/README.asciidoc index 448ebd5de8..ab439dcfed 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -2,7 +2,7 @@ = CobiGen (Code-based incremental Generator) -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"] +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"] == Usage