Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
kwiens12357 committed Apr 13, 2023
1 parent 7e9c4ac commit c83c5c4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 34 deletions.
5 changes: 0 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@
<version>${maven.plugin-tools.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.32</version>
</dependency>
<dependency>
<groupId>info.novatec</groupId>
<artifactId>camunda-bpmn-documentation-generator</artifactId>
Expand Down
38 changes: 9 additions & 29 deletions src/main/kotlin/info/novatec/cbdg/plugin/GenerateMojo.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package info.novatec.cbdg.plugin

import info.novatec.cbdg.FreeMarkerService
import info.novatec.docu.generator.DocuGenerator
import info.novatec.docu.parser.main.BpmnParser
import org.apache.maven.plugin.AbstractMojo
import org.apache.maven.plugin.logging.Log
import org.apache.maven.plugins.annotations.Mojo
import org.apache.maven.plugins.annotations.Parameter
import java.io.File
Expand Down Expand Up @@ -47,34 +49,12 @@ class GenerateMojo : AbstractMojo() {
var bpmnDiagramImageDir: File? = null

override fun execute() {
if (templateFile.name.equals("default.ftl")) {
FileOutputStream(templateFile, false).use { javaClass.classLoader.getResourceAsStream("templates/default.ftl")
?.transferTo(it) ?: throw FileNotFoundException("templates/default.ftl don't exist.")}
}

camundaBpmnDir.listFiles()?.forEach {
log.info("Generating documentation for file ${it.absolutePath}")
log.info("Using template ${templateFile.absolutePath}")

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,
"${resultOutputDir.absolutePath}/${it.nameWithoutExtension}.html"
) {
setDirectoryForTemplateLoading(templateFile.parentFile)
}
log.info("Output report into path ${resultOutputDir.absolutePath}")
} ?: throw FileNotFoundException("${camundaBpmnDir.absolutePath} don't exist.")
resultOutputDir.listFiles()?.forEach {
log.info("Output: " + it.absolutePath)
} ?: throw FileNotFoundException("${resultOutputDir.absolutePath} don't exist.")
DocuGenerator.parseAndGenerate(
// log,
templateFile,
camundaBpmnDir,
resultOutputDir,
bpmnDiagramImageDir
)
}
}

0 comments on commit c83c5c4

Please sign in to comment.