diff --git a/cosid-spring-boot-starter/build.gradle.kts b/cosid-spring-boot-starter/build.gradle.kts index 54b262992c..392b05ecff 100644 --- a/cosid-spring-boot-starter/build.gradle.kts +++ b/cosid-spring-boot-starter/build.gradle.kts @@ -40,6 +40,10 @@ java { usingSourceSet(sourceSets[SourceSet.MAIN_SOURCE_SET_NAME]) capability(group.toString(), "data-jdbc-support", version.toString()) } + registerFeature("activitiSupport") { + usingSourceSet(sourceSets[SourceSet.MAIN_SOURCE_SET_NAME]) + capability(group.toString(), "activiti-support", version.toString()) + } registerFeature("flowableSupport") { usingSourceSet(sourceSets[SourceSet.MAIN_SOURCE_SET_NAME]) capability(group.toString(), "flowable-support", version.toString()) @@ -67,6 +71,8 @@ dependencies { "proxySupportImplementation"(project(":cosid-proxy")) "mongoSupportImplementation"(project(":cosid-mongo")) + "activitiSupportImplementation"(project(":cosid-activiti")) + "activitiSupportImplementation"(libs.activitiSpringBootStarter) "flowableSupportImplementation"(project(":cosid-flowable")) "flowableSupportImplementation"(libs.flowableSpring) "flowableSupportImplementation"(libs.flowableSpringBootAutoconfigure) diff --git a/cosid-spring-boot-starter/src/main/java/me/ahoo/cosid/spring/boot/starter/activiti/ActivitiIdGeneratorAutoConfiguration.java b/cosid-spring-boot-starter/src/main/java/me/ahoo/cosid/spring/boot/starter/activiti/ActivitiIdGeneratorAutoConfiguration.java new file mode 100644 index 0000000000..55a2c588af --- /dev/null +++ b/cosid-spring-boot-starter/src/main/java/me/ahoo/cosid/spring/boot/starter/activiti/ActivitiIdGeneratorAutoConfiguration.java @@ -0,0 +1,48 @@ +/* + * Copyright [2021-present] [ahoo wang (https://github.com/Ahoo-Wang)]. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package me.ahoo.cosid.spring.boot.starter.activiti; + +import me.ahoo.cosid.activiti.ActivitiIdGenerator; +import me.ahoo.cosid.flowable.FlowableIdGenerator; +import me.ahoo.cosid.spring.boot.starter.ConditionalOnCosIdEnabled; + +import org.activiti.spring.SpringProcessEngineConfiguration; +import org.activiti.spring.boot.ProcessEngineConfigurationConfigurer; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.context.annotation.Bean; + +/** + * Activiti IdGenerator Auto Configuration. + * + * @author ahoo wang + */ +@AutoConfiguration +@ConditionalOnCosIdEnabled +@ConditionalOnClass(FlowableIdGenerator.class) +public class ActivitiIdGeneratorAutoConfiguration { + + @Bean + public ProcessEngineConfigurationConfigurer engineConfigurationConfigurer() { + return new ActivitiIdGeneratorAutoConfiguration.CosIdProcessEngineConfigurationConfigurer(); + } + + static class CosIdProcessEngineConfigurationConfigurer implements ProcessEngineConfigurationConfigurer { + + @Override + public void configure(SpringProcessEngineConfiguration engineConfiguration) { + engineConfiguration.setIdGenerator(new ActivitiIdGenerator()); + } + } +} diff --git a/cosid-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/cosid-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 1629e118ad..a04f4e6100 100644 --- a/cosid-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/cosid-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -19,3 +19,4 @@ me.ahoo.cosid.spring.boot.starter.mybatis.CosIdMybatisAutoConfiguration me.ahoo.cosid.spring.boot.starter.actuate.CosIdEndpointAutoConfiguration me.ahoo.cosid.spring.boot.starter.jdbc.CosIdJdbcAutoConfiguration me.ahoo.cosid.spring.boot.starter.flowable.FlowableIdGeneratorAutoConfiguration +me.ahoo.cosid.spring.boot.starter.activiti.ActivitiIdGeneratorAutoConfiguration \ No newline at end of file diff --git a/cosid-spring-boot-starter/src/test/java/me/ahoo/cosid/spring/boot/starter/activiti/ActivitiIdGeneratorAutoConfigurationTest.java b/cosid-spring-boot-starter/src/test/java/me/ahoo/cosid/spring/boot/starter/activiti/ActivitiIdGeneratorAutoConfigurationTest.java new file mode 100644 index 0000000000..b4c55b0b58 --- /dev/null +++ b/cosid-spring-boot-starter/src/test/java/me/ahoo/cosid/spring/boot/starter/activiti/ActivitiIdGeneratorAutoConfigurationTest.java @@ -0,0 +1,38 @@ +/* + * Copyright [2021-present] [ahoo wang (https://github.com/Ahoo-Wang)]. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package me.ahoo.cosid.spring.boot.starter.activiti; + +import me.ahoo.cosid.spring.boot.starter.machine.ConditionalOnCosIdMachineEnabled; + +import org.activiti.spring.boot.ProcessEngineConfigurationConfigurer; +import org.assertj.core.api.AssertionsForInterfaceTypes; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.runner.ApplicationContextRunner; + +class ActivitiIdGeneratorAutoConfigurationTest { + private final ApplicationContextRunner contextRunner = new ApplicationContextRunner(); + + @Test + void contextLoads() { + this.contextRunner + .withPropertyValues(ConditionalOnCosIdMachineEnabled.ENABLED_KEY + "=true") + .withUserConfiguration(ActivitiIdGeneratorAutoConfiguration.class) + .run(context -> { + AssertionsForInterfaceTypes.assertThat(context) + .hasSingleBean(ActivitiIdGeneratorAutoConfiguration.class) + .hasSingleBean(ProcessEngineConfigurationConfigurer.class) + ; + }); + } +} \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 80193439b1..4a69c9fba9 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -10,7 +10,7 @@ mybatisSpringBoot = "3.0.2" junitPioneer = "2.1.0" axon = "4.9.0" flowable = "6.8.0" -activiti = "6.0.0" +activiti = "7.0.0.SR1" springDoc = "2.2.0" hamcrest = "2.2" jmh = "1.37" @@ -29,10 +29,11 @@ guava = { module = "com.google.guava:guava", version.ref = "guava" } mybatis = { module = "org.mybatis:mybatis", version.ref = "mybatis" } mybatisSpringBoot = { module = "org.mybatis.spring.boot:mybatis-spring-boot-starter", version.ref = "mybatisSpringBoot" } springDocStarterWebfluxUi = { module = "org.springdoc:springdoc-openapi-starter-webflux-ui", version.ref = "springDoc" } +activitiEngine = { module = "org.activiti:activiti-engine", version.ref = "activiti" } +activitiSpringBootStarter = { module = "org.activiti:activiti-spring-boot-starter", version.ref = "activiti" } flowableEngineCommon = { module = "org.flowable:flowable-engine-common", version.ref = "flowable" } flowableSpring = { module = "org.flowable:flowable-spring", version.ref = "flowable" } flowableSpringBootAutoconfigure = { module = "org.flowable:flowable-spring-boot-autoconfigure", version.ref = "flowable" } -activitiEngine = { module = "org.activiti:activiti-engine", version.ref = "activiti" } junitPioneer = { module = "org.junit-pioneer:junit-pioneer", version.ref = "junitPioneer" } hamcrest = { module = "org.hamcrest:hamcrest", version.ref = "hamcrest" } jmhCore = { module = "org.openjdk.jmh:jmh-core", version.ref = "jmh" }