From 94c7140001f147b08438a50f69ddacbe0e1c68cd Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 9 Aug 2023 16:06:09 +0200 Subject: [PATCH] Use a dedicated application to collect log samples This commit moves the tasks that collect log samples for the reference guide to an isolated application. Closes gh-36875 --- .../spring-boot-docs/build.gradle | 4 +-- .../features/logexample/MyApplication.java | 34 +++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/logexample/MyApplication.java diff --git a/spring-boot-project/spring-boot-docs/build.gradle b/spring-boot-project/spring-boot-docs/build.gradle index 8e730293d8c..e920872bfc0 100644 --- a/spring-boot-project/spring-boot-docs/build.gradle +++ b/spring-boot-project/spring-boot-docs/build.gradle @@ -284,7 +284,7 @@ task runRemoteSpringApplicationExample(type: org.springframework.boot.build.docs task runSpringApplicationExample(type: org.springframework.boot.build.docs.ApplicationRunner) { classpath = configurations.springApplicationExample + sourceSets.main.output - mainClass = "org.springframework.boot.docs.features.springapplication.MyApplication" + mainClass = "org.springframework.boot.docs.features.logexample.MyApplication" args = ["--server.port=0"] output = file("$buildDir/example-output/spring-application.txt") expectedLogging = "Started MyApplication in " @@ -293,7 +293,7 @@ task runSpringApplicationExample(type: org.springframework.boot.build.docs.Appli task runLoggingFormatExample(type: org.springframework.boot.build.docs.ApplicationRunner) { classpath = configurations.springApplicationExample + sourceSets.main.output - mainClass = "org.springframework.boot.docs.features.springapplication.MyApplication" + mainClass = "org.springframework.boot.docs.features.logexample.MyApplication" args = ["--spring.main.banner-mode=off", "--server.port=0"] output = file("$buildDir/example-output/logging-format.txt") expectedLogging = "Started MyApplication in " diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/logexample/MyApplication.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/logexample/MyApplication.java new file mode 100644 index 00000000000..c588089d8d2 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/features/logexample/MyApplication.java @@ -0,0 +1,34 @@ +/* + * Copyright 2012-2023 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. + */ + +package org.springframework.boot.docs.features.logexample; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Sample application used to collect logs for the reference doc. + * + * @author Stephane Nicoll + */ +@SpringBootApplication +public class MyApplication { + + public static void main(String[] args) { + SpringApplication.run(MyApplication.class, args); + } + +}