Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JNG-5602 Add JSL project generator templat (crash on frontend generat… #1

Merged
merged 2 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 152 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# judo-jsl-fullstack-karaf-project-template

JSL based JUDO karaf backend / frontend project archetype

It can be used as:

[code, xml]
----
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>hu.blackbelt.judo.template</groupId>
<artifactId>judo-jsl-fullstack-karaf-project-template-example</artifactId>
<version>${revision}</version>
<packaging>pom</packaging>

<name>JUDO JSL Generator test</name>
<description>JUDO JSL Fullstack Karaf Project Archetype Example.</description>

<properties>
<revision>1.0.0-SNAPSHOT</revision>
<maven>3.9.4</maven>

<slf4j-version>2.0.7</slf4j-version>
<log4j.configuration>log4j.properties</log4j.configuration>

<judo-meta-jsl-version>1.0.0.20221123_203333_b8ff8102_develop</judo-meta-jsl-version>
<judo-tatami-jsl-version>1.1.0.20221130_232047_4e092061_develop</judo-tatami-jsl-version>

<structured-map-proxy-version>1.2.0</structured-map-proxy-version>
<judo-dao-api-version>1.0.3</judo-dao-api-version>
<judo-dispatcher-api-version>1.0.2</judo-dispatcher-api-version>
<judo-sdk-common-version>1.0.2</judo-sdk-common-version>
<mapper-version>1.0.3</mapper-version>

<judo-platform-version>2.0.1.20221201_123317_7aaf1bb6_develop</judo-platform-version>
<judo-services-version>1.1.0.20221201_102536_3fc7de65_develop</judo-services-version>
<judo-rdbms-schema-version>1.0.0.20221130_231648_bcdcd861_develop</judo-rdbms-schema-version>
<judo-jsl-fullstack-karaf-project-template-version>1.0.0-SNAPSHOT</judo-jsl-fullstack-karaf-project-template-version>

<!-- Frontend -->

<frontend-type>react</frontend-type>

<!-- React -->
<node-version-defined>18.16.0</node-version-defined>
<pnpm-version-defined>8.6.1</pnpm-version-defined>
<judo-meta-ui-version-defined>1.0.0.20220618_232754_311274d9_develop</judo-meta-ui-version-defined>
<judo-ui-archetype-version-defined>1.0.0.20221003_142712_453def5b_develop</judo-ui-archetype-version-defined>
<judo-tatami-ui2web-version-defined>1.0.0.20230117_190258_43070f4d_develop</judo-tatami-ui2web-version-defined>
<judo-tatami-ui2typescript-maven-plugin-version-defined>1.0.0.20230117_190258_43070f4d_develop</judo-tatami-ui2typescript-maven-plugin-version-defined>
<judo-tatami-ui-external-packages-version-defined>1.0.0.20230117_190258_43070f4d_develop</judo-tatami-ui-external-packages-version-defined>
robertcsakany marked this conversation as resolved.
Show resolved Hide resolved

<appScope>@example</appScope>
<appVersion>1.0.0</appVersion>
<defaultLanguage>en</defaultLanguage>
<tablePageLimit>10</tablePageLimit>
</properties>

<build>
<plugins>
<plugin>
<groupId>hu.blackbelt.judo.meta</groupId>
<artifactId>judo-jsl-generator-maven-plugin</artifactId>
<version>${judo-meta-jsl-version}</version>
<executions>
<execution>
<id>execute-jsl-test-model-from-artifact</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<uris>
<uri>mvn:hu.blackbelt.judo.template:judo-jsl-fullstack-karaf-project-template:${judo-jsl-fullstack-karaf-project-template-version}</uri>
</uris>
<helpers>
<helper>hu.blackbelt.judo.jsl.fullstack.project.archetype.JslDslProjectHelper</helper>
</helpers>
<type>fullstack-project</type>
<destination>${basedir}/target/classes</destination>
<templateParameters> <!-- 1 -->
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>

<modelGroupId>${project.groupId}</modelGroupId>
<modelArtifactId>${project.artifactId}-test-model</modelArtifactId>
<modelVersion>${project.version}</modelVersion>

<sqlDialects>hsqldb</sqlDialects>
<ignoreOpenAPI>true</ignoreOpenAPI>
<validateModels>false</validateModels>

<structuredMapProxyVersion>${structured-map-proxy-version}</structuredMapProxyVersion>
<judoDaoApiVersion>${judo-dao-api-version}</judoDaoApiVersion>
<judoDispatcherApiVersion>${judo-dispatcher-api-version}</judoDispatcherApiVersion>
<judoSdkCommonVersion>${judo-sdk-common-version}</judoSdkCommonVersion>
<mapperVersion>${mapper-version}</mapperVersion>

<judoTatamiJslVersion>${judo-tatami-jsl-version}</judoTatamiJslVersion>
<judoPlatformVersion>${judo-platform-version}</judoPlatformVersion>
<judoServicesVersion>${judo-services-version}</judoServicesVersion>
<judoRdbmsSchemaVersion>${judo-rdbms-schema-version}</judoRdbmsSchemaVersion>

<!-- Frontend -->

<frontendType>${frontend-type}</frontendType>

<!-- React -->

<nodeVersion>${node-version-defined}</nodeVersion>
<pnpmVersion>${pnpm-version-defined}</pnpmVersion>
<judoMetaUIVersion>${judo-meta-ui-version-defined}</judoMetaUIVersion>
<judoUIArchetypeVersion>${judo-ui-archetype-version-defined}</judoUIArchetypeVersion>
<judoTatamiUI2WebVersion>${judo-tatami-ui2web-version-defined}</judoTatamiUI2WebVersion>
<judoTatamiUI2TypeScriptMavenPluginVersion>${judo-tatami-ui2typescript-maven-plugin-version-defined}</judoTatamiUI2TypeScriptMavenPluginVersion>
<judoTatamiUIExternalPackagesVersion>${judo-tatami-ui-external-packages-version-defined}</judoTatamiUIExternalPackagesVersion>

<appScope>${appScope}</appScope> <!-- optional -->
<appVersion>${appVersion}</appVersion>
<defaultLanguage>${defaultLanguage}</defaultLanguage> <!-- optional, default: en-US -->
<muiLicensePlan>${muiLicensePlan}</muiLicensePlan> <!-- optional, default: community -->
<tablePageLimit>${tablePageLimit}</tablePageLimit> <!-- optional, default: 10 -->
</templateParameters>
</configuration>
</execution>
</executions>

<dependencies>
<dependency>
<groupId>hu.blackbelt.judo.template</groupId>
<artifactId>judo-jsl-fullstack-karaf-project-template</artifactId>
<version>${judo-jsl-fullstack-karaf-project-template-version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
----

This example generates a complete project setup into `target/classes` directory.
In a project this generation can be placed in the model project as a
profile.

The `judo-jsl-archetype-maven-plugin` documentation is placed inside
the plugin documentation itself. https://github.com/BlackBeltTechnology/judo-jsl-archetype

<1> All the template parameters are mandatory, because that's used for
project template's version definitions.

24 changes: 24 additions & 0 deletions judo-jsl-fullstack-karaf-project-template-application/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>hu.blackbelt.judo.template</groupId>
<artifactId>judo-jsl-fullstack-karaf-project-template-parent</artifactId>
<version>${revision}</version>
</parent>
<artifactId>judo-jsl-fullstack-karaf-project-template-application</artifactId>
<packaging>bundle</packaging>

<name>JUDO JSL Fullstack Karaf Project Application Template</name>
<description>JUDO JSL Fullstack Karaf Project Application Template. Helps create project skeletons.</description>

<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
= {{ model.name }} Application

== Using the generated application

This application is generated from the model defined in the upper directory or the given consumed model.

To compile and run project use `judo.sh` script. Linux and MacOS are supported. Maybe it works with WSL2, but it's not
tested, and it can have poor performance. For more details please run `./judo.sh --help`

=== Prerequisite

==== Docker
Most commands rely on Docker, therefore it is expected to be installed. The `judo.sh` will install the required tools with https://sdkman.io/[sdkman].

[source,]
----
docker run --user $RANDOM:$RANDOM --rm hello-world
----

==== Maven

To work with the model we have to set up the distribution repository in your `~/.m2/settings.xml`

[source,]
----
<server>
<id>{{ lowerCase model.name }}-distribution</id>
<username>YOURUSER</username>
<password>YOURPASS</password>
</server>
----

=== Build application
To build the application, execute

[source,]
----
./judo.sh build
----


=== Start the application
After build it can be started

[source,]
----
./judo.sh start
----

The commands can be chained:

[source,]
----
./judo.sh build start
----


=== Stop the application
After start or reckless, karaf is not terminated automatically. To stop type:

[source,]
----
./judo.sh stop
----

=== Check status
To check the running instances, use:

[source,]
----
./judo.sh status
----

=== Reckless mode
There are several situations when minimal change performed on model. To decrease the model-to-deploy time the reckless
command can be used. It will enable caching, disabling validation to perform maximum speed. It causes sometimes
errors. On that case it can be fixed with a `build`.

[source,]
----
./judo.sh reckless
----

=== Compile with maven

To create and package karaf service, run:

[source,]
----
mvn clean install
----

It uses the model version and frontend version defined in `pom.xml`.
In development sometimes other version is required (for example locally compiled JSL) On that case `model-version` and `frontend-version` can be overridden.

[source,]
----
mvn clean install -Dmodel-version=1.0.0-SNAPSHOT -Dfrontend-version=1.0.0-SNAPSHOT
----

== Profiles


- `build-model`
+
The backend models are transformed by default. If there was no change, it can be ignored.
To skip backend model transformations, use the system property: -DskipBackendModels

- `build-schema`
+
The backend schema is used to create migration scripts. It is created by default.
When you are testing with hsqldb or using empty database, it can be skipped.
To skip schema evolution script generations, use the system property: -DskipSchema

- `build-sdk`
+
The SDK can be generated from model. It is generated by default.
It is used to implement functions in Java. To build karaf it have to be compiled.
To skip SDK generations, use the system property: -DskipSDK

- `build-frontend-react`
+
The React frontend code can be generated from model. It is generated by default.
To skip React frontend generations, use the system property: -DskipFrontendReact


- `build-karaf`
+
The karaf runtime is created by default. It integrates backend and frontend modules, it
can be used as a standalone server.
To skip creating the karaf runtime, use the system property: -DskipKaraf

- `build-docker`
+
The docker image is created by default. It uses karaf runtime and creates runnable
docker image.
To skip creating the docker image, use the system property: -DskipDocker


Sometimes maven compiling can be slow. In order to investigate what is causing potential issues we can run maven with:

`-Dprofile -DprofileFormat=HTML`

Using these flags, maven will generate a HTML report in the `.profiler` directory.

== Layout

=== `model`

The model project.
It creates the intermediate models from JSL model and stores in `/model/target/generated-resources/model/` directory.
This model is packed as OSGi bundle which is used the JUDO runtime.
It also attach am OSGi bundles:

=== `schema`

The schema is used to make transition between model states in RDBMS. Schema supports incremental DDL. It creates
standalone CLI and docker images to update a database to new model state.

=== `app`

The implementations for model defined custom operations.

=== `sdk`

SDK API codes which can be implemented as custom Java operations in `app` or other custom subprojects.

=== `internal`

SDK API wrapper which are technical services to bind the user defined Java custom operations.

=== `frontend-react`

It contains the generator project and the generated react frontend source. It uses maven with frontend maven plugin
to create deployable web bundle which is served as static content in karaf runtime.

=== `karaf-features`

The description of the karaf service.
It aggregates bundle definitions and configurations for the backend service in `src/main/feature/features.xml`.

=== `karaf-offline`

The assembled karaf service which can be deployed.
We can use the `run-offline.sh` script to run it

=== `docker`

The docker image builder which is including `karaf-offline`.

[source,]
----
mvn clean install -DcreateDocker
----

== Run service

After the project compilation every artifact is created to be able to start karaf service.
Keycloak service have to be accessed by backend for all apps.

=== Keycloak

By default JUDO apps integrate with keycloak in order to provide authentication and authorization features.
Keycloak must be running in order for applications to start up.

It is accessible in port 8080 by default, so in browser:

`http://localhost:8080`


== Settings

Settings can be set up as https://documentation.judo.technology/getting-started/introduction.html[judo-documentation] describes.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!-- To define create 'app/pom.xml.extra-dependencies.fragment.hbs' file -->
<!-- End of 'app/pom.xml.extra-dependencies.fragment.hbs' -->
Loading
Loading