Skip to content

Commit d77f504

Browse files
Merge remote-tracking branch 'upstream/main' into JumpTheQueue
# Conflicts: # cobigen/index.asciidoc
2 parents cb460cf + c1c5695 commit d77f504

12 files changed

Lines changed: 314 additions & 7 deletions

File tree

.github/workflows/buildMain.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
workflow_dispatch:
8+
jobs:
9+
build_main:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout tutorial-compiler
14+
uses: actions/checkout@v2
15+
with:
16+
repository: devonfw-tutorials/tutorial-compiler
17+
18+
- name: Checkout playbooks
19+
uses: actions/checkout@v2
20+
with:
21+
repository: devonfw-tutorials/tutorials
22+
path: playbooks
23+
24+
- uses: actions/setup-node@v2-beta
25+
26+
- name: install TS
27+
run: npm install typescript
28+
29+
- name: npm install
30+
run: npm install
31+
32+
- name: run buildRun.sh
33+
run: sh buildRun.sh
34+
35+
- name: Repository dispatch
36+
uses: peter-evans/repository-dispatch@v1
37+
with:
38+
token: ${{ secrets.REPO_ACCESS_TOKEN }}
39+
repository: devonfw-tutorials/katacoda-scenarios
40+
event-type: dispatch-katacoda-scenarios
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
name: CI
22

33
on:
4-
push:
5-
branches: [ main ]
64
pull_request:
75
branches: [ main ]
86

97
workflow_dispatch:
108
jobs:
11-
build:
9+
build_pullRequest:
1210
runs-on: ubuntu-latest
1311

1412
steps:
1513
- name: Checkout tutorial-compiler
1614
uses: actions/checkout@v2
1715
with:
18-
repository: devonfw-forge/tutorial-compiler
16+
repository: devonfw-tutorials/tutorial-compiler
1917

2018
- name: Checkout playbooks
2119
uses: actions/checkout@v2
2220
with:
23-
repository: devonfw-forge/tutorials
21+
repository: devonfw-tutorials/tutorials
2422
path: playbooks
2523

2624
- uses: actions/setup-node@v2-beta

.github/workflows/pr.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,11 @@ jobs:
1515
repo-token: ${{ secrets.GITHUB_TOKEN }}
1616
repo-token-user-login: 'github-actions[bot]'
1717
message: |
18-
You can view the generated tutorials of this PR on https://www.katacoda.com/devonfw-dev in a few minutes. You just have to wait for the next run of the deployment action https://github.com/devonfw/katacoda-scenarios-dev/actions
18+
You can view the generated tutorials of this PR on https://www.katacoda.com/devonfw-dev in a few minutes. You just have to wait for the next run of the deployment action https://github.com/devonfw-tutorials/katacoda-scenarios-dev/actions
19+
20+
- name: Repository dispatch
21+
uses: peter-evans/repository-dispatch@v1
22+
with:
23+
token: ${{ secrets.REPO_ACCESS_TOKEN }}
24+
repository: devonfw-tutorials/katacoda-scenarios-dev
25+
event-type: dispatch-katacoda-scenarios-dev

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,13 @@
1-
# tutorials
1+
**Tutorials**
2+
3+
Welcome to the devonfw tutorials repository.
4+
5+
In this repository, you write tutorials that are executed by the tutorial compiler (https://github.com/devonfw-tutorials/tutorial-compiler). The tutorial compiler ensures that the tutorials are automatically tested end-to-end. It also generates other output, such as full Katacoda tutorials.<br/>.
6+
7+
You can find devonfw Katacoda tutorials at https://katacoda.com/devonfw.<br/>
8+
9+
You can find an explanation how you can create your own tutorials on the development section.<br/>
10+
[Development](https://github.com/devonfw-tutorials/tutorials/wiki/Development)
11+
12+
An overview of the commands included in the tutorial compiler can be found in the function overview. You can use these commands in your own created tutorials.<br/>
13+
[Functions](https://github.com/devonfw-tutorials/tutorials/wiki/Functions)

cobigen/index.asciidoc

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
= Tutorial for Java Backend Generation with CobiGen
2+
====
3+
CobiGen is a generic incremental code generator. It allows you to build Java CRUD application based on the devonfw architecture including all software layers. You can generate all necessary classes and services (DAOs, Transfer Objects, simple CRUD use cases with REST services) of the application from one single entity class.
4+
5+
CobiGen provides Maven and Eclipse integrations. But there is also a command line interface (CLI) which enables the generation of code using only few commands.
6+
7+
More information about CobiGen on https://devonfw.com/website/pages/docs/master-cobigen.asciidoc.html
8+
====
9+
10+
[step]
11+
--
12+
restoreDevonfwIde(["java","mvn"])
13+
--
14+
15+
For this tutorial an installation of the devonfw IDE is required, which was already set up for you.
16+
To begin you need to install CobiGen and create a Java Project.
17+
[step]
18+
== Install CobiGen and create Java Project
19+
--
20+
installCobiGen()
21+
createDevon4jProject("cobigenexample")
22+
--
23+
24+
Create the entity class which will be passed to the cobigen cli generator later
25+
[step]
26+
--
27+
createFile("cobigenexample/core/src/main/java/com/example/application/cobigenexample/customermanagement/dataaccess/api/CustomerEntity.java", "files/CustomerEntity.java")
28+
--
29+
30+
Now Build the java project
31+
[step]
32+
--
33+
buildJava("cobigenexample", false)
34+
--
35+
36+
====
37+
CobiGen is integrated via plugin in the VS Code IDE. We will use it to generate code from one single java class based on existing templates.
38+
[step]
39+
--
40+
adaptTemplatesCobiGen()
41+
cobiGenJava("cobigenexample/core/src/main/java/com/example/application/cobigenexample/customermanagement/dataaccess/api/CustomerEntity.java",[1,3,5,6,8])
42+
--
43+
The CobiGen code generator will generate some java classes for you. These contain code for basic CRUD operations, REST service handling and data access.
44+
45+
For example, the following files are generated by CobiGen when using the specified templates:
46+
47+
(1) CRUD logic: Generates the logic layer and implementations for some use cases.
48+
- `devonfw/workspaces/main/cobigenexample/core/src/main/java/com/example/application/cobigenexample/customermanagement/logic/impl/CustomermanagementImpl.java`{{open}}
49+
- `devonfw/workspaces/main/cobigenexample/core/src/main/java/com/example/application/cobigenexample/customermanagement/logic/impl/usecase/UcManageCustomerImpl.java`{{open}}
50+
- `devonfw/workspaces/main/cobigenexample/core/src/main/java/com/example/application/cobigenexample/customermanagement/logic/impl/usecase/UcFindCustomerImpl.java`{{open}}
51+
- `devonfw/workspaces/main/cobigenexample/api/src/main/java/com/example/application/cobigenexample/customermanagement/logic/api/Customermanagement.java`{{open}}
52+
53+
(3) CRUD REST services: Generates the service layer with CRUD operations for using in REST services.
54+
- `devonfw/workspaces/main/cobigenexample/api/src/main/java/com/example/application/cobigenexample/customermanagement/service/api/rest/CustomermanagementRestService.java`{{open}}
55+
- `devonfw/workspaces/main/cobigenexample/core/src/main/java/com/example/application/cobigenexample/customermanagement/service/impl/rest/CustomermanagementRestServiceImpl.java`{{open}}
56+
57+
(5) TO's: Generates the related Transfer Objects.
58+
- `devonfw/workspaces/main/cobigenexample/api/src/main/java/com/example/application/cobigenexample/customermanagement/logic/api/to/CustomerEto.java`{{open}}
59+
- `devonfw/workspaces/main/cobigenexample/api/src/main/java/com/example/application/cobigenexample/customermanagement/logic/api/to/CustomerSearchCriteriaTo.java`{{open}}
60+
61+
(6) Entity infrastructure: Creates the entity main interface and edits (by a merge) the current entity to extend the newly generated classes.
62+
- `devonfw/workspaces/main/cobigenexample/api/src/main/java/com/example/application/cobigenexample/customermanagement/common/api/Customer.java`{{open}}
63+
- `devonfw/workspaces/main/cobigenexample/core/src/main/java/com/example/application/cobigenexample/customermanagement/dataaccess/api/CustomerEntity.java`{{open}} (changed)
64+
65+
(8) CRUD SpringData Repository: Generates the entity repository (that contains the CRUD operations) in the data access layer.
66+
- `devonfw/workspaces/main/cobigenexample/core/src/main/java/com/example/application/cobigenexample/customermanagement/dataaccess/api/repo/CustomerRepository.java`{{open}}
67+
====
68+
69+
Furthermore, we can change the CustomerEntity afterwards and update our source files simply by running cobigen again.
70+
[step]
71+
== Change Entity and run cobigen again
72+
--
73+
changeFile("cobigenexample/core/src/main/java/com/example/application/cobigenexample/customermanagement/dataaccess/api/CustomerEntity.java", { "file": "files/Placeholder.java", "placeholder": "private int age;" })
74+
cobiGenJava("cobigenexample/core/src/main/java/com/example/application/cobigenexample/customermanagement/dataaccess/api/CustomerEntity.java",[1,3,5,6,8])
75+
--
30.8 KB
Loading
40.7 KB
Loading

tutorial-compiler/images/fork.jpg

7.66 KB
Loading
75.9 KB
Loading

tutorial-compiler/index.asciidoc

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
= Tutorial Compiler
2+
====
3+
In this scenario you will use the tutorial-compiler to generate the "my-thai-star" tutorial.
4+
5+
The first part will be to setup your workspace.
6+
7+
Afterwards we will show you, how to write your own tutorials.
8+
9+
Requirements:
10+
* GitHub account
11+
12+
You can find the documentation here:
13+
14+
https://github.com/devonfw-forge/tutorial-compiler/wiki
15+
16+
====
17+
18+
====
19+
# Setup your workspace
20+
Let's start!
21+
22+
First of all, go to the tutorial-compiler repository on GitHub:
23+
24+
https://github.com/devonfw-tutorials/tutorial-compiler
25+
26+
Fork the repository by clicking on the fork-button.
27+
This will create a copy of this repository in your GitHub account. You will find it in 'Your repositories'.
28+
29+
[step]
30+
--
31+
nextKatacodaStep("Fork the 'tutorial-compiler'-repository and copy the URL", [{"image": "images/fork.jpg"}, {"content": "\nGo to your repositories, click on 'tutorial-compiler' and copy the repository URL as shown in image below.\n"}, {"image": "images/clone_code.jpg"}])
32+
--
33+
====
34+
35+
36+
Usually you would paste the copied URLs next to the 'git clone' - command, but in this tutorial we will clone the original 'tutorial-compiler'-repository. Therefore we are able to write the asciidoc-files and generate the tutorials, but we can not push changes in the source code to it.
37+
[step]
38+
--
39+
cloneRepository("", "https://github.com/devonfw-tutorials/tutorial-compiler.git")
40+
--
41+
42+
====
43+
Switch to the 'tutorials'-repository and repeat all the previous steps:
44+
45+
https://github.com/devonfw-tutorials/tutorials.git
46+
47+
- Fork the 'tutorials'-repository
48+
- Copy the 'tutorials'-URL
49+
50+
[step]
51+
--
52+
cloneRepository("", "https://github.com/devonfw-tutorials/tutorials.git")
53+
--
54+
55+
After this step you should have both repositories in the same folder next to each other.
56+
====
57+
58+
[step]
59+
--
60+
npmInstall("", {"name": "typescript", "global": true})
61+
npmInstall("tutorial-compiler")
62+
--
63+
64+
# Write the my-thai-star tutorial
65+
66+
Let's start with the second part of this tutorial and write the "my-thai-star" tutorial.
67+
68+
[step]
69+
--
70+
createFile("tutorials/my-thai-star/index.asciidoc")
71+
--
72+
73+
Add the tutorial title "My Thai Star"
74+
[step]
75+
--
76+
changeFile("tutorials/my-thai-star/index.asciidoc", {"content": "= My Thai Star"})
77+
--
78+
79+
You have to write the introduction in between these equal signs '====' and underneath the title.
80+
81+
[step]
82+
--
83+
changeFile("tutorials/my-thai-star/index.asciidoc", {"file": "text/intro.txt", "placeholder": "= My Thai Star" })
84+
--
85+
86+
Last but not least add all the needed functions for this tutorial.
87+
88+
Follow the link below to find a list of all available functions and their descriptions
89+
https://github.com/devonfw-tutorials/tutorial-compiler/wiki/Functions
90+
91+
Feel free to add your own functions to the compiler
92+
93+
You will find all the information you need on:
94+
95+
https://github.com/devonfw-tutorials/tutorial-compiler/wiki/Development
96+
97+
[step]
98+
--
99+
changeFile("tutorials/my-thai-star/index.asciidoc", {"file": "text/functions.txt", "placeholder": "This is the online demo of https://github.com/devonfw/my-thai-star" })
100+
--
101+
102+
====
103+
For this step you need to open you local terminal at your forked and cloned 'tutorials' folder.
104+
Run the commands
105+
1. 'git add .'
106+
2. 'git commit -m "my-thai-star"'
107+
3. 'git push'
108+
109+
This will save all the changes and push them into your GitHub-repository 'tutorials'.
110+
111+
Switch to your browser and open:
112+
https://github.com/devonfw-tutorials/tutorials
113+
114+
Click on 'Pull requests' > 'New pull request'.
115+
116+
[step]
117+
--
118+
nextKatacodaStep("Create a pull request", [{"image": "images/pull_request.jpg"},{"image": "images/compare.jpg"}])
119+
--
120+
121+
You might have to click on 'compare across forks'.
122+
123+
Select
124+
125+
* base repository: devonfw-tutorials
126+
* base: main
127+
* head repository: [username]/tutorials
128+
* compare: 'main'
129+
130+
and finally create the pull request by clicking on 'Create pull request'.
131+
132+
After a while you will find your tutorial on:
133+
https://www.katacoda.com/devonfw-dev
134+
====

0 commit comments

Comments
 (0)