Skip to content
Closed
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2ce6cc1
feat: add Kt alternatives for Java samples from 4.4 to 6.8
p7nov Nov 24, 2021
83ad898
fix: snippet markup in spring-application.adoc
p7nov Nov 24, 2021
b59667c
feat: add Kt alternatives for Java samples in 7.2
p7nov Nov 25, 2021
4aa23b5
fix: kotlin highlight in code samples
p7nov Nov 25, 2021
d0b274a
feat: add Kt alternatives to Java sample in 7.4
p7nov Nov 25, 2021
8afe106
feat: add Kt alternatives to Java samples in 7.8
p7nov Nov 26, 2021
c7d8324
fix: remove internal and @Throws in kt examples in 7.8
p7nov Dec 3, 2021
38491e2
feat: add Kt alternatives to java samples in 7.9
p7nov Dec 3, 2021
364377d
feat: add Kt alternatives to java samples in 8.1
p7nov Dec 3, 2021
728e590
feat: add Kt alternatives to java samples in 8.2 - 8.4
p7nov Dec 3, 2021
0ff0638
feat: add Kt alternatives to java samples in 9.1
p7nov Dec 6, 2021
d02dcba
feat: add Kt alternatives to java samples in 9.2
p7nov Dec 6, 2021
98d4770
feat: add Kt alternatives to java samples in 10.1
p7nov Dec 6, 2021
5714c18
feat: add Kt alternatives to java samples in 10.2 and 10.3
p7nov Dec 6, 2021
43a0498
feat: add Kt alternatives to java samples in 10.4
p7nov Dec 6, 2021
67525ad
feat: add Kt alternatives to java samples in 11.1
p7nov Dec 6, 2021
9bd3abc
feat: add Kt alternatives to java samples in 11.3
p7nov Dec 6, 2021
0cecda0
feat: add Kt alternatives to java samples in 11.5
p7nov Dec 6, 2021
ef2378f
feat: add Kt alternatives to java samples in 11.6 - 11.8
p7nov Dec 6, 2021
e39b383
feat: add Kt alternatives to java samples in 13.2
p7nov Dec 6, 2021
51917c9
feat: add Kt alternatives to java samples in 13.6
p7nov Dec 6, 2021
b668095
feat: add Kt alternatives to java samples in 13.10 - 17.6
p7nov Dec 8, 2021
09af420
feat: add Kt alternatives to java samples from 17.8 to the end
p7nov Dec 8, 2021
494c34c
fix: failing Kotlin samples
p7nov Jan 21, 2022
7e13360
fix: failing Kotlin samples
p7nov Jan 21, 2022
d330741
update: Kotlin lang and API version to 1.6
p7nov Jan 21, 2022
99209cd
fix: warnings & file names
p7nov Jan 21, 2022
34c1eac
fix: lateinit instead of @MockBean
p7nov Jan 27, 2022
7157f4a
chore: set warnings as errors to false in spring-boot-docs
p7nov Jan 27, 2022
1dae6b9
fix: add lost @MockBean
p7nov Jan 27, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ void apply(Project project) {
project.getPlugins().withId("org.jetbrains.kotlin.jvm", (plugin) -> {
project.getTasks().withType(KotlinCompile.class, (compile) -> {
KotlinJvmOptions kotlinOptions = compile.getKotlinOptions();
kotlinOptions.setApiVersion("1.3");
kotlinOptions.setLanguageVersion("1.3");
kotlinOptions.setAllWarningsAsErrors(true);
kotlinOptions.setApiVersion("1.6");
kotlinOptions.setLanguageVersion("1.6");
kotlinOptions.setAllWarningsAsErrors(false);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took the liberty to switch this to false because there are warnings that are meaningless in sample code (such as parameter is never used in functions with empty bodies) and they break the build.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should do this specifically for the docs project, leaving warnings as errors by convention.

Copy link
Contributor Author

@p7nov p7nov Jan 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returned this setting to true; set to false in build.gradle of spring-boot-docs.

List<String> freeCompilerArgs = new ArrayList<>(compile.getKotlinOptions().getFreeCompilerArgs());
freeCompilerArgs.add("-Xsuppress-version-warnings");
compile.getKotlinOptions().setFreeCompilerArgs(freeCompilerArgs);
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ org.gradle.jvmargs=-Xmx2g -Dfile.encoding=UTF-8
kotlinVersion=1.6.10
tomcatVersion=9.0.56

kotlin.stdlib.default.dependency=false
kotlin.stdlib.default.dependency=true
24 changes: 24 additions & 0 deletions spring-boot-project/spring-boot-docs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
id "org.asciidoctor.jvm.convert"
id "org.springframework.boot.conventions"
id "org.springframework.boot.deployed"
id 'org.jetbrains.kotlin.jvm'
}

description = "Spring Boot Docs"
Expand Down Expand Up @@ -173,6 +174,7 @@ dependencies {
testRuntimeOnly("org.springframework:spring-jdbc")

testSlices(project(path: ":spring-boot-project:spring-boot-test-autoconfigure", configuration: "testSliceMetadata"))
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
}

task dependencyVersions(type: org.springframework.boot.build.constraints.ExtractVersionConstraints) {
Expand Down Expand Up @@ -324,6 +326,9 @@ syncDocumentationSourceForAsciidoctor {
from("src/main/groovy") {
into "main/groovy"
}
from("src/main/kotlin") {
into "main/kotlin"
}
from("src/main/resources") {
into "main/resources"
}
Expand All @@ -348,6 +353,9 @@ syncDocumentationSourceForAsciidoctorMultipage {
from("src/main/groovy") {
into "main/groovy"
}
from("src/main/kotlin") {
into "main/kotlin"
}
from("src/main/resources") {
into "main/resources"
}
Expand All @@ -372,6 +380,9 @@ syncDocumentationSourceForAsciidoctorPdf {
from("src/main/groovy") {
into "main/groovy"
}
from("src/main/kotlin") {
into "main/kotlin"
}
from("src/main/resources") {
into "main/resources"
}
Expand Down Expand Up @@ -427,3 +438,16 @@ publishing {
}
}
}
repositories {
mavenCentral()
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ If you expect the Cloud Foundry endpoints to always be available at `/cloudfound
The configuration differs, depending on the web server in use.
For Tomcat, you can add the following configuration:

[source,java,indent=0,subs="verbatim"]
.Java
[source,java,indent=0,subs="verbatim",role="primary"]
----
include::{docs-java}/actuator/cloudfoundry/customcontextpath/MyCloudFoundryConfiguration.java[]
----
.Kotlin
[source,kotlin,indent=0,subs="verbatim",role="secondary"]
----
include::{docs-kotlin}/actuator/cloudfoundry/customcontextpath/MyCloudFoundryConfiguration.kt[]
----
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,16 @@ If you wish to configure custom security for HTTP endpoints (for example, to all

A typical Spring Security configuration might look something like the following example:

[source,java,indent=0,subs="verbatim"]
.Java
[source,java,indent=0,subs="verbatim",role="primary"]
----
include::{docs-java}/actuator/endpoints/security/typical/MySecurityConfiguration.java[]
----
.Kotlin
[source,kotlin,indent=0,subs="verbatim",role="secondary"]
----
include::{docs-kotlin}/actuator/endpoints/security/typical/MySecurityConfiguration.kt[]
----

The preceding example uses `EndpointRequest.toAnyEndpoint()` to match a request to any endpoint and then ensures that all have the `ENDPOINT_ADMIN` role.
Several other matcher methods are also available on `EndpointRequest`.
Expand All @@ -351,10 +357,16 @@ You can do so by changing the configprop:management.endpoints.web.exposure.inclu

Additionally, if Spring Security is present, you would need to add custom security configuration that allows unauthenticated access to the endpoints, as the following example shows:

[source,java,indent=0,subs="verbatim"]
.Java
[source,java,indent=0,subs="verbatim",role="primary"]
----
include::{docs-java}/actuator/endpoints/security/exposeall/MySecurityConfiguration.java[]
----
.Kotlin
[source,kotlin,indent=0,subs="verbatim",role="secondary"]
----
include::{docs-kotlin}/actuator/endpoints/security/exposeall/MySecurityConfiguration.kt[]
----

NOTE: In both of the preceding examples, the configuration applies only to the actuator endpoints.
Since Spring Boot's security configuration backs off completely in the presence of any `SecurityFilterChain` bean, you need to configure an additional `SecurityFilterChain` bean with rules that apply to the rest of the application.
Expand Down Expand Up @@ -443,10 +455,16 @@ If both Jersey and Spring MVC are available, Spring MVC is used.

The following example exposes a read operation that returns a custom object:

[source,java,indent=0,subs="verbatim"]
.Java
[source,java,indent=0,subs="verbatim",role="primary"]
----
include::{docs-java}/actuator/endpoints/implementingcustom/MyEndpoint.java[tag=read]
----
.Kotlin
[source,kotlin,indent=0,subs="verbatim",role="secondary"]
----
include::{docs-kotlin}/actuator/endpoints/implementingcustom/MyEndpoint.kt[tag=read]
----

You can also write technology-specific endpoints by using `@JmxEndpoint` or `@WebEndpoint`.
These endpoints are restricted to their respective technologies.
Expand Down Expand Up @@ -480,10 +498,16 @@ Consider the following JSON request body:

You can use this to invoke a write operation that takes `String name` and `int counter` parameters, as the following example shows:

[source,java,indent=0,subs="verbatim"]
.Java
[source,java,indent=0,subs="verbatim",role="primary"]
----
include::{docs-java}/actuator/endpoints/implementingcustom/MyEndpoint.java[tag=write]
----
.Kotlin
[source,kotlin,indent=0,subs="verbatim",role="secondary"]
----
include::{docs-kotlin}/actuator/endpoints/implementingcustom/MyEndpoint.kt[tag=write]
----

TIP: Because endpoints are technology agnostic, only simple types can be specified in the method signature.
In particular, declaring a single parameter with a `CustomData` type that defines a `name` and `counter` properties is not supported.
Expand Down Expand Up @@ -759,10 +783,16 @@ You need to provide an implementation of the `health()` method and return a `Hea
The `Health` response should include a status and can optionally include additional details to be displayed.
The following code shows a sample `HealthIndicator` implementation:

[source,java,indent=0,subs="verbatim"]
.Java
[source,java,indent=0,subs="verbatim",role="primary"]
----
include::{docs-java}/actuator/endpoints/health/writingcustomhealthindicators/MyHealthIndicator.java[]
----
.Kotlin
[source,kotlin,indent=0,subs="verbatim",role="secondary"]
----
include::{docs-kotlin}/actuator/endpoints/health/writingcustomhealthindicators/MyHealthIndicator.kt[]
----

NOTE: The identifier for a given `HealthIndicator` is the name of the bean without the `HealthIndicator` suffix, if it exists.
In the preceding example, the health information is available in an entry named `my`.
Expand Down Expand Up @@ -837,10 +867,17 @@ If you need to register a regular `HealthContributor`, you should wrap it with `
To provide custom health information from a reactive API, you can register Spring beans that implement the {spring-boot-actuator-module-code}/health/ReactiveHealthIndicator.java[`ReactiveHealthIndicator`] interface.
The following code shows a sample `ReactiveHealthIndicator` implementation:

[source,java,indent=0,subs="verbatim"]
.Java
[source,java,indent=0,subs="verbatim",role="primary"]
----
include::{docs-java}/actuator/endpoints/health/reactivehealthindicators/MyReactiveHealthIndicator.java[]
----
.Kotlin
[source,kotlin,indent=0,subs="verbatim",role="secondary"]
----
include::{docs-kotlin}/actuator/endpoints/health/reactivehealthindicators/MyReactiveHealthIndicator.kt[]
----


TIP: To handle the error automatically, consider extending from `AbstractReactiveHealthIndicator`.

Expand Down Expand Up @@ -1283,10 +1320,16 @@ To provide custom application information, you can register Spring beans that im

The following example contributes an `example` entry with a single value:

[source,java,indent=0,subs="verbatim"]
.Java
[source,java,indent=0,subs="verbatim",role="primary"]
----
include::{docs-java}/actuator/endpoints/info/writingcustominfocontributors/MyInfoContributor.java[]
----
.Kotlin
[source,kotlin,indent=0,subs="verbatim",role="secondary"]
----
include::{docs-kotlin}/actuator/endpoints/info/writingcustominfocontributors/MyInfoContributor.kt[]
----

If you reach the `info` endpoint, you should see a response that contains the following additional entry:

Expand Down
Loading