Skip to content

Commit 016c7ab

Browse files
committed
Added Company Wrappers for all modules in CompanyWrapperGenerator / added mdoc for Version resolving in code.
1 parent 946b54a commit 016c7ab

29 files changed

+1042
-97
lines changed

00-documentation/src/docs/README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

00-documentation/src/docs/helper/directory.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
laika.navigationOrder = [
33
development.md
44
initCompany.md
5+
createProject.md
6+
projectDev.md
57
]

00-documentation/src/docs/helper/initCompany.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,20 @@ So try to stick to the conventions, whenever possible.
2828
mkdir ~/dev-myCompany
2929
```
3030

31-
1. Create `helperCompany.scala` in your company directory.
31+
1. Create `helperCompany.scala` in your company directory and open it.
3232
```bash
3333
cd ~/dev-myCompany
34+
touch helperCompany.scala
3435
open helperCompany.scala
3536
```
3637

3738
1. Copy the following content to `helperCompany.scala`:
38-
```scala
39+
```scala mdoc
3940
#!/usr/bin/env -S scala shebang
4041
// DO NOT ADJUST. This file is replaced by `./helper.scala update`.
4142

4243
//> using toolkit 0.5.0
43-
//> using dep io.github.pme123::camundala-helper:${project.version}
44+
//> using dep io.github.pme123::camundala-helper:@VERSION@
4445

4546
import camundala.helper.dev.DevCompanyHelper
4647

@@ -49,8 +50,6 @@ open helperCompany.scala
4950
DevCompanyHelper.run(command, arguments*)
5051
```
5152

52-
1. Replace `${project.version}` with _${project.version}_.
53-
5453
1. Make the file executable:
5554
```bash
5655
chmod +x helperCompany.scala
Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
# Project Development
22
**Experimental**
33

4-
TODO
4+
The following chapters describe the tasks to support the project development.
5+
6+
## update
7+
Whenever you have changes in the `company-camundala` project or in one of your dependencies,
8+
you can update the project with the following command:
9+
10+
```bash
11+
./helper.scala update
12+
```
13+
14+
This will create or update your project with the latest changes.
15+
16+
Files that contain the `DO NOT ADJUST` comment will be replaced.
17+
If you do adjust them, remove this comment.
18+
You will get a warning, but the file will not be replaced.
19+

03-dmn/src/main/scala/camundala/dmn/DmnTesterConfigCreator.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import camundala.domain.*
55
import camundala.bpmn.*
66
import pme123.camunda.dmn.tester.shared.*
77

8+
import java.io.FileNotFoundException
89
import java.time.LocalDateTime
910
import scala.language.reflectiveCalls
1011
import scala.reflect.ClassTag
@@ -16,7 +17,11 @@ trait DmnTesterConfigCreator extends DmnConfigWriter:
1617
// the path where the DMN Configs are
1718
protected def dmnConfigPath: os.Path = starterConfig.dmnConfigPaths.head
1819
// creating the Path to the DMN - by default the _dmnName_ is `decisionDmn.decisionDefinitionKey`.
19-
protected def defaultDmnPath(dmnName: String): os.Path = dmnBasePath / s"$dmnName.dmn"
20+
protected def defaultDmnPath(dmnName: String): os.Path =
21+
val dmnPath = dmnBasePath / s"${dmnName.replace(s"${starterConfig.companyName}-", "")}.dmn"
22+
if (!dmnPath.toIO.exists())
23+
throw FileNotFoundException(s"There is no DMN in $dmnPath")
24+
dmnPath
2025

2126
protected def createDmnConfigs(dmnTesterObjects: DmnTesterObject[?]*): Unit =
2227
dmnConfigs(dmnTesterObjects)

03-dmn/src/main/scala/camundala/dmn/DmnTesterHelpers.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,20 @@ import os.CommandResult
44
import sttp.client3.*
55

66
trait DmnTesterHelpers:
7-
protected def starterConfig: DmnTesterStarterConfig = DmnTesterStarterConfig()
7+
protected def starterConfig: DmnTesterStarterConfig
88
protected def projectBasePath: os.Path = os.pwd
99
private lazy val exposedPort: Int = starterConfig.exposedPort
1010
protected lazy val client: SimpleHttpClient = SimpleHttpClient()
1111
protected lazy val apiUrl = s"http://localhost:$exposedPort/api"
1212
protected lazy val infoUrl = s"http://localhost:$exposedPort/info"
1313

1414
protected case class DmnTesterStarterConfig(
15+
companyName: String,
1516
// the name of the container that will be started
1617
containerName: String = "camunda-dmn-tester",
1718
// path to where the configs should be created in
1819
dmnConfigPaths: Seq[os.Path] = Seq(
19-
projectBasePath / "src" / "main" / "resources" / "dmnConfigs"
20+
projectBasePath / "03-dmn" / "src" / "main" / "resources" / "dmnConfigs"
2021
),
2122
// paths where the DMNs are (could be different places)
2223
dmnPaths: Seq[os.Path] = Seq(

04-helper/src/main/scala/camundala/helper/dev/company/CompanySbtGenerator.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import camundala.helper.dev.update.*
55
import camundala.helper.util.{TestType, VersionHelper}
66

77
case class CompanySbtGenerator()(using
8-
config: DevConfig
8+
config: DevConfig
99
):
1010
lazy val sbtGenerator = SbtGenerator()
1111
lazy val generate: Unit =
@@ -15,7 +15,7 @@ case class CompanySbtGenerator()(using
1515
end generate
1616

1717
lazy val generatePluginsSbt =
18-
createOrUpdate(config.sbtProjectDir / "plugins.sbt", pluginsSbt)
18+
createIfNotExists(config.sbtProjectDir / "plugins.sbt", pluginsSbt)
1919
private lazy val projectConf = config.apiProjectConf
2020
private lazy val versionHelper = VersionHelper(projectConf)
2121
private lazy val buildSbtDir = config.projectDir / "build.sbt"
@@ -56,7 +56,8 @@ case class CompanySbtGenerator()(using
5656
| scalaVersion,
5757
| sbtVersion,
5858
| BuildInfoKey("camundalaV", camundalaV)
59-
| )
59+
| ),
60+
| buildInfoPackage := s"$$companyName.camundala"
6061
| )
6162
| .settings(generalSettings())
6263
| .settings(publicationSettings)
Lines changed: 138 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,154 @@
11
package camundala.helper.dev.company
22

3-
import camundala.helper.dev.update.createOrUpdate
3+
import camundala.helper.dev.update.createIfNotExists
44
import camundala.helper.util.*
55

66
case class CompanyWrapperGenerator()(using config: DevConfig):
77

88
lazy val generate: Unit =
9-
createOrUpdate(projectDevPath, helperConfig)
9+
createIfNotExists(projectBpmnPath, bpmnWrapper)
10+
createIfNotExists(projectApiPath, apiWrapper)
11+
createIfNotExists(projectDmnPath, dmnWrapper)
12+
createIfNotExists(projectSimulationPath, simulationWrapper)
13+
createIfNotExists(projectWorkerPath, workerWrapper)
14+
createIfNotExists(projectHelperPath, helperWrapper)
1015

1116
private lazy val companyName = config.companyName
12-
private lazy val helperPath =
13-
config.projectDir / ModuleConfig.helperModule.packagePath(config.projectPath)
14-
private lazy val projectDevPath = helperPath / "CompanyDevHelper.scala"
15-
16-
private lazy val helperConfig =
17-
objectContent("CompanyDevHelper"):
18-
s"""
19-
| def config(projectName: String, subProjects: Seq[String] = Seq.empty): DevConfig =
20-
| DevConfig.defaultConfig(projectName) //TODO Implement your Config!
21-
| .copy(subProjects = subProjects)
22-
|""".stripMargin
23-
end helperConfig
24-
25-
private def objectContent(objName: String)(body: String) =
17+
18+
private lazy val projectBpmnPath = ModuleConfig.bpmnModule.srcPath / "CompanyBpmnDsl.scala"
19+
private lazy val projectApiPath = ModuleConfig.apiModule.srcPath / "CompanyApiCreator.scala"
20+
private lazy val projectDmnPath = ModuleConfig.dmnModule.srcPath / "CompanyDmnTester.scala"
21+
private lazy val projectSimulationPath = ModuleConfig.simulationModule.testPath / "CompanySimulation.scala"
22+
private lazy val projectWorkerPath = ModuleConfig.workerModule.srcPath / "CompanyWorkerHandler.scala"
23+
private lazy val projectHelperPath = ModuleConfig.helperModule.srcPath / "CompanyDevHelper.scala"
24+
25+
private lazy val bpmnWrapper =
26+
s"""package $companyName.camundala.bpmn
27+
|
28+
|import camundala.bpmn.*
29+
|import camundala.domain.*
30+
|
31+
|/**
32+
| * Add here company specific stuff, like documentation or custom elements.
33+
| */
34+
|trait CompanyBpmnDsl
35+
|
36+
|trait CompanyBpmnProcessDsl extends BpmnProcessDsl, CompanyBpmnDsl
37+
|trait CompanyBpmnServiceTaskDsl extends BpmnServiceTaskDsl, CompanyBpmnDsl
38+
|trait CompanyBpmnCustomTaskDsl extends BpmnCustomTaskDsl, CompanyBpmnDsl
39+
|trait CompanyBpmnDecisionDsl extends BpmnDecisionDsl, CompanyBpmnDsl
40+
|trait CompanyBpmnUserTaskDsl extends BpmnUserTaskDsl, CompanyBpmnDsl
41+
|trait CompanyBpmnMessageEventDsl extends BpmnMessageEventDsl, CompanyBpmnDsl
42+
|trait CompanyBpmnSignalEventDsl extends BpmnSignalEventDsl, CompanyBpmnDsl
43+
|trait CompanyBpmnTimerEventDsl extends BpmnTimerEventDsl, CompanyBpmnDsl
44+
|""".stripMargin
45+
46+
private lazy val apiWrapper =
47+
s"""package $companyName.camundala.api
48+
|
49+
|import camundala.api.*
50+
|
51+
|/**
52+
| * Add here company specific stuff, to create the Api documentation and the Postman collection.
53+
| */
54+
|trait CompanyApiCreator extends ApiCreator, ApiDsl, CamundaPostmanApiCreator:
55+
|
56+
| // override the config if needed
57+
| //override protected def apiConfig: ApiConfig = ???
58+
|
59+
| lazy val companyDescr = ??? //TODO Add your Company Description!
60+
|""".stripMargin
61+
62+
private lazy val dmnWrapper =
63+
s"""package $companyName.camundala.dmn
64+
|
65+
|import camundala.dmn.*
66+
|
67+
|/**
68+
| * Add here company specific stuff, to run the DMN Tester.
69+
| */
70+
|trait CompanyDmnTester extends DmnTesterConfigCreator, DmnTesterStarter:
71+
|
72+
| def starterConfig: DmnTesterStarterConfig =
73+
| DmnTesterStarterConfig( // adjust paths if needed
74+
| companyName = "$companyName",
75+
| )
76+
|""".stripMargin
77+
78+
private lazy val simulationWrapper =
79+
s"""package $companyName.camundala.simulation
80+
|
81+
|import camundala.simulation.custom.*
82+
|
83+
|/**
84+
| * Add here company specific stuff, to run the Simulations.
85+
| */
86+
|trait CompanySimulation extends BasicSimulationDsl:
87+
|
88+
| override implicit def config =
89+
| super.config //TODO Adjust config if needed
90+
|""".stripMargin
91+
92+
private lazy val workerWrapper =
93+
s"""package $companyName.camundala.worker
94+
|
95+
|import camundala.camunda7.worker.C7WorkerHandler
96+
|import camundala.worker.*
97+
|
98+
|import scala.reflect.ClassTag
99+
|
100+
|/**
101+
| * Add here company specific stuff, to run the Workers.
102+
| * You also define the implementation of the WorkerHandler here.
103+
| */
104+
|trait CompanyWorkerHandler extends C7WorkerHandler
105+
|
106+
|trait CompanyInitWorkerDsl[
107+
| In <: Product: InOutCodec,
108+
| Out <: Product: InOutCodec,
109+
| InitIn <: Product: InOutCodec,
110+
| InConfig <: Product: InOutCodec
111+
|] extends CompanyWorkerHandler, InitWorkerDsl[In, Out, InitIn, InConfig]
112+
|
113+
|trait CompanyValidationWorkerDsl[
114+
| In <: Product: InOutCodec
115+
|] extends CompanyWorkerHandler, ValidationWorkerDsl[In]
116+
|
117+
|trait CompanyCustomWorkerDsl[
118+
| In <: Product: InOutCodec,
119+
| Out <: Product: InOutCodec
120+
|] extends CompanyWorkerHandler, CustomWorkerDsl[In, Out]
121+
|
122+
|trait CompanyServiceWorkerDsl[
123+
| In <: Product: InOutCodec,
124+
| Out <: Product: InOutCodec,
125+
| ServiceIn: InOutEncoder,
126+
| ServiceOut: InOutDecoder: ClassTag
127+
|] extends CompanyWorkerHandler, ServiceWorkerDsl[In, Out, ServiceIn, ServiceOut]
128+
|""".stripMargin
129+
130+
private lazy val helperWrapper =
26131
s"""package $companyName.camundala.helper
27132
|
28133
|import camundala.helper.dev.*
29134
|import camundala.helper.util.*
30135
|
31-
|object $objName:
136+
|object CompanyDevHelper:
32137
|
33-
|$body
34-
|end $objName""".stripMargin
138+
| def config(projectName: String, subProjects: Seq[String] = Seq.empty): DevConfig =
139+
| DevConfig.defaultConfig(projectName) //TODO Implement your Config!
140+
| .copy(subProjects = subProjects)
141+
|""".stripMargin
142+
end helperWrapper
143+
144+
extension (module: ModuleConfig)
145+
def srcPath: os.Path =
146+
config.projectDir / module.packagePath(
147+
config.projectPath
148+
)
149+
def testPath: os.Path =
150+
config.projectDir / module.packagePath(
151+
config.projectPath,
152+
mainOrTest = "test"
153+
)
35154
end CompanyWrapperGenerator

04-helper/src/main/scala/camundala/helper/dev/update/SbtSettingsGenerator.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,10 @@ case class SbtSettingsGenerator()(using config: DevConfig):
135135
}""".stripMargin
136136

137137
private lazy val sbtDocker =
138-
s"""
139-
| lazy val dockerSettings = ${config.sbtDockerSettings}
140-
|""".stripMargin
138+
s" lazy val dockerSettings = " +
139+
config.sbtDockerSettings
140+
.getOrElse("Seq()")
141+
141142
private lazy val testSettings =
142143
s""" lazy val testSettings = Seq(
143144
| libraryDependencies += mUnit,

04-helper/src/main/scala/camundala/helper/util/DevConfig.scala

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ case class DevConfig(
1616
reposConfig: ReposConfig = ReposConfig.dummyRepos,
1717
// path where the BPMNs are - must be relative to the project path
1818
bpmnPath: os.RelPath = os.rel / "src" / "main" / "resources",
19-
sbtDockerSettings: String = ""
19+
sbtDockerSettings: Option[String] = None
2020
):
2121
lazy val companyName: String = apiProjectConf.org
2222
lazy val companyClassName: String = companyName.head.toUpper + companyName.tail
@@ -59,7 +59,7 @@ object DevConfig:
5959
ApiProjectConf.init(projectName, projectDir(projectName, os.pwd) / packageConfRelPath),
6060
versionConfig = versionConfig,
6161
reposConfig = reposConfig,
62-
sbtDockerSettings = sbtDockerSettings,
62+
sbtDockerSettings = Some(sbtDockerSettings),
6363
bpmnPath = bpmnPath
6464
)
6565

@@ -116,6 +116,13 @@ case class ModuleConfig(
116116
os.rel / nameWithLevel /
117117
subModule / "src" / mainOrTest / sourceOrResource
118118
end packagePath
119+
120+
def emptyExportsFile(projPackage: String): String =
121+
s"""package $projPackage.$name
122+
|
123+
|// put here your exports - dummy file if you don't have any classes
124+
|""".stripMargin
125+
119126
end ModuleConfig
120127

121128
object ModuleConfig:

0 commit comments

Comments
 (0)