diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index b58bfae..6a0a2b4 100755 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1 +1 @@ -distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.9.0/apache-maven-3.9.0-bin.zip +distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip diff --git a/pom.xml b/pom.xml index 95484b1..3e9c0c2 100644 --- a/pom.xml +++ b/pom.xml @@ -14,10 +14,10 @@ UTF-8 - 1.8.10 - 3.9.0 + 1.9.20 + 3.9.5 3.7.1 - 5.9.2 + 5.10.1 @@ -44,11 +44,6 @@ ${maven.plugin-tools.version} provided - - org.freemarker - freemarker - 2.3.32 - info.novatec camunda-bpmn-documentation-generator diff --git a/src/main/kotlin/info/novatec/cbdg/plugin/CamundaBpmnDocumentationGeneratorMojo.kt b/src/main/kotlin/info/novatec/cbdg/plugin/CamundaBpmnDocumentationGeneratorMojo.kt new file mode 100644 index 0000000..2b9452f --- /dev/null +++ b/src/main/kotlin/info/novatec/cbdg/plugin/CamundaBpmnDocumentationGeneratorMojo.kt @@ -0,0 +1,48 @@ +package info.novatec.cbdg.plugin + +import info.novatec.docu.generator.DocuGenerator +import org.apache.maven.plugin.AbstractMojo +import org.apache.maven.plugins.annotations.Mojo +import org.apache.maven.plugins.annotations.Parameter +import java.io.File + +/** + * Mojo - Class for cbdg-plugin. Calls by Maven-command 'mvn cbdg:generate'. + */ +@Mojo(name = "generate") +class CamundaBpmnDocumentationGeneratorMojo : AbstractMojo() { + /** + * Default usage is the templates/default.ftl from Jar-File. + * To use it, it will be created in Build-Dir of the target project the empty file default.ftl + * and fill it with the stream of templates/default.ftl from Jar-File + */ + @Parameter(property = "templateFile", defaultValue = "\${project.build.directory}/classes/templates/default.ftl") + lateinit var templateFile: File + + /** + * Directory with bpmn-files. Default is '{project.basedir}/src/main/resources/bpmn' + */ + @Parameter(property = "camundaBpmnDir", defaultValue = "\${project.basedir}/src/main/resources/bpmn") + lateinit var camundaBpmnDir: File + + /** + * Target-directory fot generated content. Default is '{project.build.directory}/cbdg/html' + */ + @Parameter(property = "resultOutputDir", defaultValue = "\${project.build.directory}/cbdg/html") + lateinit var resultOutputDir: File + + /** + * 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() { + DocuGenerator().parseAndGenerate( + templateFile, + camundaBpmnDir, + resultOutputDir, + bpmnDiagramImageDir + ) + } +} diff --git a/src/main/kotlin/info/novatec/cbdg/plugin/GenerateMojo.kt b/src/main/kotlin/info/novatec/cbdg/plugin/GenerateMojo.kt deleted file mode 100644 index d97de2b..0000000 --- a/src/main/kotlin/info/novatec/cbdg/plugin/GenerateMojo.kt +++ /dev/null @@ -1,80 +0,0 @@ -package info.novatec.cbdg.plugin - -import info.novatec.cbdg.FreeMarkerService -import info.novatec.docu.parser.main.BpmnParser -import org.apache.maven.plugin.AbstractMojo -import org.apache.maven.plugins.annotations.Mojo -import org.apache.maven.plugins.annotations.Parameter -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'. - */ -@Mojo(name = "generate") -class GenerateMojo : AbstractMojo() { - - /** - * Default usage is the templates/default.ftl from Jar-File. - * To use it, it will be created in Build-Dir of the target project the empty file default.ftl - * and fill it with the stream of templates/default.ftl from Jar-File - */ - @Parameter(property = "templateFile", defaultValue = "\${project.build.directory}/classes/templates/default.ftl") - lateinit var templateFile: File - - /** - * Directory with bpmn-files. Default is '{project.basedir}/src/main/resources/bpmn' - */ - @Parameter(property = "camundaBpmnDir", defaultValue = "\${project.basedir}/src/main/resources/bpmn") - lateinit var camundaBpmnDir: File - - /** - * Target-directory fot generated content. Default is '{project.build.directory}/cbdg/html' - */ - @Parameter(property = "resultOutputDir", defaultValue = "\${project.build.directory}/cbdg/html") - lateinit var resultOutputDir: File - - /** - * 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")) { - 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.") - } -}