From 048cc5a6dacb24dba6c8c43f04cd3ec1ea49e9d8 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 12 May 2025 09:43:42 +0100 Subject: [PATCH] Move code from spring-boot-actuator to spring-boot-mail --- .../mail/MailHealthContributorAutoConfiguration.java | 4 ++-- .../mail/MailHealthContributorAutoConfigurationTests.java | 4 ++-- spring-boot-project/spring-boot-mail/build.gradle | 6 ++++++ .../boot/mail/actuate/health}/MailHealthIndicator.java | 6 +++--- .../boot/mail/actuate/health}/package-info.java | 6 +++--- .../boot/mail/actuate/health}/MailHealthIndicatorTests.java | 4 ++-- 6 files changed, 18 insertions(+), 12 deletions(-) rename spring-boot-project/{spring-boot-actuator/src/main/java/org/springframework/boot/actuate/mail => spring-boot-mail/src/main/java/org/springframework/boot/mail/actuate/health}/MailHealthIndicator.java (93%) rename spring-boot-project/{spring-boot-actuator/src/main/java/org/springframework/boot/actuate/mail => spring-boot-mail/src/main/java/org/springframework/boot/mail/actuate/health}/package-info.java (79%) rename spring-boot-project/{spring-boot-actuator/src/test/java/org/springframework/boot/actuate/mail => spring-boot-mail/src/test/java/org/springframework/boot/mail/actuate/health}/MailHealthIndicatorTests.java (98%) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/mail/MailHealthContributorAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/mail/MailHealthContributorAutoConfiguration.java index 69aa5a338e..10fc3be4d9 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/mail/MailHealthContributorAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/mail/MailHealthContributorAutoConfiguration.java @@ -20,12 +20,12 @@ import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.boot.actuate.autoconfigure.health.CompositeHealthContributorConfiguration; import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator; import org.springframework.boot.actuate.health.HealthContributor; -import org.springframework.boot.actuate.mail.MailHealthIndicator; import org.springframework.boot.autoconfigure.AutoConfiguration; 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.mail.actuate.health.MailHealthIndicator; import org.springframework.boot.mail.autoconfigure.MailSenderAutoConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.mail.javamail.JavaMailSenderImpl; @@ -37,7 +37,7 @@ import org.springframework.mail.javamail.JavaMailSenderImpl; * @since 2.0.0 */ @AutoConfiguration(after = MailSenderAutoConfiguration.class) -@ConditionalOnClass(JavaMailSenderImpl.class) +@ConditionalOnClass({ JavaMailSenderImpl.class, MailHealthIndicator.class }) @ConditionalOnBean(JavaMailSenderImpl.class) @ConditionalOnEnabledHealthIndicator("mail") public class MailHealthContributorAutoConfiguration diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/mail/MailHealthContributorAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/mail/MailHealthContributorAutoConfigurationTests.java index c9d0edd150..0f0df1326a 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/mail/MailHealthContributorAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/mail/MailHealthContributorAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2025 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. @@ -19,8 +19,8 @@ package org.springframework.boot.actuate.autoconfigure.mail; import org.junit.jupiter.api.Test; import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration; -import org.springframework.boot.actuate.mail.MailHealthIndicator; import org.springframework.boot.autoconfigure.AutoConfigurations; +import org.springframework.boot.mail.actuate.health.MailHealthIndicator; import org.springframework.boot.mail.autoconfigure.MailSenderAutoConfiguration; import org.springframework.boot.test.context.runner.ApplicationContextRunner; diff --git a/spring-boot-project/spring-boot-mail/build.gradle b/spring-boot-project/spring-boot-mail/build.gradle index 5801abba49..c4ceaf2cb3 100644 --- a/spring-boot-project/spring-boot-mail/build.gradle +++ b/spring-boot-project/spring-boot-mail/build.gradle @@ -14,6 +14,9 @@ dependencies { api("org.springframework:spring-context-support") api("org.eclipse.angus:jakarta.mail") + compileOnly("com.fasterxml.jackson.core:jackson-annotations") + + optional(project(":spring-boot-project:spring-boot-actuator")) optional(project(":spring-boot-project:spring-boot-autoconfigure")) dockerTestImplementation(project(":spring-boot-project:spring-boot-test")) @@ -21,8 +24,11 @@ dependencies { dockerTestImplementation("org.testcontainers:testcontainers") dockerTestImplementation("org.testcontainers:junit-jupiter") + testCompileOnly("com.fasterxml.jackson.core:jackson-annotations") + testImplementation(project(":spring-boot-project:spring-boot-test")) testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support")) testImplementation(testFixtures(project(":spring-boot-project:spring-boot-autoconfigure"))) + testRuntimeOnly("ch.qos.logback:logback-classic") } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/mail/MailHealthIndicator.java b/spring-boot-project/spring-boot-mail/src/main/java/org/springframework/boot/mail/actuate/health/MailHealthIndicator.java similarity index 93% rename from spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/mail/MailHealthIndicator.java rename to spring-boot-project/spring-boot-mail/src/main/java/org/springframework/boot/mail/actuate/health/MailHealthIndicator.java index 99bc8a5eac..a40f5bf924 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/mail/MailHealthIndicator.java +++ b/spring-boot-project/spring-boot-mail/src/main/java/org/springframework/boot/mail/actuate/health/MailHealthIndicator.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2025 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.actuate.mail; +package org.springframework.boot.mail.actuate.health; import org.springframework.boot.actuate.health.AbstractHealthIndicator; import org.springframework.boot.actuate.health.Health.Builder; @@ -27,7 +27,7 @@ import org.springframework.util.StringUtils; * * @author Johannes Edmeier * @author Scott Frederick - * @since 2.0.0 + * @since 4.0.0 */ public class MailHealthIndicator extends AbstractHealthIndicator { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/mail/package-info.java b/spring-boot-project/spring-boot-mail/src/main/java/org/springframework/boot/mail/actuate/health/package-info.java similarity index 79% rename from spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/mail/package-info.java rename to spring-boot-project/spring-boot-mail/src/main/java/org/springframework/boot/mail/actuate/health/package-info.java index ec977ea6ee..004104c368 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/mail/package-info.java +++ b/spring-boot-project/spring-boot-mail/src/main/java/org/springframework/boot/mail/actuate/health/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2025 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. @@ -15,6 +15,6 @@ */ /** - * Actuator support for JavaMail. + * Health integration for JavaMail. */ -package org.springframework.boot.actuate.mail; +package org.springframework.boot.mail.actuate.health; diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/mail/MailHealthIndicatorTests.java b/spring-boot-project/spring-boot-mail/src/test/java/org/springframework/boot/mail/actuate/health/MailHealthIndicatorTests.java similarity index 98% rename from spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/mail/MailHealthIndicatorTests.java rename to spring-boot-project/spring-boot-mail/src/test/java/org/springframework/boot/mail/actuate/health/MailHealthIndicatorTests.java index 9abfbedd88..9ee658c44a 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/mail/MailHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-mail/src/test/java/org/springframework/boot/mail/actuate/health/MailHealthIndicatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2025 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.actuate.mail; +package org.springframework.boot.mail.actuate.health; import java.util.Properties;