编译和运行开源流程引擎camunda源代码

使用camunda开源工作流引擎有多种方式,包括:通过docker运行、使用springboot集成、部署camunda发行包、基于源代码编译运行等多种方式,其中,通过源代码编译集成整合方式,是最复杂的一种方式,文本重点介绍如何通过camunda7.19源代码编译,集成整合到自己的项目工程里。

下载camunda源代码

camunda开源github下载地址:https://github.com/camunda/camunda-bpm-platform

我选择camunda最后一个可支持JDK1.8的稳定版本camunda7.19

01-源码下载

camunda-bpm-platform-7.19.0版本的下载地址:

https://github.com/camunda/camunda-bpm-platform/releases/tag/7.19.0

编译camunda源代码

下载下来是一个20多M的zip压缩包,直接解压即可。

02-源码包结构

Camunda7.19源代码核心包说明:

maven工程名称

说明

camunda-database-settings

camunda支持的各种数据库定义

camunda-engine

Camunda BPMN流程引擎核心包

camunda-engine-dmn

Camunda dmn引擎核心包

camunda-engine-plugins

camunda支持的插件包

camunda-engine-rest-core

camunda发布rest服务的核心包

camunda-engine-spring

camunda集成spring框架的包

camunda-model-apis

camunda中各种模型API接口包

camunda-parent

Camunda maven工程父包,主要定义第三方Jar包版本

camunda-qa

camunda与各种环境的集成测试包

camunda-bpm-spring-boot-starter

camunda集成springboot框架的包

camunda-webapp

camunda发布web程序构建包

webapps\frontend

camunda的前端代码包,基于angular开发

首先要编译源代码,要确保下载的源代码可编译通过,建议使用maven命令行编译运行,这个时间预计1个小时左右,跟你的网络有关系,也可能有的包下载不下来失败,可多尝试几次。

我本地使用的Java jdk版本是java version "11.0.6",maven版本是Apache Maven 3.8.2,理论上jdk1.8版本以上都可以。

使用命令行cd到camunda-bpm-platform-7.19.0根目录下,使用maven命令执行编译:

mvn clean install -DskipTests=true

由于camunda源代码中有大量的测试用例,编译比较耗时,这里通过-DskipTests=true命令跳过测试用例执行。

注意:以下几个module执行涉及到第三方Jar包下载不了可能会报错,这几个跟Javaee相关的集成模块可以pom.xml中注释掉,不影响后续使用。

<module>javaee/ejb-service</module>

<module>javaee/ejb-client</module>

<module>javaee/ejb-client-jakarta</module>

<module>javaee/jobexecutor-ra</module>

<module>javaee/jobexecutor-rar</module>

我们也不会使用camunda的web前端,webapps也可注释掉。

<module>webapps</module>

最后执行mvn clean install -DskipTests=true成功的结果:

50-maven编译源码

[INFO] Reactor Summary for Camunda Platform - Root Pom 7.19.0:

[INFO]

[INFO] Camunda Platform - Root Pom ........................ SUCCESS [ 2.687 s]

[INFO] Camunda Platform - Parent Pom ...................... SUCCESS [ 0.000 s]

[INFO] Camunda Platform - database settings ............... SUCCESS [ 0.032 s]

[INFO] camunda Model APIs ................................. SUCCESS [ 0.031 s]

[INFO] Camunda Platform - Xml Model API ................... SUCCESS [ 6.407 s]

[INFO] Camunda Platform - ArchUnit ........................ SUCCESS [ 0.954 s]

[INFO] Camunda Platform - BPMN Model API .................. SUCCESS [ 12.806 s]

[INFO] Camunda Platform - CMMN Model API .................. SUCCESS [ 5.918 s]

[INFO] camunda Commons - Typed Values ..................... SUCCESS [ 5.595 s]

[INFO] Camunda Platform - DMN Model API ................... SUCCESS [ 5.078 s]

[INFO] camunda DMN - engine - root ........................ SUCCESS [ 0.062 s]

[INFO] camunda DMN - engine FEEL - API .................... SUCCESS [ 0.739 s]

[INFO] camunda DMN - engine FEEL - JUEL ................... SUCCESS [ 8.282 s]

[INFO] camunda DMN - engine FEEL - SCALA .................. SUCCESS [ 1.516 s]

[INFO] camunda DMN - engine ............................... SUCCESS [ 3.933 s]

[INFO] Camunda Test Utils - Testcontainers ................ SUCCESS [ 0.773 s]

[INFO] Camunda Platform - engine .......................... SUCCESS [02:14 min]

[INFO] Camunda Platform - engine - Spring ................. SUCCESS [ 3.640 s]

[INFO] Camunda Platform - engine plugins .................. SUCCESS [ 0.086 s]

[INFO] Camunda Platform - engine plugins - spin ........... SUCCESS [ 1.106 s]

[INFO] Camunda Platform - engine plugins - connect ........ SUCCESS [ 0.267 s]

[INFO] Camunda Platform - Assert - Root ................... SUCCESS [ 0.048 s]

[INFO] Camunda Platform - Assert .......................... SUCCESS [ 0.852 s]

[INFO] Camunda Platform - Spring Boot Starter - Root Pom .. SUCCESS [ 0.734 s]

[INFO] Camunda Platform - Spring Boot Starter - Test ...... SUCCESS [ 0.714 s]

[INFO] Camunda Platform - Spring Boot Starter ............. SUCCESS [ 4.950 s]

[INFO] Camunda Platform - Bom ............................. SUCCESS [ 0.077 s]

[INFO] Camunda Platform - Core - Internal Dependencies .... SUCCESS [ 0.040 s]

[INFO] Camunda Platform - engine - REST - Root ............ SUCCESS [ 0.036 s]

[INFO] Camunda Platform - engine - REST ................... SUCCESS [ 8.516 s]

[INFO] Camunda Platform - Spring Boot Starter - Rest ...... SUCCESS [ 0.283 s]

[INFO] Camunda Platform - Java External Task Client - ROOT SUCCESS [ 0.050 s]

[INFO] Camunda Platform - Java External Task Client - QA .. SUCCESS [ 0.051 s]

[INFO] Camunda Platform - Java External Task Client - QA VARIABLE TEST SUCCESS [ 2.222 s]

[INFO] Camunda Platform - engine - Cdi .................... SUCCESS [ 10.352 s]

[INFO] Camunda Platform - engine plugins - identity - ldap SUCCESS [ 0.704 s]

[INFO] Camunda Platform - License Book .................... SUCCESS [ 1.496 s]

[INFO] Camunda Platform - tomcat .......................... SUCCESS [ 0.044 s]

[INFO] Camunda Platform - tomcat Assembly ................. SUCCESS [ 15.426 s]

[INFO] Camunda Platform - engine - REST - Assembly ........ SUCCESS [ 7.909 s]

[INFO] Camunda Platform - Java External Task Client - CLIENT SUCCESS [ 2.110 s]

[INFO] Camunda Platform - Spring Boot Starter - Client - Spring SUCCESS [ 0.397 s]

[INFO] Camunda Platform - Spring Boot Starter - Client - Spring Boot SUCCESS [ 0.493 s]

[INFO] Camunda Platform - Spring Boot Starter - QA - Root Pom SUCCESS [ 0.085 s]

[INFO] Camunda Platform - Spring Boot Starter - QA - Simple SUCCESS [ 0.142 s]

[INFO] Camunda Platform - Spring Boot Starter - QA - Request Scope SUCCESS [ 0.144 s]

[INFO] Camunda Platform - Spring Boot Starter - QA - Plugins SUCCESS [ 0.046 s]

[INFO] Camunda Platform - Spring Boot Starter - QA - Plugins - Spin SUCCESS [ 0.033 s]

[INFO] Camunda Platform - Spring Boot Starter - QA - Plugins - Spin Json Jackson SUCCESS [ 0.204 s]

[INFO] Camunda Platform - Spring Boot Starter - QA - Plugins - Spin All SUCCESS [ 0.144 s]

[INFO] Camunda Platform - Spring Boot Starter - QA - Liquibase SUCCESS [ 0.250 s]

[INFO] Camunda Platform - webapp - webjar ................. SUCCESS [ 7.726 s]

[INFO] Camunda Platform - Spring Boot Starter - Webapps Core SUCCESS [ 0.291 s]

[INFO] Camunda Platform - Spring Boot Starter - Webapps ... SUCCESS [ 0.203 s]

[INFO] Camunda Platform - Example - Root .................. SUCCESS [ 0.053 s]

[INFO] Camunda Platform - Example - Invoice ............... SUCCESS [ 0.559 s]

[INFO] Camunda Platform - Spring Boot Starter - QA - Webapps SUCCESS [ 0.031 s]

[INFO] Camunda Platform - Spring Boot Starter - QA - Webapps Invoice Example SUCCESS [ 0.156 s]

[INFO] Camunda Platform - Spring Boot Starter - QA - Webapps Runtime SUCCESS [ 0.094 s]

[INFO] Camunda Platform - Quarkus Extension - Parent ...... SUCCESS [ 0.048 s]

[INFO] Camunda Platform - Quarkus Extension - Engine - Parent SUCCESS [ 0.046 s]

[INFO] Camunda Platform - Quarkus Extension - Engine - Runtime SUCCESS [ 1.784 s]

[INFO] Camunda Platform - Quarkus Extension - Engine - Deployment SUCCESS [ 1.618 s]

[INFO] Camunda Platform - Quarkus Extension - Engine - CDI QA SUCCESS [ 0.427 s]

[INFO] Camunda Platform - QA .............................. SUCCESS [ 0.046 s]

[INFO] Camunda Platform - QA - ensure clean db plugin ..... SUCCESS [ 0.117 s]

[INFO] Camunda Platform - QA Wildfly Test Runtime ......... SUCCESS [ 0.433 s]

[INFO] Camunda Platform - QA Wildfly 26 Test Runtime ...... SUCCESS [ 0.396 s]

[INFO] Camunda Platform - QA Tomcat Test Runtime .......... SUCCESS [ 0.050 s]

[INFO] Camunda Platform - QA Tomcat Vanilla Test Runtime .. SUCCESS [ 0.046 s]

[INFO] Camunda Platform - QA Wildfly Vanilla Test Runtime . SUCCESS [ 0.032 s]

[INFO] Camunda Platform - QA Wildfly 26 Vanilla Test Runtime SUCCESS [ 0.033 s]

[INFO] Camunda Platform - QA Integration Tests - Webapps Root SUCCESS [ 2.216 s]

[INFO] Camunda Platform - QA Integration Tests - Webapps ITs SUCCESS [ 0.698 s]

[INFO] Camunda Platform - Client .......................... SUCCESS [ 0.119 s]

[INFO] Camunda Platform - QA Integration Tests - Engine ... SUCCESS [ 4.576 s]

[INFO] Camunda Platform - EJB Client Jakarta .............. SUCCESS [ 1.170 s]

[INFO] Camunda Platform - engine - Cdi - Jakarta .......... SUCCESS [ 2.891 s]

[INFO] Camunda Platform - QA Integration Tests - Engine - Jakarta SUCCESS [ 5.385 s]

[INFO] Camunda Platform - QA - upgrade - database ......... SUCCESS [ 0.094 s]

[INFO] Camunda Platform - QA - upgrade - scenario util .... SUCCESS [ 0.250 s]

[INFO] Camunda Platform - QA - upgrade - instance migration SUCCESS [ 0.062 s]

[INFO] Camunda Platform - QA - upgrade - instance migration - test fixture - 7.2.0 SUCCESS [ 1.390 s]

[INFO] Camunda Platform - QA - upgrade - instance migration - test fixture - 7.3.0 SUCCESS [ 0.438 s]

[INFO] Camunda Platform - QA - upgrade - instance migration - test fixture - 7.4.0 SUCCESS [ 0.172 s]

[INFO] Camunda Platform - QA - upgrade - instance migration - test fixture - 7.5.0 SUCCESS [ 0.312 s]

[INFO] Camunda Platform - QA - upgrade - instance migration - test fixture - 7.6.0 SUCCESS [ 0.328 s]

[INFO] Camunda Platform - QA - upgrade - instance migration - test fixture - 7.7.0 SUCCESS [ 0.375 s]

[INFO] Camunda Platform - QA - upgrade - instance migration - test fixture - 7.8.0 SUCCESS [ 0.485 s]

[INFO] Camunda Platform - QA - upgrade - instance migration - test fixture - 7.9.0 SUCCESS [ 0.484 s]

[INFO] Camunda Platform - QA - upgrade - instance migration - test fixture - 7.10.0 SUCCESS [ 0.641 s]

[INFO] Camunda Platform - QA - upgrade - instance migration - test fixture - 7.11.0 SUCCESS [ 0.312 s]

[INFO] Camunda Platform - QA - upgrade - instance migration - test fixture - 7.12.0 SUCCESS [ 0.844 s]

[INFO] Camunda Platform - QA - upgrade - instance migration - test fixture - 7.13.0 SUCCESS [ 0.609 s]

[INFO] Camunda Platform - QA - upgrade - instance migration - test fixture - 7.14.0 SUCCESS [ 0.828 s]

[INFO] Camunda Platform - QA - upgrade - instance migration - test fixture - 7.15.0 SUCCESS [ 0.859 s]

[INFO] camunda BPM - QA - upgrade - instance migration - test fixture - 7.16.0 SUCCESS [ 0.844 s]

[INFO] camunda BPM - QA - upgrade - instance migration - test fixture - 7.17.0 SUCCESS [ 0.640 s]

[INFO] camunda BPM - QA - upgrade - instance migration - test fixture - 7.18.0 SUCCESS [ 0.469 s]

[INFO] camunda BPM - QA - upgrade - instance migration - test fixture - 7.19.0 SUCCESS [ 0.172 s]

[INFO] Camunda Platform - QA - upgrade - instance migration - test SUCCESS [ 0.516 s]

[INFO] Camunda Platform - QA - upgrade - rolling update ... SUCCESS [ 0.054 s]

[INFO] Camunda Platform - QA - upgrade - rolling update util SUCCESS [ 0.133 s]

[INFO] Camunda Platform - QA - upgrade - rolling update - create old engine SUCCESS [ 0.219 s]

[INFO] Camunda Platform - QA - upgrade - rolling update - create new engine SUCCESS [ 0.187 s]

[INFO] Camunda Platform - QA - upgrade - rolling update - test old engine SUCCESS [ 0.203 s]

[INFO] Camunda Platform - QA - test new schema with old engine SUCCESS [ 0.063 s]

[INFO] Camunda Platform - QA Performance Tests Engine ..... SUCCESS [ 9.141 s]

[INFO] Large Data Tests ................................... SUCCESS [ 0.203 s]

[INFO] camunda DMN - engine - bom ......................... SUCCESS [ 0.031 s]

[INFO] Camunda Platform - JUnit 5 Extension ............... SUCCESS [ 0.242 s]

[INFO] Camunda Platform - QA - Assert ..................... SUCCESS [ 0.141 s]

[INFO] Camunda Platform - engine - Cdi - Compatbility Test Weld 3 SUCCESS [ 0.443 s]

[INFO] Camunda Platform - engine - CDI - Root ............. SUCCESS [ 0.041 s]

[INFO] Camunda Platform - engine - Compatbility Test Spring 4 SUCCESS [ 0.328 s]

[INFO] Camunda Platform - engine - Spring - Root .......... SUCCESS [ 0.032 s]

[INFO] Camunda Platform - engine - REST - OpenAPI (JSON Generator) SUCCESS [ 0.109 s]

[INFO] Camunda Platform - engine - REST - OpenAPI ......... SUCCESS [ 41.661 s]

[INFO] Camunda Platform - engine - REST Jakarta ........... SUCCESS [01:28 min]

[INFO] Camunda Platform - engine - REST - Assembly Jakarta SUCCESS [ 2.850 s]

[INFO] Camunda Platform - Example - Invoice Jakarta ....... SUCCESS [ 2.167 s]

[INFO] Camunda Platform - JBoss ........................... SUCCESS [ 0.019 s]

[INFO] Camunda Platform - webapp - JBoss .................. SUCCESS [ 5.335 s]

[INFO] Camunda Platform - webapp - JBoss Standalone ....... SUCCESS [ 8.444 s]

[INFO] Camunda Platform - SQL scripts ..................... SUCCESS [ 15.140 s]

[INFO] Camunda Platform - webapp - Tomcat ................. SUCCESS [ 3.849 s]

[INFO] Camunda Platform - tomcat Distro ................... SUCCESS [ 39.697 s]

[INFO] Camunda Platform - webapp - Tomcat Standalone ...... SUCCESS [ 7.264 s]

[INFO] Camunda Platform - Run - Root ...................... SUCCESS [ 0.022 s]

[INFO] Camunda Platform - Run - Modules ................... SUCCESS [ 0.038 s]

[INFO] Camunda Platform - Run - Module REST ............... SUCCESS [ 12.390 s]

[INFO] camunda Platform - Run - Module Swagger UI ......... SUCCESS [17:24 min]

[INFO] Camunda Platform - Run - Module Example Invoice .... SUCCESS [ 8.375 s]

[INFO] Camunda Platform - Run - Core ...................... SUCCESS [ 9.920 s]

[INFO] Camunda Platform - Run - Assembly .................. SUCCESS [ 9.158 s]

[INFO] Camunda Platform - Run - QA ........................ SUCCESS [ 0.029 s]

[INFO] Camunda Platform - Run - QA - Integration Tests .... SUCCESS [12:17 min]

[INFO] Camunda Platform - Run - Module Webapps ............ SUCCESS [ 0.308 s]

[INFO] Camunda Platform - Run - Distribution .............. SUCCESS [ 30.881 s]

[INFO] Camunda Platform - Run - QA - Runtime .............. SUCCESS [ 0.566 s]

[INFO] Camunda Platform - Wildfly ......................... SUCCESS [ 0.056 s]

[INFO] Camunda Platform - Wildfly Subsystem ............... SUCCESS [ 26.416 s]

[INFO] Camunda Platform - Wildfly Modules ................. SUCCESS [ 15.832 s]

[INFO] Camunda Platform - Wildfly Assembly ................ SUCCESS [01:23 min]

[INFO] Camunda Platform - webapp - WildFly ................ SUCCESS [ 9.859 s]

[INFO] Camunda Platform - Wildfly Distro .................. SUCCESS [01:34 min]

[INFO] Camunda Platform - Wildfly 26 ...................... SUCCESS [ 0.043 s]

[INFO] Camunda Platform - Wildfly 26 Subsystem ............ SUCCESS [ 28.524 s]

[INFO] Camunda Platform - Wildfly 26 Modules .............. SUCCESS [ 22.495 s]

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 44:25 min

[INFO] Finished at: 2024-02-17T13:45:01+08:00

[INFO] ---------------------------------------------------------------------

这是在我本地笔记本上编译的结果,用了44分钟完成了camunda7.19源代码的编译和打包。

构建camunda源代码工程

Camunda 7.19源代码一共有178个maven工程和1个angular前端工程,这么多工程中包括了大量的QA测试包、JDK不同版本适配(比如:Java EE和Jakarta EE)、多种中间件部署包(比如:Tomcat、Jboss、wildfly)、spring和springboot集成适配包等,我们仅仅需要把Camunda的流程引擎包和REST服务包的源代码拿来使用,下面通过IDEA开发工具,从代码层面整合Camunda的流程引擎源代码。

3.1、Camunda包结构分析

Camunda 7.19源代码一共有178个maven工程和1个angular前端工程,他们之间有什么样的依赖和引用关系,我们首先要分析清楚,然后才能把流程引擎和resf服务包的源代码拷贝过来使用。

下面我们就分析camunda-bpm-platform-7.19.0源代码中pom工程的引用和依赖关系。

首先,打开camunda-bpm-platform-7.19.0\engine工程的pom.xml,发现该工程继承了父工程camunda-database-settings。

13-pom包依赖分析

打开父工程camunda-bpm-platform-7.19.0\database的pom.xml,发现它又继承了父工程camunda-parent。

14-pom包依赖分析2

打开父工程camunda-bpm-platform-7.19.0\parent的pom.xml,发现它又继承了父工程camunda-root。

15-pom包依赖分析3

打开父工程camunda-bpm-platform-7.19.0根目录下的pom.xml,发现它又继承了父工程camunda-bpm-release-parent,该工程没有源代码,就是camunda官方定义的发布版本的顶级工程了,是通过mvn依赖动态下载的。

16-pom包依赖分析4

至此,我们从camunda流程引擎内核包入手分析,找到了相关maven工程父子继承关系,即engine(BPMN流程引擎核心工程)—》database(多种数据库配置工程)—》parent(第三方Jar配置工程)—》root(camunda源代码聚合工程)。

有了以上分析,下面我们在自己的笔记本电脑上新建Java工程,把camunda核心源代码拷贝进来编译通过,最后通过springboot方式,把camunda源代码运行起来。

3.2、新建maven聚合工程

新建pom父工程,命名为camunda7-source-dev,version设置为7.19-SNAPSHOT,注意packaging的值为pom,该工程为聚合项目。

10-新建pom父工程

该工程的目的就是多个maven工程聚合,也可以根据需要配置一些manve的全局设置,比如仓库地址。

Pom.xml源文件如下:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.yuncheng</groupId>
<artifactId>camunda7-source-dev</artifactId>
<version>7.19-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<!-- <module>camunda-engine</module>-->
<!-- <module>camunda-engine-rest</module>-->
<!-- <module>camunda-boot</module>-->
</modules>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

</project>

3.3、新建maven父工程

通过以上分析camunda工程结构,发现camunda-engine流程引擎依赖了camunda-parent工程,而camunda-parent工程里定义了流程引擎需要的第三方Jar。这里我们也参考camunda-parent工程,新建一个自己的parent工程。

在刚才建的聚合工程camunda7-source-dev下,新建一个camunda-parent子工程。

65-parent父工程

我们需要把camunda-bpm-platform-7.19.0\parent\pom.xml文件内容拷贝过来,最后的pom.xml源文件如下:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.yuncheng</groupId>
<artifactId>camunda7-source-dev</artifactId>
<version>7.19-SNAPSHOT</version>
</parent>
<packaging>pom</packaging>

<artifactId>camunda-parent</artifactId>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<license.includeTransitiveDependencies>false</license.includeTransitiveDependencies>
<!-- These properties are used in both the BOM as well as camunda-parent and subprojects -->
<version.camunda>7.19.0</version.camunda>
<version.mybatis>3.5.6</version.mybatis>
<version.joda-time>2.1</version.joda-time>
<version.uuid-generator>3.2.0</version.uuid-generator>
<version.camunda.commons>1.12.0</version.camunda.commons>
<version.camunda.connect>1.5.6</version.camunda.connect>
<version.camunda.spin>1.19.0</version.camunda.spin>
<version.camunda.template-engines>2.1.0</version.camunda.template-engines>
<version.camunda.ee.xslt-plugin>1.1.0</version.camunda.ee.xslt-plugin>
<version.feel-scala>1.15.3</version.feel-scala>
<plugin.version.javadoc>3.0.1</plugin.version.javadoc>

<!-- database driver versions -->
<version.h2>2.1.214</version.h2>
<version.h2-v1>1.4.190</version.h2-v1><!-- used for instance migration qa -->
<version.oracle-12>12.1.0.2</version.oracle-12>
<version.oracle-19>19.3.0.0</version.oracle-19>
<version.oracle>${version.oracle-12}</version.oracle>
<version.mariadb>1.7.6</version.mariadb>
<version.mariadb-v1>1.1.8</version.mariadb-v1>
<version.mysql>8.0.32</version.mysql>
<version.sqlserver>8.4.1.jre8</version.sqlserver>
<version.db2-11.5>11.5.0.0</version.db2-11.5>
<version.db2>${version.db2-11.5}</version.db2>
<version.postgresql>42.5.4</version.postgresql>
<version.liquibase>4.8.0</version.liquibase>

<!-- CockroachDB is compatible with PostgreSQL 9.5,
so a different version of the JDBC driver needs to be used -->
<version.cockroachdb>42.2.9</version.cockroachdb>

<!-- needed for sql script and backward compatibility checks -->
<camunda.version.old>7.18.0</camunda.version.old>

<!-- Testcontainers JDBC URL parameters. By default, an empty string -->
<database.tc.params />


<version.quarkus>2.16.4.Final</version.quarkus>
<version.spring.framework>5.3.22</version.spring.framework>
<version.spring-boot>2.7.9</version.spring-boot>
<version.cxf>3.0.3</version.cxf>
<version.resteasy>3.15.3.Final</version.resteasy>
<version.jersey2>2.34</version.jersey2>
<!-- use minimum version of resteasy and jersey -->
<version.jaxrs.api>2.0.1.Final</version.jaxrs.api>
<version.groovy>2.4.21</version.groovy>
<version.graal.js>21.1.0</version.graal.js>
<version.icu.icu4j>68.2</version.icu.icu4j>
<version.gson>2.8.9</version.gson>
<version.openjpa>2.4.3</version.openjpa>
<version.hibernate>5.6.5.Final</version.hibernate>
<version.hikaricp>4.0.3</version.hikaricp>
<version.jackson>2.14.1</version.jackson>
<version.xml.bind-api>2.3.3</version.xml.bind-api>
<version.xml.jaxb-impl>2.3.6</version.xml.jaxb-impl>
<version.snakeyaml>1.33</version.snakeyaml>

<version.slf4j>1.7.26</version.slf4j>
<version.logback>1.2.11</version.logback>
<version.junit>4.13.1</version.junit>
<version.assertj>2.9.1</version.assertj>
<version.mockito>4.3.1</version.mockito>
<version.wiremock>2.27.2</version.wiremock>
<version.wiremock-jre8>2.27.2</version.wiremock-jre8>
<version.testcontainers>1.16.0</version.testcontainers>

<version.commonj>1.1.0</version.commonj>
<version.bouncycastle>1.47</version.bouncycastle>

<!-- application servers -->
<version.wildfly>27.0.1.Final</version.wildfly>
<version.wildfly.core>19.0.1.Final</version.wildfly.core>
<version.wildfly26>26.0.1.Final</version.wildfly26>
<version.wildfly26.core>18.0.4.Final</version.wildfly26.core>

<version.tomcat>9.0.72</version.tomcat>

<version.arquillian>1.1.10.Final</version.arquillian>
<version.shrinkwrap.resolvers>2.2.2</version.shrinkwrap.resolvers>
<version.selenium>4.1.4</version.selenium>
<version.freemarker>2.3.31</version.freemarker>

<version.jboss-javaee-spec>3.0.2.Final</version.jboss-javaee-spec>
<version.jakarta-ee-spec>10.0.0</version.jakarta-ee-spec>
</properties>

<dependencyManagement>
<dependencies>

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${version.h2}</version>
</dependency>
<dependency>
<groupId>com.oracle.jdbc</groupId>
<artifactId>ojdbc7</artifactId>
<version>${version.oracle}</version>
</dependency>
<dependency>
<groupId>com.oracle.ojdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>${version.oracle}</version>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>${version.mariadb}</version>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>${version.mysql}</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>${version.sqlserver}</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${version.postgresql}</version>
</dependency>
<dependency>
<groupId>com.ibm.db2</groupId>
<artifactId>jcc</artifactId>
<version>${version.db2}</version>
</dependency>

<dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-bom</artifactId>
<version>${version.camunda}</version>
<type>pom</type>
<scope>import</scope>
</dependency>

</dependencies>
</dependencyManagement>

<build>
<pluginManagement>
<plugins>
<!-- test plugins -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<runOrder>hourly</runOrder>
<systemPropertyVariables>
<myWorkingDir>${project.build.directory}</myWorkingDir>
</systemPropertyVariables>
<argLine>-Xmx968m -Duser.language=en -Duser.region=US -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${project.build.directory}/heap_dump.hprof</argLine>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.16</version>
<configuration>
<argLine>-Xmx968m</argLine>
<runOrder>hourly</runOrder>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- code plugins -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
</plugin>

<!-- artifact plugins -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<configuration>
<createSourcesJar>true</createSourcesJar>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven3-plugin</artifactId>
<version>1.10.5</version>
</plugin>
<plugin>
<groupId>net.kennychua</groupId>
<artifactId>maven-urlpoller-plugin</artifactId>
<version>1.0.3</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.5</version>
<configuration>
<keepFormat>true</keepFormat>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>clirr-maven-plugin</artifactId>
<version>2.8</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<failOnError>false</failOnError>
<additionalJOptions>
<additionalJOption>-Xdoclint:none</additionalJOption>
<additionalJOption>--ignore-source-errors</additionalJOption>
</additionalJOptions>
<doctitle>Camunda Platform Javadocs ${project.version}</doctitle>
<windowtitle>Camunda Platform Javadocs ${project.version}</windowtitle>
</configuration>
</plugin>

</plugins>
</pluginManagement>
</build>

<profiles>

</profiles>

<repositories>
<repository>
<id>JBoss public</id>
<name>jboss</name>
<url>https://repository.jboss.org/nexus/content/groups/public/</url>
</repository>
<!-- required for commonJ dependency -->
<repository>
<id>com.springsource.repository.bundles.external</id>
<name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
<url>https://repo.spring.io/plugins-release</url>
</repository>
</repositories>

<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>

<organization>
<name>camunda services GmbH</name>
<url>http://www.camunda.com</url>
</organization>

<url>http://www.camunda.org</url>
</project>

3.4、新建流程引擎源码工程

在聚合工程camunda7-source-dev下,新建一个camunda-engine流程引擎子工程,需要把该工程的父工程配置为camunda-parent。

66-流程引擎工程

我们需要把camunda-bpm-platform-7.19.0\engine\pom.xml文件内容拷贝过来,最后的pom.xml源文件如下:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.yuncheng</groupId>
<artifactId>camunda-parent</artifactId>
<version>7.19-SNAPSHOT</version>
<relativePath>../camunda-parent</relativePath>
</parent>

<artifactId>camunda-engine</artifactId>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<test.includes />
<!-- without a special test profile we don't want to exclude anything, this expressions should never match -->
<test.excludes>$.</test.excludes>
<history.level>full</history.level>
<mail.server.port>5025</mail.server.port>
<authorizationCheckRevokes>auto</authorizationCheckRevokes>
<jdbcBatchProcessing>true</jdbcBatchProcessing>

<!-- We shade artifacts into the jar, so we need to generate a dependency BOM
for the license book -->
<skip-third-party-bom>false</skip-third-party-bom>

<camunda.artifact>org.camunda.bpm</camunda.artifact>
<version.camunda>7.19.0</version.camunda>
</properties>

<dependencyManagement>
<dependencies>

<dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-core-internal-dependencies</artifactId>
<version>${version.camunda}</version>
<scope>import</scope>
<type>pom</type>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>${version.spring.framework}</version>
<type>pom</type>
<scope>import</scope>
</dependency>

<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-bom</artifactId>
<version>${version.jakarta-ee-spec}</version>
<type>pom</type>
<scope>import</scope>
</dependency>

</dependencies>
</dependencyManagement>

<dependencies>

<!-- camunda dependencies -->

<dependency>
<groupId>org.camunda.bpm.model</groupId>
<artifactId>camunda-bpmn-model</artifactId>
</dependency>

<dependency>
<groupId>org.camunda.bpm.model</groupId>
<artifactId>camunda-cmmn-model</artifactId>
</dependency>

<dependency>
<groupId>org.camunda.bpm.dmn</groupId>
<artifactId>camunda-engine-dmn</artifactId>
<exclusions>
<exclusion>
<groupId>de.odysseus.juel</groupId>
<artifactId>juel-api</artifactId>
</exclusion>
<exclusion>
<groupId>de.odysseus.juel</groupId>
<artifactId>juel-spi</artifactId>
</exclusion>
<exclusion>
<groupId>de.odysseus.juel</groupId>
<artifactId>juel-impl</artifactId>
</exclusion>
<!-- these exclusions are needed when building with Maven >= 3.3
see CAM-11822 for details -->
<exclusion>
<groupId>com.lihaoyi</groupId>
<artifactId>fastparse_2.13</artifactId>
</exclusion>
<exclusion>
<groupId>com.lihaoyi</groupId>
<artifactId>sourcecode_2.13</artifactId>
</exclusion>
<exclusion>
<groupId>com.lihaoyi</groupId>
<artifactId>geny_2.13</artifactId>
</exclusion>
<exclusion>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.camunda.commons</groupId>
<artifactId>camunda-commons-logging</artifactId>
</dependency>

<dependency>
<groupId>org.camunda.commons</groupId>
<artifactId>camunda-commons-typed-values</artifactId>
</dependency>

<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</dependency>

<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</dependency>

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>

<dependency>
<groupId>org.camunda.connect</groupId>
<artifactId>camunda-connect-core</artifactId>
</dependency>

<dependency>
<groupId>org.camunda.connect</groupId>
<artifactId>camunda-connect-connectors-all</artifactId>
<scope>runtime</scope>
</dependency>

<!-- provided dependencies -->

<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jta_1.1_spec</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.fasterxml.uuid</groupId>
<artifactId>java-uuid-generator</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-web-6.0</artifactId>
<type>pom</type>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>jakarta.transaction</groupId>
<artifactId>jakarta.transaction-api</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>jakarta.ejb</groupId>
<artifactId>jakarta.ejb-api</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>catalina</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-vfs</artifactId>
<version>3.1.0.Final</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-email</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>provided</scope>
</dependency>

<!-- test dependencies -->

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.subethamail</groupId>
<artifactId>subethasmtp-wiser</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<!-- required for DiagramQueryTest -->
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.camunda.commons</groupId>
<artifactId>camunda-commons-testing</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-test-utils-testcontainers</artifactId>
<version>${version.camunda}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-jsr223</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.python</groupId>
<artifactId>jython</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.jruby</groupId>
<artifactId>jruby-complete</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.graalvm.js</groupId>
<artifactId>js</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.graalvm.js</groupId>
<artifactId>js-scriptengine</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-bpm-archunit</artifactId>
<version>${version.camunda}</version>
<scope>test</scope>
</dependency>
</dependencies>


<build>
<!-- filter test configurations to inject properties -->
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>org/camunda/bpm/engine/product-info.properties</include>
</includes>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/camunda.cfg.xml</include>
<include>**/*camunda.cfg.xml</include>
<include>**/camunda.cfg.*.xml</include>
<include>testconfig.properties</include>
<include>**/testcontainers.properties</include>
</includes>
</testResource>
</testResources>

<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<failIfNoTests>false</failIfNoTests>
<trimStackTrace>false</trimStackTrace>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<includes>
<include>%regex[.*(${test.includes}).*Test.*.class]</include>
</includes>
<excludes>
<exclude>**/*TestCase.java</exclude>
<exclude>%regex[.*(${test.excludes}).*Test.*.class]</exclude>
</excludes>
<dependenciesToScan>
<dependency>org.camunda.bpm:camunda-bpm-archunit</dependency>
</dependenciesToScan>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>cleanVersions</goal>
</goals>
</execution>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<configuration>
<promoteTransitiveDependencies>false</promoteTransitiveDependencies>
<createSourcesJar>true</createSourcesJar>
<createDependencyReducedPom>true</createDependencyReducedPom>
<keepDependenciesWithProvidedScope>true</keepDependenciesWithProvidedScope>
<artifactSet>
<excludes>
<exclude>org.camunda.bpm.model:*</exclude>
<exclude>org.camunda.bpm.dmn:*</exclude>
<exclude>org.camunda.commons:*</exclude>
<exclude>org.camunda.connect:*</exclude>
<exclude>org.camunda.feel:*</exclude>

<exclude>org.springframework:*</exclude>
<exclude>org.slf4j:*</exclude>
<exclude>org.apache.commons:*</exclude>
<exclude>com.sun.mail:*</exclude>
<exclude>javax.activation:*</exclude>
<exclude>org.mybatis:mybatis:*</exclude>
<exclude>commons-logging:*</exclude>
<exclude>joda-time:*</exclude>
</excludes>
</artifactSet>
<relocations>
<relocation>
<pattern>com.google.gson</pattern>
<shadedPattern>camundajar.impl.com.google.gson</shadedPattern>
</relocation>
</relocations>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
</transformers>
<shadeTestJar>true</shadeTestJar>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>copy-upgrade-scripts-liquibase</id>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>

<!-- copy all upgrade scripts after 7.15 -->
<mkdir dir="target/classes/org/camunda/bpm/engine/db/liquibase/upgrade" />
<copy todir="target/classes/org/camunda/bpm/engine/db/liquibase/upgrade">
<fileset dir="target/classes/org/camunda/bpm/engine/db/upgrade" excludes="*_6.*_*,*_7.0_*,*_7.1_*,*_7.2_*,*_7.3_*,*_7.4_*,*_7.5_*,*_7.6_*,*_7.7_*, *_7.8_*,*_7.9_*,*_7.10_*,*_7.11_*,*_7.12_*,*_7.13_*,*_7.14_*,*_7.15_*" />
</copy>

</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.felix</groupId>
<artifactId>
maven-bundle-plugin
</artifactId>
<versionRange>
[2.1.0,)
</versionRange>
<goals>
<goal>cleanVersions</goal>
<goal>manifest</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

<profiles>
<profile>
<id>distro</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

<profile>
<id>h2-in-memory</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<database.url>jdbc:h2:mem:camunda;DB_CLOSE_DELAY=1000;LOCK_TIMEOUT=10000</database.url>
<database.driver>org.h2.Driver</database.driver>
<database.username>sa</database.username>
<database.password />
<hibernate.dialect>org.hibernate.dialect.H2Dialect</hibernate.dialect>
</properties>
<dependencies>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${version.h2}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>

</profiles>

</project>

到这里,你可以通过IDEA的maven工具先执行mvn clean install命令,把相关依赖包下载下来,同时验证一下这几个maven工程是否能编译通过。

接下来,拷贝camunda-bpm-platform-7.19.0\engine引擎包下的源代码到自己刚刚新建的camunda-engine工程下,再执行mvn clean install命令进行编译打包,检查是否可以通过。由于camunda-engine源代码中有大量的测试用例,编译比较耗时,这里通过mvn clean install -DskipTests=true命令跳过测试用例执行。

3.5、新建REST服务源码工程

在聚合工程camunda7-source-dev下,新建一个camunda-engine-rest流程引擎rest服务子工程,需要把该工程的父工程配置为camunda-parent。

67-流程引擎rest工程

我们需要把camunda-bpm-platform-7.19.0\engine-rest\engine-rest\pom.xml文件内容拷贝过来,最后的pom.xml源文件如下:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.yuncheng</groupId>
<artifactId>camunda-parent</artifactId>
<version>7.19-SNAPSHOT</version>
<relativePath>../camunda-parent</relativePath>
</parent>

<artifactId>camunda-engine-rest</artifactId>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.rest-assured>4.5.0</version.rest-assured>
<!-- override groovy version with the one used by rest-assured -->
<version.groovy>3.0.9</version.groovy>
<version.apache.httpcore>4.4.5</version.apache.httpcore>
<version.commons-codec>1.15</version.commons-codec>
<!-- pin tomcat version for engine-rest -->
<version.tomcat>7.0.50</version.tomcat>
<rest.http.port>38080</rest.http.port>
<javax.activation.version>1.1.1</javax.activation.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${version.spring-boot}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-bom</artifactId>
<version>${version.groovy}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-core-internal-dependencies</artifactId>
<version>${version.camunda}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>${version.xml.jaxb-impl}</version>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>${version.rest-assured}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-bom</artifactId>
<version>${version.jackson}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>${version.apache.httpcore}</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>${version.commons-codec}</version>
</dependency>
</dependencies>

</dependencyManagement>

<dependencies>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<exclusions>
<exclusion>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- override managed version from commons-fileupload -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<exclusions>
<exclusion>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
</exclusion>
<exclusion>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>

<!-- provided deps -->
<dependency>
<groupId>org.jboss.spec.javax.servlet</groupId>
<artifactId>jboss-servlet-api_3.0_spec</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.yuncheng</groupId>
<artifactId>camunda-engine</artifactId>
<version>7.19-SNAPSHOT</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-jcl</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.camunda.commons</groupId>
<artifactId>camunda-commons-logging</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>${javax.activation.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<scope>test</scope>
</dependency>

<!-- test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<version>${version.tomcat}</version>
<scope>test</scope>
</dependency>


<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${version.spring.framework}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-jcl</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- Tomcat for resteasy and wink -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.camunda.commons</groupId>
<artifactId>camunda-commons-testing</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>${version.tomcat}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-logging-juli</artifactId>
<version>${version.tomcat}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<restEasyVersion>${version.resteasy}</restEasyVersion>
</systemPropertyVariables>
</configuration>
</plugin>

</plugins>
</build>

<profiles>
<profile>
<id>distro</id>
<dependencies>
<dependency>
<groupId>org.jboss.spec.javax.ws.rs</groupId>
<artifactId>jboss-jaxrs-api_2.1_spec</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
</profile>

<profile>
<id>jersey2</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-grizzly2-http</artifactId>
<version>${version.jersey2}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>${version.jersey2}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>${version.jersey2}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/rest/standalone/**</exclude>
</excludes>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
</configuration>
<executions>
<execution>
<id>encoding-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<argLine>-Dfile.encoding=ISO-8859-1</argLine>
<includes>
<include>**/ProcessDefinitionRestServiceInteractionTest.java</include>
<include>**/TaskRestServiceInteractionTest.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-test-source</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/test/java-jersey2</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-test-resource</id>
<phase>generate-test-resources</phase>
<goals>
<goal>add-test-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>src/test/resources-jersey2</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

</profiles>
</project>

接下来,拷贝camunda-bpm-platform-7.19.0\engine-rest\engine-rest工程下的源代码到自己刚刚新建的工程里,再执行mvn clean install命令进行编译打包,检查是否可以通过。

3.6、新建Springboot启动工程

以上4个步骤新建了4个Java maven工程,如果这4个工程均可编译通过,说明camunda源代码迁移这一步骤是没有问题的,接下来就是需要把camunda流程引擎基于源代码方式运行起来。

在聚合工程camunda7-source-dev下,新建一个名称为camunda-boot 的工程,即流程引擎的springboot启动工程。

68-流程引擎boot工程

在该工程下把需要把刚刚新建的流程引擎工程camunda-engine和流程引擎服务工程camunda-engine-rest引入进来,确保它是基于源代码运行的,最后的pom.xml源文件如下:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.yuncheng</groupId>
<artifactId>camunda-parent</artifactId>
<version>7.19-SNAPSHOT</version>
<relativePath>../camunda-parent</relativePath>
</parent>

<artifactId>camunda-boot</artifactId>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!--定义使用camunda的版本-->
<version.camunda>7.19.0</version.camunda>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${version.spring-boot}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>

<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.2.15</version>
</dependency>

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>

<dependency>
<groupId>com.yuncheng</groupId>
<artifactId>camunda-engine</artifactId>
<version>7.19-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>com.yuncheng</groupId>
<artifactId>camunda-engine-rest</artifactId>
<version>7.19-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.camunda.bpm.springboot</groupId>
<artifactId>camunda-bpm-spring-boot-starter-rest</artifactId>
<version>${version.camunda}</version>
<!--排除官方引用jar包,用自己工程里的源代码包-->
<exclusions>
<exclusion>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-engine</artifactId>
</exclusion>
<exclusion>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-engine-rest-core</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.camunda.bpm.springboot</groupId>
<artifactId>camunda-bpm-spring-boot-starter</artifactId>
<version>${version.camunda}</version>
<!--排除官方引用jar包,用自己工程里的源代码包-->
<exclusions>
<exclusion>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-engine</artifactId>
</exclusion>
</exclusions>
</dependency>

</dependencies>

</project>

接下来,新建一个SpringBootApplication启动类:


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

@SpringBootApplication
public class Camunda7Application {

private static final Logger log = LoggerFactory.getLogger(Camunda7Application.class);

public static void main(String[] args) {
ConfigurableApplicationContext application = SpringApplication.run(Camunda7Application.class, args);
Environment env = application.getEnvironment();
String port = env.getProperty("server.port");
String path = env.getProperty("server.servlet.context-path");
if (path == null || "".equals(path)) {
path = "/";
}
log.info("\n----------------------------------------------------------\n" +
"\tApplication is running!\n" +
"\tPort:\t" + port + "\n" +
"\tPath:\t" + path + "\n" +
"----------------------------------------------------------");
}
}

最后,新建一个springboot启动的application.yaml配置文件,我这里用的是druid连接池,H2数据库,你也可以根据需要切换成mysql数据库:

server:
port: 8080
spring:
datasource:
# url: jdbc:mysql://127.0.0.1:3306/camunda719?characterEncoding=UTF-8&useUnicode=true&useSSL=false&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai
# username: root
# password: root
# driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:h2:mem:camunda;DB_CLOSE_DELAY=1000;LOCK_TIMEOUT=10000
username: sa
password:
driver-class-name: org.h2.Driver
camunda:
bpm:
database:
type: h2 #可改成 mysql
schema-update: true
auto-deployment-enabled: false # 自动部署 resources 下的 bpmn文件
admin-user:
id: demo
password: demo

以上这些完成后,启动springboot工程即可。

69-流程引擎boot启动成功

至此,我们完成了基于camunda源代码编译和运行流程引擎,接下来通过rest服务接口验证camunda流程引擎的功能。

4、测试验证camunda

4.1、发布流程模型

先通过camunda的流程设计器设计一个流程,命名为:UserTask Flow1,然后发布流程,发布流程的接口是我们通过源代码发布的rest服务接口,地址为:http://localhost:8080/engine-rest

51-发布流程

该bpmn流程设计比较简单,就是两个人工处理节点,处理人设置为demo,camunda系统初始化后默认的一个测试用户。UserTask Flow1.bpmn源文件如下:

<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_0lwtj60" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.19.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.20.0">
<bpmn:process id="Process_15r7d3m" name="UserTask Flow1" isExecutable="true" camunda:historyTimeToLive="180">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>Flow_11x673q</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="Flow_11x673q" sourceRef="StartEvent_1" targetRef="Activity_10ell5p" />
<bpmn:sequenceFlow id="Flow_0foitiz" sourceRef="Activity_10ell5p" targetRef="Activity_09u1so2" />
<bpmn:endEvent id="Event_0e68o48">
<bpmn:incoming>Flow_01cgzte</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_01cgzte" sourceRef="Activity_09u1so2" targetRef="Event_0e68o48" />
<bpmn:userTask id="Activity_10ell5p" name="申请" camunda:assignee="demo">
<bpmn:incoming>Flow_11x673q</bpmn:incoming>
<bpmn:outgoing>Flow_0foitiz</bpmn:outgoing>
</bpmn:userTask>
<bpmn:userTask id="Activity_09u1so2" name="审批" camunda:assignee="demo">
<bpmn:incoming>Flow_0foitiz</bpmn:incoming>
<bpmn:outgoing>Flow_01cgzte</bpmn:outgoing>
</bpmn:userTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_15r7d3m">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="179" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1xzvv8s_di" bpmnElement="Activity_10ell5p">
<dc:Bounds x="270" y="77" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1h27nqt_di" bpmnElement="Activity_09u1so2">
<dc:Bounds x="460" y="77" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0e68o48_di" bpmnElement="Event_0e68o48">
<dc:Bounds x="652" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_11x673q_di" bpmnElement="Flow_11x673q">
<di:waypoint x="215" y="117" />
<di:waypoint x="270" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_01cgzte_di" bpmnElement="Flow_01cgzte">
<di:waypoint x="560" y="117" />
<di:waypoint x="652" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0foitiz_di" bpmnElement="Flow_0foitiz">
<di:waypoint x="370" y="117" />
<di:waypoint x="460" y="117" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

点击Deploy流程发布按钮

52-发布成功

提示流程发布成功了,流程模型定义ID也显示了出来!

4.2、查询流程定义

接下来我们验证是否流程发布成功了,可以通过camunda流程引擎的服务接口查看。camunda平台提供了详细的rest服务接口,详细见文档:

https://docs.camunda.org/rest/camunda-bpm-platform/7.19/

64-rest服务接口

查看流程定义rest接口:http://{host}:{port}/{contextPath}/process-definition

用Postman测试验证:http://localhost:8080/engine-rest/process-definition

63-postman查看流程定义

返回结果:

[

    {

        "id": "Process_15r7d3m:1:80b53453-cfc5-11ee-a32c-32f6efb33b52",

        "key": "Process_15r7d3m",

        "category": "http://bpmn.io/schema/bpmn",

        "description": null,

        "name": "UserTask Flow1",

        "version": 1,

        "resource": "UserTask Flow1.bpmn",

        "deploymentId": "80719ba1-cfc5-11ee-a32c-32f6efb33b52",

        "diagram": null,

        "suspended": false,

        "tenantId": null,

        "versionTag": null,

        "historyTimeToLive": 180,

        "startableInTasklist": true

    }

]

4.3、发起一个流程

通过服务接口发起流程,去官方网站查找发起流程的rest接口:

54-发起流程rest接口

流程发起的rest接口为:http://{host}:{port}/{contextPath}/process-definition/key/{key}/start

详细接口描述见官方文档:https://docs.camunda.org/rest/camunda-bpm-platform/7.19/#tag/Process-Definition/operation/startProcessInstanceByKey

打开postman工具进行测试验证:http://localhost:8080/engine-rest/process-definition/key/Process_15r7d3m/start

55-postman发起流程

输入JSON

{

  "variables": {

    "variable1": {

      "value": "hello",

      "type": "String"

    },

    "variable2": {

      "value": true,

      "type": "Boolean"

    }

  },

  "businessKey": "myBusinessKey-test1"

}

返回结果:

{

    "links": [

        {

            "method": "GET",

            "href": "http://localhost:8080/engine-rest/process-instance/2881747c-cfca-11ee-a32c-32f6efb33b52",

            "rel": "self"

        }

    ],

    "id": "2881747c-cfca-11ee-a32c-32f6efb33b52",

    "definitionId": "Process_15r7d3m:1:80b53453-cfc5-11ee-a32c-32f6efb33b52",

    "businessKey": "myBusinessKey-test1",

    "caseInstanceId": null,

    "ended": false,

    "suspended": false,

    "tenantId": null

}

4.4、查询流程状态

查看流程实例的rest接口为:http://{host}:{port}/{contextPath}/process-instance/{id}

56-查看流程实例接口

用postman发起请求:http://localhost:8080/engine-rest/process-instance/2881747c-cfca-11ee-a32c-32f6efb33b52

57-postman查看流程实例

返回:

{

    "links": [],

    "id": "2881747c-cfca-11ee-a32c-32f6efb33b52",

    "definitionId": "Process_15r7d3m:1:80b53453-cfc5-11ee-a32c-32f6efb33b52",

    "businessKey": "myBusinessKey-test1",

    "caseInstanceId": null,

    "ended": false,

    "suspended": false,

    "tenantId": null

}

这时需要知道流程流转到了哪个步骤上,查看流程活动实例的rest接口:http://{host}:{port}/{contextPath}/process-instance/{id}/activity-instances

用Postman测试:

http://localhost:8080/engine-rest/process-instance/2881747c-cfca-11ee-a32c-32f6efb33b52/activity-instances

58-postman查看流程活动

这个信息返回是比较全的,可以看出来流程当前流转到了“申请”节点,即流程刚刚启动的第一个节点。

{

    "id": "2881747c-cfca-11ee-a32c-32f6efb33b52",

    "parentActivityInstanceId": null,

    "activityId": "Process_15r7d3m:1:80b53453-cfc5-11ee-a32c-32f6efb33b52",

    "activityType": "processDefinition",

    "processInstanceId": "2881747c-cfca-11ee-a32c-32f6efb33b52",

    "processDefinitionId": "Process_15r7d3m:1:80b53453-cfc5-11ee-a32c-32f6efb33b52",

    "childActivityInstances": [

        {

            "id": "Activity_10ell5p:28b18532-cfca-11ee-a32c-32f6efb33b52",

            "parentActivityInstanceId": "2881747c-cfca-11ee-a32c-32f6efb33b52",

            "activityId": "Activity_10ell5p",

            "activityType": "userTask",

            "processInstanceId": "2881747c-cfca-11ee-a32c-32f6efb33b52",

            "processDefinitionId": "Process_15r7d3m:1:80b53453-cfc5-11ee-a32c-32f6efb33b52",

            "childActivityInstances": [],

            "childTransitionInstances": [],

            "executionIds": [

                "2881747c-cfca-11ee-a32c-32f6efb33b52"

            ],

            "activityName": "申请",

            "incidentIds": [],

            "incidents": [],

            "name": "申请"

        }

    ],

    "childTransitionInstances": [],

    "executionIds": [

        "2881747c-cfca-11ee-a32c-32f6efb33b52"

    ],

    "activityName": "UserTask Flow1",

    "incidentIds": [],

    "incidents": [],

    "name": "UserTask Flow1"

}

4.5、查询待办任务

通过上面接口得知,流程当前流转到了人工节点上,那么需要查询待办任务:

查询待办任务的rest接口:http://{host}:{port}/{contextPath}/task

用Postman测试:http://localhost:8080/engine-rest/task

59-postman查看待办

返回所有的流程待办任务列表:

[

    {

        "id": "28b1d353-cfca-11ee-a32c-32f6efb33b52",

        "name": "申请",

        "assignee": "demo",

        "created": "2024-02-20T16:29:26.815+0800",

        "due": null,

        "followUp": null,

        "lastUpdated": null,

        "delegationState": null,

        "description": null,

        "executionId": "2881747c-cfca-11ee-a32c-32f6efb33b52",

        "owner": null,

        "parentTaskId": null,

        "priority": 50,

        "processDefinitionId": "Process_15r7d3m:1:80b53453-cfc5-11ee-a32c-32f6efb33b52",

        "processInstanceId": "2881747c-cfca-11ee-a32c-32f6efb33b52",

        "taskDefinitionKey": "Activity_10ell5p",

        "caseExecutionId": null,

        "caseInstanceId": null,

        "caseDefinitionId": null,

        "suspended": false,

        "formKey": null,

        "camundaFormRef": null,

        "tenantId": null

    }

]

4.6、完成待办提交流程

完成待办任务,提交流程往下走,提交流程的rest服务接口为:

http://{host}:{port}/{contextPath}/task/{id}/complete

用Postman测试:http://localhost:8080/engine-rest/task/28b1d353-cfca-11ee-a32c-32f6efb33b52/complete

参数:

{

  "variables": {

    "variable": {

      "value": "china"

    },

    "variable2": {

      "value": false

    }

  },

  "withVariablesInReturn": true

}

60-postman完成待办

这时,我们再查询流程的的活动实例:

http://{host}:{port}/{contextPath}/process-instance/{id}/activity-instances

用Postman测试:http://localhost:8080/engine-rest/process-instance/2881747c-cfca-11ee-a32c-32f6efb33b52/activity-instances

61-postman活动实例查询

查询流程的待办任务:

http://{host}:{port}/{contextPath}/task

用Postman测试:http://localhost:8080/engine-rest/task

62-postman待办

可以看到,流程提交到下一个”审批”节点,待办任务也流转到了下一步骤。

4.7、查询流程变量

可以通过接口查询该流程执行实例的流程变量,查询流程变量的rest接口为:

http://{host}:{port}/{contextPath}/execution/{id}/localVariables

用Postman测试:http://localhost:8080/engine-rest/execution/2881747c-cfca-11ee-a32c-32f6efb33b52/localVariables

63-postman查看流程变量

5、小结

本文章介绍了通过camunda7.19的源代码编译运行方式,构建自己的springboot工程,并通过RESTful接口方式,验证camunda源代码编译和运行效果。

以上仅仅是验证了camunda流程引擎和rest接口是好用的,还没有人机交互界面,camunda开源版本也提供了基于angular语言开发的web界面,但该界面功能有限(好多高级有用的功能都在camunda企业版本里),而且不太适合中国人操作习惯,所以UI界面部分建议大家选择自己熟悉的语言vue\react\angular,进行定制化开发。

流程门户界面:以下是通过vue开发的流程门户界面,包括流程中心、我的待办、我的已办、我的流程、常用流程等重要的流程操作界面,用户也可以通过可视化拖拉拽方式配置自己的门户界面。

70-流程门户界面

发起流程界面:把用户有权限发起的流程,按照业务分类聚合到一个界面上,方便用户快速发起流程和审批流程。

71-发起流程界面

在线体验系统:http://www.yunchengxc.com

camunda源代码:https://github.com/camunda/camunda-bpm-platform

posted @ 2024-07-11 18:50  大龄码农有梦想  阅读(289)  评论(0编辑  收藏  举报