Skip to content
devonfw-core edited this page Sep 7, 2022 · 41 revisions

CobiGen - Code-based incremental Generator

Overview

CobiGen is a generic incremental generator for end-to-end code generation tasks, mostly used in Java projects. Due to a template-based approach, CobiGen generates any set of text-based documents and document fragments.

Input (currently):

  • Java classes

  • XML-based files

  • OpenAPI documents

  • Possibly more inputs like WSDL, which is currently not implemented.

Output:

  • any text-based document or document fragments specified by templates

Architecture

CobiGen is build as an extensible framework for incremental code generation. It provides extension points for new input readers which allow reading new input types and converting them to an internally processed model. The model is used to process templates of different kinds to generate patches. The template processing will be done by different template engines. There is an extension point for template engines to support multiple ones as well. Finally, the patch will be structurally merged into potentially already existing code. To allow structural merge on different programming languages, the extension point for structural mergers has been introduced. Here you will see an overview of the currently available extension points and plug-ins:

Features and Characteristics

  • Generate fresh files across all the layers of an application - ready to run.

  • Add on to existing files merging code into it. E.g. generate new methods into existing Java classes or adding nodes to an XML file. Merging of contents into existing files will be done using structural merge mechanisms.

  • Structural merge mechanisms are currently implemented for Java, XML, Java Property Syntax, JSON, Basic HTML, Text Append, TypeScript.

  • Conflicts can be resolved individually but automatically by former configuration for each template.

  • CobiGen provides an Eclipse integration as well as a Maven integration.

  • CobiGen comes with an extensive documentation for users and developers.

  • Templates can be fully tailored to project needs - this is considered as a simple task.

Selection of current and past CobiGen applications

General applications:

  • Generation of a Java CRUD application based on devonfw architecture including all software-layers on the server plus code for JS-clients (Angular). You can find details here.

  • Generation of a Java CRUD application according to the Register Factory architecture. Persistence entities are the input for generation.

  • Generation of builder classes for generating test data for JUnit-Tests. Input are the persistence entities.

  • Generation of an Angular 13 client with full CRUD operations connected to a devon4j server based on devon4ng application template.

  • Generation of an Ionic client with full CRUD operations connected to a devon4j server based on devon4ng Ionic template.

Project-specific applications in the past:

  • Generation of an additional Java type hierarchy on top of existing Java classes in combination with additional methods to be integrated in the modified classes. Hibernate entities were considered as input as well as output of the generation. The rational in this case, was to generate an additional business object hierarchy on top of an existing data model for efficient business processing.

  • Generation of hash- and equals-methods as well as copy constructors depending on the field types of the input Java class. Furthermore, CobiGen is able to re-generate these methods/constructors triggered by the user, i.e, when fields have been changed.

  • Extraction of JavaDoc of test classes and their methods for generating a csv test documentation. This test documentation has been further processed manually in Excel to provide a good overview about the currently available tests in the software system, which enables further human analysis.

Clone this wiki locally