From ac6d6758720b9b9ae293a9d9071bc0904d3dd30d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Sat, 26 Sep 2020 20:11:58 -0500 Subject: [PATCH 1/4] Add spring-boot-configuration-processor dependency In order to make properties discoverable by IDEs, metadata should be provided. This dependency generate metadata for CloudstateProperties. --- cloudstate-springboot-support/pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cloudstate-springboot-support/pom.xml b/cloudstate-springboot-support/pom.xml index 06ef44d..d148def 100644 --- a/cloudstate-springboot-support/pom.xml +++ b/cloudstate-springboot-support/pom.xml @@ -67,6 +67,13 @@ 1 + + org.springframework.boot + spring-boot-configuration-processor + ${spring-boot.version} + true + + org.springframework.boot From fecab35346c7809de8a89b5076d48857a027c800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Sat, 26 Sep 2020 20:12:48 -0500 Subject: [PATCH 2/4] Add spring-boot-autoconfigure-processor dependency Generate metadata for CloudstateAutoConfiguration class in order to improve startup. --- cloudstate-springboot-support/pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cloudstate-springboot-support/pom.xml b/cloudstate-springboot-support/pom.xml index d148def..b6d15f8 100644 --- a/cloudstate-springboot-support/pom.xml +++ b/cloudstate-springboot-support/pom.xml @@ -74,6 +74,13 @@ true + + org.springframework.boot + spring-boot-autoconfigure-processor + ${spring-boot.version} + true + + org.springframework.boot From 457237dee2f2e4e9e809e23d627c61721bb03bbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Sat, 26 Sep 2020 20:17:50 -0500 Subject: [PATCH 3/4] Fix ConditionalOnClass Currently, `ConditionalOnClass` check on a class in the same jar. In order to enable this auto-configuration the check should be against depenencies such as CloudState in `io.cloudstate:cloud-state-javasupport`. --- .../starter/autoconfigure/CloudstateAutoConfiguration.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudstate-springboot-support/src/main/java/io/cloudstate/springboot/starter/autoconfigure/CloudstateAutoConfiguration.java b/cloudstate-springboot-support/src/main/java/io/cloudstate/springboot/starter/autoconfigure/CloudstateAutoConfiguration.java index 6f860b4..a695d07 100644 --- a/cloudstate-springboot-support/src/main/java/io/cloudstate/springboot/starter/autoconfigure/CloudstateAutoConfiguration.java +++ b/cloudstate-springboot-support/src/main/java/io/cloudstate/springboot/starter/autoconfigure/CloudstateAutoConfiguration.java @@ -13,7 +13,7 @@ import io.cloudstate.springboot.starter.internal.CloudstateEntityScan; @Configuration -@ConditionalOnClass(CloudstateProperties.class) +@ConditionalOnClass(CloudState.class) @EnableConfigurationProperties(CloudstateProperties.class) @ComponentScan(basePackages = "io.cloudstate.springboot.starter") public class CloudstateAutoConfiguration { From bd443914ad2d16466a9690069090144405f8513b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Sat, 26 Sep 2020 20:20:07 -0500 Subject: [PATCH 4/4] Add CloudstateAutoConfigation into spring.factories Auto-Configuration can be enabled if all the conditions match. Also, there is no need to add `@EnableCloudState` in a spring-boot project if the auto-configuration is registered in `spring.factories`. --- .../src/main/resources/META-INF/spring.factories | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 cloudstate-springboot-support/src/main/resources/META-INF/spring.factories diff --git a/cloudstate-springboot-support/src/main/resources/META-INF/spring.factories b/cloudstate-springboot-support/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000..a2f40d4 --- /dev/null +++ b/cloudstate-springboot-support/src/main/resources/META-INF/spring.factories @@ -0,0 +1,2 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ +io.cloudstate.springboot.starter.autoconfigure.CloudstateAutoConfiguration