From 8f623e8934f55df08aaa1343c89d24e8bfd64ea4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Nicoll?= Date: Mon, 24 Mar 2025 16:05:11 +0100 Subject: [PATCH] Create spring-boot-quartz module Issue: 46107 --- settings.gradle | 1 + .../build.gradle | 1 + .../QuartzEndpointAutoConfiguration.java | 2 +- .../build.gradle | 1 - ...itional-spring-configuration-metadata.json | 11 ----- .../main/resources/META-INF/spring.factories | 1 - ...ot.autoconfigure.AutoConfiguration.imports | 1 - .../spring-boot-dependencies/build.gradle | 1 + .../spring-boot-docs/build.gradle | 2 + .../modules/reference/pages/io/quartz.adoc | 8 ++-- .../spring-boot-quartz/build.gradle | 45 +++++++++++++++++++ .../quartz/autoconfigure}/JobStoreType.java | 4 +- .../QuartzAutoConfiguration.java | 9 ++-- .../autoconfigure}/QuartzDataSource.java | 4 +- ...tzDataSourceScriptDatabaseInitializer.java | 4 +- .../autoconfigure}/QuartzProperties.java | 4 +- .../QuartzTransactionManager.java | 4 +- ...pendsOnDatabaseInitializationDetector.java | 2 +- .../SchedulerFactoryBeanCustomizer.java | 4 +- .../quartz/autoconfigure}/package-info.java | 2 +- ...itional-spring-configuration-metadata.json | 16 +++++++ .../main/resources/META-INF/spring.factories | 3 ++ ...ot.autoconfigure.AutoConfiguration.imports | 1 + .../QuartzAutoConfigurationTests.java | 2 +- ...aSourceScriptDatabaseInitializerTests.java | 2 +- .../autoconfigure}/tables_#_comments.sql | 0 .../autoconfigure}/tables_--_comments.sql | 0 .../tables_custom_comment_prefix.sql | 0 .../spring-boot-starter-quartz/build.gradle | 3 +- 29 files changed, 96 insertions(+), 42 deletions(-) create mode 100644 spring-boot-project/spring-boot-quartz/build.gradle rename spring-boot-project/{spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz => spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure}/JobStoreType.java (92%) rename spring-boot-project/{spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz => spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure}/QuartzAutoConfiguration.java (95%) rename spring-boot-project/{spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz => spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure}/QuartzDataSource.java (95%) rename spring-boot-project/{spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz => spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure}/QuartzDataSourceScriptDatabaseInitializer.java (98%) rename spring-boot-project/{spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz => spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure}/QuartzProperties.java (98%) rename spring-boot-project/{spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz => spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure}/QuartzTransactionManager.java (95%) rename spring-boot-project/{spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz => spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure}/SchedulerDependsOnDatabaseInitializationDetector.java (96%) rename spring-boot-project/{spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz => spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure}/SchedulerFactoryBeanCustomizer.java (95%) rename spring-boot-project/{spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz => spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure}/package-info.java (92%) create mode 100644 spring-boot-project/spring-boot-quartz/src/main/resources/META-INF/additional-spring-configuration-metadata.json create mode 100644 spring-boot-project/spring-boot-quartz/src/main/resources/META-INF/spring.factories create mode 100644 spring-boot-project/spring-boot-quartz/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports rename spring-boot-project/{spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/quartz => spring-boot-quartz/src/test/java/org/springframework/boot/quartz/autoconfigure}/QuartzAutoConfigurationTests.java (99%) rename spring-boot-project/{spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/quartz => spring-boot-quartz/src/test/java/org/springframework/boot/quartz/autoconfigure}/QuartzDataSourceScriptDatabaseInitializerTests.java (97%) rename spring-boot-project/{spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/quartz => spring-boot-quartz/src/test/resources/org/springframework/boot/quartz/autoconfigure}/tables_#_comments.sql (100%) rename spring-boot-project/{spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/quartz => spring-boot-quartz/src/test/resources/org/springframework/boot/quartz/autoconfigure}/tables_--_comments.sql (100%) rename spring-boot-project/{spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/quartz => spring-boot-quartz/src/test/resources/org/springframework/boot/quartz/autoconfigure}/tables_custom_comment_prefix.sql (100%) diff --git a/settings.gradle b/settings.gradle index d5e7e0e0da8..c37d0e6f07f 100644 --- a/settings.gradle +++ b/settings.gradle @@ -93,6 +93,7 @@ include "spring-boot-project:spring-boot-mail" include "spring-boot-project:spring-boot-mustache" include "spring-boot-project:spring-boot-parent" include "spring-boot-project:spring-boot-pulsar" +include "spring-boot-project:spring-boot-quartz" include "spring-boot-project:spring-boot-r2dbc" include "spring-boot-project:spring-boot-reactor-netty" include "spring-boot-project:spring-boot-rsocket" diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle b/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle index 43e4e62e3ac..3e1def5e198 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle @@ -51,6 +51,7 @@ dependencies { optional(project(":spring-boot-project:spring-boot-liquibase")) optional(project(":spring-boot-project:spring-boot-mail")) optional(project(":spring-boot-project:spring-boot-neo4j")) + optional(project(":spring-boot-project:spring-boot-quartz")) optional(project(":spring-boot-project:spring-boot-r2dbc")) optional(project(":spring-boot-project:spring-boot-reactor-netty")) optional(project(":spring-boot-project:spring-boot-tomcat")) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/quartz/QuartzEndpointAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/quartz/QuartzEndpointAutoConfiguration.java index 9dbf90d0fb6..a2909c6b600 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/quartz/QuartzEndpointAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/quartz/QuartzEndpointAutoConfiguration.java @@ -29,8 +29,8 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.boot.quartz.autoconfigure.QuartzAutoConfiguration; import org.springframework.context.annotation.Bean; /** diff --git a/spring-boot-project/spring-boot-autoconfigure-all/build.gradle b/spring-boot-project/spring-boot-autoconfigure-all/build.gradle index 211f9d65ba5..952a17e671f 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/build.gradle +++ b/spring-boot-project/spring-boot-autoconfigure-all/build.gradle @@ -164,7 +164,6 @@ dependencies { optional("org.opensaml:opensaml-core:4.0.1") optional("org.opensaml:opensaml-saml-api:4.0.1") optional("org.opensaml:opensaml-saml-impl:4.0.1") - optional("org.quartz-scheduler:quartz") optional("org.springframework:spring-aspects") optional("org.springframework:spring-jdbc") optional("org.springframework:spring-jms") diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-project/spring-boot-autoconfigure-all/src/main/resources/META-INF/additional-spring-configuration-metadata.json index cb36c3e5a84..bf9f62e2fe5 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot-project/spring-boot-autoconfigure-all/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -760,17 +760,6 @@ "level": "error" } }, - { - "name": "spring.quartz.jdbc.comment-prefix", - "defaultValue": [ - "#", - "--" - ] - }, - { - "name": "spring.quartz.scheduler-name", - "defaultValue": "quartzScheduler" - }, { "name": "spring.reactor.stacktrace-mode.enabled", "description": "Whether Reactor should collect stacktrace information at runtime.", diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/resources/META-INF/spring.factories b/spring-boot-project/spring-boot-autoconfigure-all/src/main/resources/META-INF/spring.factories index 2838d2949da..d3f25c52ee0 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/resources/META-INF/spring.factories +++ b/spring-boot-project/spring-boot-autoconfigure-all/src/main/resources/META-INF/spring.factories @@ -13,5 +13,4 @@ org.springframework.boot.autoconfigure.web.servlet.JspTemplateAvailabilityProvid # Depends on Database Initialization Detectors org.springframework.boot.sql.init.dependency.DependsOnDatabaseInitializationDetector=\ -org.springframework.boot.autoconfigure.quartz.SchedulerDependsOnDatabaseInitializationDetector,\ org.springframework.boot.autoconfigure.session.JdbcIndexedSessionRepositoryDependsOnDatabaseInitializationDetector diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/spring-boot-project/spring-boot-autoconfigure-all/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 3fa359d360a..e706c784b7b 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/spring-boot-project/spring-boot-autoconfigure-all/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -55,7 +55,6 @@ org.springframework.boot.autoconfigure.ldap.LdapAutoConfiguration org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration org.springframework.boot.autoconfigure.mongo.MongoReactiveAutoConfiguration org.springframework.boot.autoconfigure.netty.NettyAutoConfiguration -org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration org.springframework.boot.autoconfigure.reactor.ReactorAutoConfiguration org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index e5a844b314f..3bc1d6894a7 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -2023,6 +2023,7 @@ bom { "spring-boot-neo4j", "spring-boot-properties-migrator", "spring-boot-pulsar", + "spring-boot-quartz", "spring-boot-r2dbc", "spring-boot-reactor-netty", "spring-boot-rsocket", diff --git a/spring-boot-project/spring-boot-docs/build.gradle b/spring-boot-project/spring-boot-docs/build.gradle index 11ea7ea1d4b..62c62d8be87 100644 --- a/spring-boot-project/spring-boot-docs/build.gradle +++ b/spring-boot-project/spring-boot-docs/build.gradle @@ -104,6 +104,7 @@ dependencies { autoConfiguration(project(path: ":spring-boot-project:spring-boot-mustache", configuration: "autoConfigurationMetadata")) autoConfiguration(project(path: ":spring-boot-project:spring-boot-neo4j", configuration: "autoConfigurationMetadata")) autoConfiguration(project(path: ":spring-boot-project:spring-boot-pulsar", configuration: "autoConfigurationMetadata")) + autoConfiguration(project(path: ":spring-boot-project:spring-boot-quartz", configuration: "autoConfigurationMetadata")) autoConfiguration(project(path: ":spring-boot-project:spring-boot-r2dbc", configuration: "autoConfigurationMetadata")) autoConfiguration(project(path: ":spring-boot-project:spring-boot-reactor-netty", configuration: "autoConfigurationMetadata")) autoConfiguration(project(path: ":spring-boot-project:spring-boot-rsocket", configuration: "autoConfigurationMetadata")) @@ -144,6 +145,7 @@ dependencies { configurationProperties(project(path: ":spring-boot-project:spring-boot-mustache", configuration: "configurationPropertiesMetadata")) configurationProperties(project(path: ":spring-boot-project:spring-boot-neo4j", configuration: "configurationPropertiesMetadata")) configurationProperties(project(path: ":spring-boot-project:spring-boot-pulsar", configuration: "configurationPropertiesMetadata")) + configurationProperties(project(path: ":spring-boot-project:spring-boot-quartz", configuration: "configurationPropertiesMetadata")) configurationProperties(project(path: ":spring-boot-project:spring-boot-r2dbc", configuration: "configurationPropertiesMetadata")) configurationProperties(project(path: ":spring-boot-project:spring-boot-reactor-netty", configuration: "configurationPropertiesMetadata")) configurationProperties(project(path: ":spring-boot-project:spring-boot-rsocket", configuration: "configurationPropertiesMetadata")) diff --git a/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/io/quartz.adoc b/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/io/quartz.adoc index 7ff87db760f..c572fc1ac3e 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/io/quartz.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/io/quartz.adoc @@ -37,18 +37,18 @@ To use a custom script, set the configprop:spring.quartz.jdbc.schema[] property. Some of the standard scripts – such as those for SQL Server, Azure SQL, and Sybase – cannot be used without modification. In these cases, make a copy of the script and edit it as directed in the script's comments then set configprop:spring.quartz.jdbc.schema[] to use your customized script. -To have Quartz use a javadoc:javax.sql.DataSource[] other than the application's main javadoc:javax.sql.DataSource[], declare a javadoc:javax.sql.DataSource[] bean, annotating its javadoc:org.springframework.context.annotation.Bean[format=annotation] method with javadoc:org.springframework.boot.autoconfigure.quartz.QuartzDataSource[format=annotation]. +To have Quartz use a javadoc:javax.sql.DataSource[] other than the application's main javadoc:javax.sql.DataSource[], declare a javadoc:javax.sql.DataSource[] bean, annotating its javadoc:org.springframework.context.annotation.Bean[format=annotation] method with javadoc:org.springframework.boot.quartz.autoconfigure.QuartzDataSource[format=annotation]. Doing so ensures that the Quartz-specific javadoc:javax.sql.DataSource[] is used by both the javadoc:org.springframework.scheduling.quartz.SchedulerFactoryBean[] and for schema initialization. -Similarly, to have Quartz use a javadoc:org.springframework.transaction.TransactionManager[] other than the application's main javadoc:org.springframework.transaction.TransactionManager[] declare a javadoc:org.springframework.transaction.TransactionManager[] bean, annotating its javadoc:org.springframework.context.annotation.Bean[format=annotation] method with javadoc:org.springframework.boot.autoconfigure.quartz.QuartzTransactionManager[format=annotation]. +Similarly, to have Quartz use a javadoc:org.springframework.transaction.TransactionManager[] other than the application's main javadoc:org.springframework.transaction.TransactionManager[] declare a javadoc:org.springframework.transaction.TransactionManager[] bean, annotating its javadoc:org.springframework.context.annotation.Bean[format=annotation] method with javadoc:org.springframework.boot.quartz.autoconfigure.QuartzTransactionManager[format=annotation]. By default, jobs created by configuration will not overwrite already registered jobs that have been read from a persistent job store. To enable overwriting existing job definitions set the configprop:spring.quartz.overwrite-existing-jobs[] property. -Quartz Scheduler configuration can be customized using `spring.quartz` properties and javadoc:org.springframework.boot.autoconfigure.quartz.SchedulerFactoryBeanCustomizer[] beans, which allow programmatic javadoc:org.springframework.scheduling.quartz.SchedulerFactoryBean[] customization. +Quartz Scheduler configuration can be customized using `spring.quartz` properties and javadoc:org.springframework.boot.quartz.autoconfigure.SchedulerFactoryBeanCustomizer[] beans, which allow programmatic javadoc:org.springframework.scheduling.quartz.SchedulerFactoryBean[] customization. Advanced Quartz configuration properties can be customized using `spring.quartz.properties.*`. NOTE: In particular, an javadoc:java.util.concurrent.Executor[] bean is not associated with the scheduler as Quartz offers a way to configure the scheduler through `spring.quartz.properties`. -If you need to customize the task executor, consider implementing javadoc:org.springframework.boot.autoconfigure.quartz.SchedulerFactoryBeanCustomizer[]. +If you need to customize the task executor, consider implementing javadoc:org.springframework.boot.quartz.autoconfigure.SchedulerFactoryBeanCustomizer[]. Jobs can define setters to inject data map properties. Regular beans can also be injected in a similar manner, as shown in the following example: diff --git a/spring-boot-project/spring-boot-quartz/build.gradle b/spring-boot-project/spring-boot-quartz/build.gradle new file mode 100644 index 00000000000..a906a125506 --- /dev/null +++ b/spring-boot-project/spring-boot-quartz/build.gradle @@ -0,0 +1,45 @@ +/* + * Copyright 2012-present the original author or authors. + * + * 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 + * + * https://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. + */ + + +plugins { + id "java-library" + id "org.springframework.boot.auto-configuration" + id "org.springframework.boot.configuration-properties" + id "org.springframework.boot.deployed" + id "org.springframework.boot.optional-dependencies" +} + +description = "Spring Boot Quartz" + +dependencies { + api(project(":spring-boot-project:spring-boot-tx")) + api("org.quartz-scheduler:quartz") + api("org.springframework:spring-context-support") + + optional(project(":spring-boot-project:spring-boot-autoconfigure")) + optional(project(":spring-boot-project:spring-boot-jdbc")) + optional(project(":spring-boot-project:spring-boot-jpa")) + + testImplementation(project(":spring-boot-project:spring-boot-flyway")) + testImplementation(project(":spring-boot-project:spring-boot-liquibase")) + testImplementation(project(":spring-boot-project:spring-boot-test")) + testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support")) + + testRuntimeOnly("ch.qos.logback:logback-classic") + testRuntimeOnly("com.h2database:h2") + testRuntimeOnly("com.zaxxer:HikariCP") +} diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz/JobStoreType.java b/spring-boot-project/spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure/JobStoreType.java similarity index 92% rename from spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz/JobStoreType.java rename to spring-boot-project/spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure/JobStoreType.java index 596e0ec676d..4ef05755e47 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz/JobStoreType.java +++ b/spring-boot-project/spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure/JobStoreType.java @@ -14,13 +14,13 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.quartz; +package org.springframework.boot.quartz.autoconfigure; /** * Define the supported Quartz {@code JobStore}. * * @author Stephane Nicoll - * @since 2.0.0 + * @since 4.0.0 */ public enum JobStoreType { diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfiguration.java b/spring-boot-project/spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure/QuartzAutoConfiguration.java similarity index 95% rename from spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfiguration.java rename to spring-boot-project/spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure/QuartzAutoConfiguration.java index c27a3c0e6ce..8d73c7796c5 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfiguration.java +++ b/spring-boot-project/spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure/QuartzAutoConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.quartz; +package org.springframework.boot.quartz.autoconfigure; import java.util.Map; import java.util.Properties; @@ -35,7 +35,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate; import org.springframework.boot.autoconfigure.sql.init.OnDatabaseInitializationCondition; import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration; import org.springframework.boot.sql.init.dependency.DatabaseInitializationDependencyConfigurer; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; @@ -52,10 +51,10 @@ import org.springframework.transaction.PlatformTransactionManager; * * @author Vedran Pavic * @author Stephane Nicoll - * @since 2.0.0 + * @since 4.0.0 */ -@AutoConfiguration(after = DataSourceAutoConfiguration.class, - afterName = "org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration") +@AutoConfiguration(afterName = { "org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration", + "org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration" }) @ConditionalOnClass({ Scheduler.class, SchedulerFactoryBean.class, PlatformTransactionManager.class }) @EnableConfigurationProperties(QuartzProperties.class) public class QuartzAutoConfiguration { diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzDataSource.java b/spring-boot-project/spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure/QuartzDataSource.java similarity index 95% rename from spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzDataSource.java rename to spring-boot-project/spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure/QuartzDataSource.java index 3f4422f91ff..32ff091b379 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzDataSource.java +++ b/spring-boot-project/spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure/QuartzDataSource.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.quartz; +package org.springframework.boot.quartz.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -31,7 +31,7 @@ import org.springframework.beans.factory.annotation.Qualifier; * * @author Madhura Bhave * @see QuartzDataSource - * @since 2.0.2 + * @since 4.0.0 */ @Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.TYPE, ElementType.ANNOTATION_TYPE }) @Retention(RetentionPolicy.RUNTIME) diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzDataSourceScriptDatabaseInitializer.java b/spring-boot-project/spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure/QuartzDataSourceScriptDatabaseInitializer.java similarity index 98% rename from spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzDataSourceScriptDatabaseInitializer.java rename to spring-boot-project/spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure/QuartzDataSourceScriptDatabaseInitializer.java index 705fa624069..a457b4d9033 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzDataSourceScriptDatabaseInitializer.java +++ b/spring-boot-project/spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure/QuartzDataSourceScriptDatabaseInitializer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.quartz; +package org.springframework.boot.quartz.autoconfigure; import java.util.List; @@ -35,7 +35,7 @@ import org.springframework.util.StringUtils; * @author Vedran Pavic * @author Andy Wilkinson * @author Phillip Webb - * @since 2.6.0 + * @since 4.0.0 */ public class QuartzDataSourceScriptDatabaseInitializer extends DataSourceScriptDatabaseInitializer { diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzProperties.java b/spring-boot-project/spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure/QuartzProperties.java similarity index 98% rename from spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzProperties.java rename to spring-boot-project/spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure/QuartzProperties.java index fa2bc10f32f..58a94836f8b 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzProperties.java +++ b/spring-boot-project/spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure/QuartzProperties.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.quartz; +package org.springframework.boot.quartz.autoconfigure; import java.time.Duration; import java.util.ArrayList; @@ -31,7 +31,7 @@ import org.springframework.boot.sql.init.DatabaseInitializationMode; * * @author Vedran Pavic * @author Stephane Nicoll - * @since 2.0.0 + * @since 4.0.0 */ @ConfigurationProperties("spring.quartz") public class QuartzProperties { diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzTransactionManager.java b/spring-boot-project/spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure/QuartzTransactionManager.java similarity index 95% rename from spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzTransactionManager.java rename to spring-boot-project/spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure/QuartzTransactionManager.java index 2836aeb2e6c..42eff3f35ce 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzTransactionManager.java +++ b/spring-boot-project/spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure/QuartzTransactionManager.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.quartz; +package org.springframework.boot.quartz.autoconfigure; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -31,7 +31,7 @@ import org.springframework.beans.factory.annotation.Qualifier; * * @author Andy Wilkinson * @see QuartzDataSource - * @since 2.2.11 + * @since 4.0.0 */ @Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.TYPE, ElementType.ANNOTATION_TYPE }) @Retention(RetentionPolicy.RUNTIME) diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz/SchedulerDependsOnDatabaseInitializationDetector.java b/spring-boot-project/spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure/SchedulerDependsOnDatabaseInitializationDetector.java similarity index 96% rename from spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz/SchedulerDependsOnDatabaseInitializationDetector.java rename to spring-boot-project/spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure/SchedulerDependsOnDatabaseInitializationDetector.java index 7c99301b7f3..f71117c8655 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz/SchedulerDependsOnDatabaseInitializationDetector.java +++ b/spring-boot-project/spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure/SchedulerDependsOnDatabaseInitializationDetector.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.quartz; +package org.springframework.boot.quartz.autoconfigure; import java.util.Arrays; import java.util.HashSet; diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz/SchedulerFactoryBeanCustomizer.java b/spring-boot-project/spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure/SchedulerFactoryBeanCustomizer.java similarity index 95% rename from spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz/SchedulerFactoryBeanCustomizer.java rename to spring-boot-project/spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure/SchedulerFactoryBeanCustomizer.java index ebc004cb517..d6375d0739a 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz/SchedulerFactoryBeanCustomizer.java +++ b/spring-boot-project/spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure/SchedulerFactoryBeanCustomizer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.quartz; +package org.springframework.boot.quartz.autoconfigure; import javax.sql.DataSource; @@ -31,7 +31,7 @@ import org.springframework.scheduling.quartz.SchedulerFactoryBean; * {@link QuartzDataSourceScriptDatabaseInitializer}. * * @author Vedran Pavic - * @since 2.0.0 + * @since 4.0.0 */ @FunctionalInterface public interface SchedulerFactoryBeanCustomizer { diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz/package-info.java b/spring-boot-project/spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure/package-info.java similarity index 92% rename from spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz/package-info.java rename to spring-boot-project/spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure/package-info.java index d9c5af25ed4..87fc620b97d 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/quartz/package-info.java +++ b/spring-boot-project/spring-boot-quartz/src/main/java/org/springframework/boot/quartz/autoconfigure/package-info.java @@ -17,4 +17,4 @@ /** * Auto-configuration for Quartz Scheduler. */ -package org.springframework.boot.autoconfigure.quartz; +package org.springframework.boot.quartz.autoconfigure; diff --git a/spring-boot-project/spring-boot-quartz/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-project/spring-boot-quartz/src/main/resources/META-INF/additional-spring-configuration-metadata.json new file mode 100644 index 00000000000..ace8964b50e --- /dev/null +++ b/spring-boot-project/spring-boot-quartz/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -0,0 +1,16 @@ +{ + "groups": [], + "properties": [ + { + "name": "spring.quartz.jdbc.comment-prefix", + "defaultValue": [ + "#", + "--" + ] + }, + { + "name": "spring.quartz.scheduler-name", + "defaultValue": "quartzScheduler" + } + ] +} diff --git a/spring-boot-project/spring-boot-quartz/src/main/resources/META-INF/spring.factories b/spring-boot-project/spring-boot-quartz/src/main/resources/META-INF/spring.factories new file mode 100644 index 00000000000..f70b277621f --- /dev/null +++ b/spring-boot-project/spring-boot-quartz/src/main/resources/META-INF/spring.factories @@ -0,0 +1,3 @@ +# Depends on Database Initialization Detectors +org.springframework.boot.sql.init.dependency.DependsOnDatabaseInitializationDetector=\ +org.springframework.boot.quartz.autoconfigure.SchedulerDependsOnDatabaseInitializationDetector diff --git a/spring-boot-project/spring-boot-quartz/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/spring-boot-project/spring-boot-quartz/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000000..006e19b5387 --- /dev/null +++ b/spring-boot-project/spring-boot-quartz/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +org.springframework.boot.quartz.autoconfigure.QuartzAutoConfiguration diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfigurationTests.java b/spring-boot-project/spring-boot-quartz/src/test/java/org/springframework/boot/quartz/autoconfigure/QuartzAutoConfigurationTests.java similarity index 99% rename from spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfigurationTests.java rename to spring-boot-project/spring-boot-quartz/src/test/java/org/springframework/boot/quartz/autoconfigure/QuartzAutoConfigurationTests.java index ad12bc6153b..a22315ad8b7 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-quartz/src/test/java/org/springframework/boot/quartz/autoconfigure/QuartzAutoConfigurationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.quartz; +package org.springframework.boot.quartz.autoconfigure; import java.io.InputStream; import java.nio.file.Files; diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/quartz/QuartzDataSourceScriptDatabaseInitializerTests.java b/spring-boot-project/spring-boot-quartz/src/test/java/org/springframework/boot/quartz/autoconfigure/QuartzDataSourceScriptDatabaseInitializerTests.java similarity index 97% rename from spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/quartz/QuartzDataSourceScriptDatabaseInitializerTests.java rename to spring-boot-project/spring-boot-quartz/src/test/java/org/springframework/boot/quartz/autoconfigure/QuartzDataSourceScriptDatabaseInitializerTests.java index d4526666e1b..69b06819f22 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/quartz/QuartzDataSourceScriptDatabaseInitializerTests.java +++ b/spring-boot-project/spring-boot-quartz/src/test/java/org/springframework/boot/quartz/autoconfigure/QuartzDataSourceScriptDatabaseInitializerTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.quartz; +package org.springframework.boot.quartz.autoconfigure; import java.util.Arrays; diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/quartz/tables_#_comments.sql b/spring-boot-project/spring-boot-quartz/src/test/resources/org/springframework/boot/quartz/autoconfigure/tables_#_comments.sql similarity index 100% rename from spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/quartz/tables_#_comments.sql rename to spring-boot-project/spring-boot-quartz/src/test/resources/org/springframework/boot/quartz/autoconfigure/tables_#_comments.sql diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/quartz/tables_--_comments.sql b/spring-boot-project/spring-boot-quartz/src/test/resources/org/springframework/boot/quartz/autoconfigure/tables_--_comments.sql similarity index 100% rename from spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/quartz/tables_--_comments.sql rename to spring-boot-project/spring-boot-quartz/src/test/resources/org/springframework/boot/quartz/autoconfigure/tables_--_comments.sql diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/quartz/tables_custom_comment_prefix.sql b/spring-boot-project/spring-boot-quartz/src/test/resources/org/springframework/boot/quartz/autoconfigure/tables_custom_comment_prefix.sql similarity index 100% rename from spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/quartz/tables_custom_comment_prefix.sql rename to spring-boot-project/spring-boot-quartz/src/test/resources/org/springframework/boot/quartz/autoconfigure/tables_custom_comment_prefix.sql diff --git a/spring-boot-project/spring-boot-starters/spring-boot-starter-quartz/build.gradle b/spring-boot-project/spring-boot-starters/spring-boot-starter-quartz/build.gradle index a5457e858d4..89816a745b3 100644 --- a/spring-boot-project/spring-boot-starters/spring-boot-starter-quartz/build.gradle +++ b/spring-boot-project/spring-boot-starters/spring-boot-starter-quartz/build.gradle @@ -22,7 +22,6 @@ description = "Starter for using the Quartz scheduler" dependencies { api(project(":spring-boot-project:spring-boot-starters:spring-boot-starter")) + api(project(":spring-boot-project:spring-boot-quartz")) api(project(":spring-boot-project:spring-boot-tx")) - api("org.springframework:spring-context-support") - api("org.quartz-scheduler:quartz") }