diff --git a/build.gradle.kts b/build.gradle.kts index c6b98d2..42d0065 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,7 @@ plugins { id("com.diffplug.spotless") version "5.14.0" id("com.liferay.maven.plugin.builder") version "1.2.8" id("org.jetbrains.kotlin.jvm") version "1.5.31" - id("org.jlleitschuh.gradle.ktlint") version "10.1.0" + // id("org.jlleitschuh.gradle.ktlint") version "10.1.0" id("org.jetbrains.dokka") version "1.7.0" } @@ -60,7 +60,7 @@ tasks.withType { useJUnitPlatform() } -configure { +/*configure { kotlin { ktlint("0.38.0") } @@ -68,4 +68,4 @@ configure { target("*.gradle.kts") ktlint() } -} +}*/ diff --git a/src/main/kotlin/info/novatec/cbdg/plugin/GenerateMojo.kt b/src/main/kotlin/info/novatec/cbdg/plugin/GenerateMojo.kt index 43f361c..9af8008 100644 --- a/src/main/kotlin/info/novatec/cbdg/plugin/GenerateMojo.kt +++ b/src/main/kotlin/info/novatec/cbdg/plugin/GenerateMojo.kt @@ -9,8 +9,10 @@ import java.io.File import java.io.FileNotFoundException import java.io.FileOutputStream import java.nio.file.Files +import java.nio.file.StandardCopyOption import kotlin.io.path.Path import kotlin.io.path.createDirectories +import kotlin.io.path.exists /** * Mojo - Class for cbdg-plugin. Calls by Maven-command 'mvn cbdg:generate'. @@ -38,8 +40,11 @@ class GenerateMojo : AbstractMojo() { @Parameter(property = "resultOutputDir", defaultValue = "\${project.build.directory}/cbdg/html") lateinit var resultOutputDir: File - @Parameter(property = "bpmnDiagramImageFile") - var bpmnDiagramImageFile: File? = null + /** + * Directory with the images of bpmn-files. Default is '{project.basedir}/src/main/resources/images' + */ + @Parameter(property = "bpmnDiagramImageDir", defaultValue = "\${project.basedir}/src/main/resources/images") + var bpmnDiagramImageDir: File? = null override fun execute() { if (templateFile.name.equals("default.ftl")) { @@ -49,7 +54,15 @@ class GenerateMojo : AbstractMojo() { camundaBpmnDir.listFiles()?.forEach { log.info("Generating documentation for file ${it.absolutePath}") log.info("Using template ${templateFile.absolutePath}") - val bpmnObject = BpmnParser.parseBpmnFile(it, bpmnDiagramImageFile?.name) + + val imageSrcPath = Path("${bpmnDiagramImageDir?.absolutePath}/${it.nameWithoutExtension}.png") + val imageTargetPath = Path("${resultOutputDir.absolutePath}/images/${it.nameWithoutExtension}.png") + imageTargetPath.parent.createDirectories() + if (imageSrcPath.exists()) { + Files.copy(imageSrcPath, imageTargetPath, StandardCopyOption.REPLACE_EXISTING) + } + + val bpmnObject = BpmnParser.parseBpmnFile(it, "${it.nameWithoutExtension}.png") FreeMarkerService.writeTemplate( bpmnObject, templateFile.name, @@ -58,11 +71,6 @@ class GenerateMojo : AbstractMojo() { setDirectoryForTemplateLoading(templateFile.parentFile) } log.info("Output report into path ${resultOutputDir.absolutePath}") - bpmnDiagramImageFile?.let { - val imagePath = Path("${resultOutputDir.absolutePath}/images/${it.name}") - imagePath.parent.createDirectories() - Files.copy(it.toPath(), imagePath) - } } ?: throw FileNotFoundException("${camundaBpmnDir.absolutePath} don't exist.") resultOutputDir.listFiles()?.forEach { log.info(it.absolutePath) diff --git a/src/main/resources/META-INF/maven/info.novatec/camunda-bpmn-documentation-generator/plugin-help.xml b/src/main/resources/META-INF/maven/info.novatec/camunda-bpmn-documentation-generator/plugin-help.xml index 7d1a6a4..5f61682 100644 --- a/src/main/resources/META-INF/maven/info.novatec/camunda-bpmn-documentation-generator/plugin-help.xml +++ b/src/main/resources/META-INF/maven/info.novatec/camunda-bpmn-documentation-generator/plugin-help.xml @@ -23,7 +23,7 @@ false - bpmnDiagramImageFile + bpmnDiagramImageDir java.io.File false true @@ -52,7 +52,7 @@ - ${bpmnDiagramImageFile} + ${bpmnDiagramImageDir} ${camundaBpmnDir} ${resultOutputDir} ${templateFile} diff --git a/src/main/resources/META-INF/maven/plugin.xml b/src/main/resources/META-INF/maven/plugin.xml index 23a6905..805c484 100644 --- a/src/main/resources/META-INF/maven/plugin.xml +++ b/src/main/resources/META-INF/maven/plugin.xml @@ -25,7 +25,7 @@ false - bpmnDiagramImageFile + bpmnDiagramImageDir java.io.File false true @@ -54,7 +54,7 @@ - ${bpmnDiagramImageFile} + ${bpmnDiagramImageDir} ${camundaBpmnDir} ${resultOutputDir} ${templateFile} diff --git a/src/test/resources/bpmn/TestDiagramWithoutImage.bpmn b/src/test/resources/bpmn/TestDiagramWithoutImage.bpmn new file mode 100644 index 0000000..8b399ee --- /dev/null +++ b/src/test/resources/bpmn/TestDiagramWithoutImage.bpmn @@ -0,0 +1,335 @@ + + + + Hier steht eine Dokumentation + + Start des Prozesses + Flow_0mp6cca + + + Flow_1sfmmhq + Flow_0yb16gj + + + + Ende des Prozesses + NoSequenceFlow + + + + Flow_0yb16gj + NoSequenceFlow + YesSequenceFlow + + + ${false} + + + YesSequenceFlow + Flow_12ovz2t + + + ${true} + + + + Flow_0mp6cca + Flow_1a42jd0 + Flow_09ptqu0 + Flow_1b6ee3r + Flow_1sfmmhq + + + + + Start Event Message + Flow_1a42jd0 + + + + Start Event Timer + Flow_09ptqu0 + + + + + Start Event Conditional + Flow_1b6ee3r + + true + + + + + Start Event Signal + Flow_0ifyc4k + + + + End Event Message + N2SequenceFlow + + + + End Event Escalation + N3SequenceFlow + + + + End Event Error + N4SequenceFlow + + + + End Event Compensation + N5SequenceFlow + + + + End Event Signal + N6SequenceFlow + + + + End Event Terminate + Flow_1fl1sio + + + + Flow_12ovz2t + N3SequenceFlow + N4SequenceFlow + N5SequenceFlow + N6SequenceFlow + N2SequenceFlow + + + ${true} + + + ${true} + + + ${true} + + + ${true} + + + ${true} + + + This is the documentation for the CallActivity "Call Activity 2" + Flow_1rcdta1 + Flow_1fl1sio + + + This is the documentation for the CallActivity "Call Activity 1" + Flow_0ifyc4k + Flow_1rcdta1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/images/flowchart.png b/src/test/resources/images/TestDiagram.png similarity index 100% rename from src/test/resources/images/flowchart.png rename to src/test/resources/images/TestDiagram.png diff --git a/src/test/resources/pom.xml b/src/test/resources/pom.xml index ad6db04..6ae4dac 100644 --- a/src/test/resources/pom.xml +++ b/src/test/resources/pom.xml @@ -20,7 +20,7 @@ src/test/resources/templates/test.ftl src/test/resources/bpmn build/test-results/cbdg/html - src/test/resources/images/flowchart.png + src/test/resources/images