Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Spring Boot 2.3.0 #2720

Merged
merged 10 commits into from
May 22, 2020

Conversation

matsumana
Copy link
Member

@matsumana matsumana commented May 18, 2020

Upgrade to Spring Boot 2.3.0

Still work in progress.
depends on #2716.

dependencies.yml Outdated
@@ -11,7 +11,9 @@ boms:
- io.netty:netty-bom:4.1.50.Final
- io.zipkin.brave:brave-bom:5.11.2
- org.eclipse.jetty:jetty-bom:9.4.28.v20200408
- org.springframework.boot:spring-boot-dependencies:2.3.0.RELEASE
Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I think adding spring-boot-dependencies is not a good idea. There are so many version conflicts with other modules such as dropwizard. Actually that's the reason we didn't use Spring BOM before.

Copy link
Contributor

Choose a reason for hiding this comment

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

So the solution is I think we need to add the needed dependencies one by one.

implementation "org.jctools:jctools-core:${managedVersions['org.jctools:jctools-core']}"
implementation "org.reflections:reflections:${managedVersions['org.reflections:reflections']}"
implementation "org.bouncycastle:bcprov-jdk15on:${managedVersions['org.bouncycastle:bcprov-jdk15on']}"
implementation "javax.inject:javax.inject:${managedVersions['javax.inject:javax.inject']}"
Copy link
Member Author

@matsumana matsumana May 18, 2020

Choose a reason for hiding this comment

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

If I don't add these settings, can't compile due to the following error.
Seems If I add dependency-management-plugin, these settings are not applied.
https://github.com/line/armeria/blob/master/build.gradle#L73-L132

$ ./gradlew :examples:spring-boot-minimal:build
> Task :examples:spring-boot-minimal:bootJar FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':examples:spring-boot-minimal:bootJar'.
> Could not resolve all files for configuration ':examples:spring-boot-minimal:productionRuntimeClasspath'.
   > Could not find com.spotify:completable-futures:.
     Required by:
         project :examples:spring-boot-minimal
         project :examples:spring-boot-minimal > project :core
         project :examples:spring-boot-minimal > project :spring:boot-starter
         project :examples:spring-boot-minimal > project :spring:boot-actuator-starter
         project :examples:spring-boot-minimal > project :spring:boot-starter > project :spring:boot-autoconfigure
         project :examples:spring-boot-minimal > project :spring:boot-actuator-starter > project :spring:boot-actuator-autoconfigure
         project :examples:spring-boot-minimal > project :spring:boot-starter > project :spring:boot-autoconfigure > project :logback
   > Could not find it.unimi.dsi:fastutil:.
     Required by:
         project :examples:spring-boot-minimal
         project :examples:spring-boot-minimal > project :core
         project :examples:spring-boot-minimal > project :spring:boot-starter
         project :examples:spring-boot-minimal > project :spring:boot-actuator-starter
         project :examples:spring-boot-minimal > project :spring:boot-starter > project :spring:boot-autoconfigure
         project :examples:spring-boot-minimal > project :spring:boot-actuator-starter > project :spring:boot-actuator-autoconfigure
         project :examples:spring-boot-minimal > project :spring:boot-starter > project :spring:boot-autoconfigure > project :logback
   > Could not find com.google.guava:guava:.
     Required by:
         project :examples:spring-boot-minimal
         project :examples:spring-boot-minimal > project :core
         project :examples:spring-boot-minimal > project :spring:boot-starter
         project :examples:spring-boot-minimal > project :spring:boot-actuator-starter
         project :examples:spring-boot-minimal > project :spring:boot-starter > project :spring:boot-autoconfigure
         project :examples:spring-boot-minimal > project :spring:boot-actuator-starter > project :spring:boot-actuator-autoconfigure
         project :examples:spring-boot-minimal > project :spring:boot-starter > project :spring:boot-autoconfigure > project :logback
   > Could not find com.google.code.findbugs:jsr305:.
     Required by:
         project :examples:spring-boot-minimal
         project :examples:spring-boot-minimal > project :core
         project :examples:spring-boot-minimal > project :spring:boot-starter
         project :examples:spring-boot-minimal > project :spring:boot-actuator-starter
         project :examples:spring-boot-minimal > project :spring:boot-starter > project :spring:boot-autoconfigure
         project :examples:spring-boot-minimal > project :spring:boot-actuator-starter > project :spring:boot-actuator-autoconfigure
         project :examples:spring-boot-minimal > project :spring:boot-starter > project :spring:boot-autoconfigure > project :logback
   > Could not find org.jctools:jctools-core:.
     Required by:
         project :examples:spring-boot-minimal
         project :examples:spring-boot-minimal > project :core
         project :examples:spring-boot-minimal > project :spring:boot-starter
         project :examples:spring-boot-minimal > project :spring:boot-actuator-starter
         project :examples:spring-boot-minimal > project :spring:boot-starter > project :spring:boot-autoconfigure
         project :examples:spring-boot-minimal > project :spring:boot-actuator-starter > project :spring:boot-actuator-autoconfigure
         project :examples:spring-boot-minimal > project :spring:boot-starter > project :spring:boot-autoconfigure > project :logback
   > Could not find org.reflections:reflections:.
     Required by:
         project :examples:spring-boot-minimal
         project :examples:spring-boot-minimal > project :core
         project :examples:spring-boot-minimal > project :spring:boot-starter
         project :examples:spring-boot-minimal > project :spring:boot-actuator-starter
         project :examples:spring-boot-minimal > project :spring:boot-starter > project :spring:boot-autoconfigure
         project :examples:spring-boot-minimal > project :spring:boot-actuator-starter > project :spring:boot-actuator-autoconfigure
         project :examples:spring-boot-minimal > project :spring:boot-starter > project :spring:boot-autoconfigure > project :logback
   > Could not find org.bouncycastle:bcprov-jdk15on:.
     Required by:
         project :examples:spring-boot-minimal > project :core
   > Could not find javax.inject:javax.inject:.
     Required by:
         project :examples:spring-boot-minimal > project :spring:boot-starter > project :spring:boot-autoconfigure
         project :examples:spring-boot-minimal > project :spring:boot-actuator-starter > project :spring:boot-actuator-autoconfigure

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.4/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 8s
49 actionable tasks: 4 executed, 45 up-to-date

Copy link
Contributor

@minwoox minwoox May 21, 2020

Choose a reason for hiding this comment

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

from Boot 2.3.0 productionRuntimeClasspath is newly added and its canBeConsumed is true, so the version is not added because this condition is not meet. https://github.com/line/gradle-scripts/blob/master/lib/common-dependencies.gradle#L156
Perhaps we can add a logic in https://github.com/line/gradle-scripts to set
configurations.productionRuntimeClasspath.setCanBeConsumed(false) if bootJar task exists.
@anuraaga Do you have any idea about this?

Copy link
Contributor

Choose a reason for hiding this comment

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

By the way, this is how I managed to build this:

diff --git a/dependencies.yml b/dependencies.yml
index ef594b06c..1e216a11f 100644
--- a/dependencies.yml
+++ b/dependencies.yml
@@ -494,12 +494,16 @@ org.slf4j:
     - https://static.javadoc.io/org.slf4j/slf4j-api/1.7.30/
   slf4j-simple: { version: *SLF4J_VERSION }

+org.springframework:
+  spring-web: { version: '5.2.6.RELEASE' }
+
 org.springframework.boot:
   spring-boot-starter:
-    version: &SPRING_BOOT_VERSION '2.2.7.RELEASE'
+    version: &SPRING_BOOT_VERSION '2.3.0.RELEASE'
     javadocs:
     - https://docs.spring.io/spring/docs/current/javadoc-api/
   spring-boot-actuator-autoconfigure: { version: *SPRING_BOOT_VERSION }
+  spring-boot-autoconfigure: { version: *SPRING_BOOT_VERSION }
   spring-boot-starter-actuator: { version: *SPRING_BOOT_VERSION }
   spring-boot-starter-test: { version: *SPRING_BOOT_VERSION }
   spring-boot-starter-web: { version: *SPRING_BOOT_VERSION }
diff --git a/examples/spring-boot-minimal-kotlin/build.gradle.kts b/examples/spring-boot-minimal-kotlin/build.gradle.kts
index 59dd1b093..581f4014d 100644
--- a/examples/spring-boot-minimal-kotlin/build.gradle.kts
+++ b/examples/spring-boot-minimal-kotlin/build.gradle.kts
@@ -23,6 +23,9 @@ apply(plugin = "org.jetbrains.kotlin.plugin.spring")
 apply(plugin = "org.jlleitschuh.gradle.ktlint")
 apply(plugin = "org.springframework.boot")

+val productionRuntimeClasspath by configurations
+productionRuntimeClasspath.setCanBeConsumed(false)
+
 dependencies {
     implementation(project(":spring:boot-starter"))
     implementation("org.hibernate.validator:hibernate-validator")
diff --git a/examples/spring-boot-minimal/build.gradle b/examples/spring-boot-minimal/build.gradle
index bcf6a5621..4874c0019 100644
--- a/examples/spring-boot-minimal/build.gradle
+++ b/examples/spring-boot-minimal/build.gradle
@@ -13,6 +13,8 @@ springBoot {
     mainClassName = 'example.springframework.boot.minimal.Main'
 }

+configurations.productionRuntimeClasspath.setCanBeConsumed(false)
+
 dependencies {
     implementation project(':spring:boot-starter')
     implementation 'org.hibernate.validator:hibernate-validator'
diff --git a/examples/spring-boot-tomcat/build.gradle b/examples/spring-boot-tomcat/build.gradle
index 58e678673..848ff7de2 100644
--- a/examples/spring-boot-tomcat/build.gradle
+++ b/examples/spring-boot-tomcat/build.gradle
@@ -13,6 +13,8 @@ springBoot {
     mainClassName = 'example.springframework.boot.tomcat.Main'
 }

+configurations.productionRuntimeClasspath.setCanBeConsumed(false)
+
 dependencies {
     implementation project(':core')
     implementation project(':spring:boot-starter')
diff --git a/examples/spring-boot-webflux/build.gradle b/examples/spring-boot-webflux/build.gradle
index bf2e04e6c..151773407 100644
--- a/examples/spring-boot-webflux/build.gradle
+++ b/examples/spring-boot-webflux/build.gradle
@@ -13,6 +13,8 @@ springBoot {
     mainClassName = 'example.springframework.boot.webflux.Main'
 }

+configurations.productionRuntimeClasspath.setCanBeConsumed(false)
+
 dependencies {
     implementation project(':spring:boot-webflux-starter')

diff --git a/it/spring/boot-tomcat/build.gradle b/it/spring/boot-tomcat/build.gradle
index 0aa813e30..e4f60230b 100644
--- a/it/spring/boot-tomcat/build.gradle
+++ b/it/spring/boot-tomcat/build.gradle
@@ -4,5 +4,6 @@ dependencies {
     implementation('org.springframework.boot:spring-boot-starter-web') {
         exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
     }
+    implementation 'org.springframework:spring-web'
     testImplementation('org.springframework.boot:spring-boot-starter-test')
 }
diff --git a/it/spring/boot-tomcat8.5/build.gradle b/it/spring/boot-tomcat8.5/build.gradle
index 0d549447e..b89b07700 100644
--- a/it/spring/boot-tomcat8.5/build.gradle
+++ b/it/spring/boot-tomcat8.5/build.gradle
@@ -1,21 +1,28 @@
 final def SPRING_BOOT_VERSION = '2.1.14.RELEASE'
+final def SPRING_VERSION = '5.1.15.RELEASE'
 final def TOMCAT_VERSION = '8.5.55'

 dependencies {
     implementation project(':spring:boot-starter')
     implementation project(':tomcat8.5')
-    implementation("org.springframework.boot:spring-boot-starter") {
-        version {
-            // Will fail the build if the override doesn't work
-            strictly SPRING_BOOT_VERSION
+
+    [ 'spring-boot-starter', 'spring-boot-autoconfigure', 'spring-boot-starter-web' ].each {
+        implementation("org.springframework.boot:$it") {
+            version {
+                // Will fail the build if the override doesn't work
+                strictly SPRING_BOOT_VERSION
+            }
+            exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
         }
     }
-    implementation("org.springframework.boot:spring-boot-starter-web") {
-        version {
-            // Will fail the build if the override doesn't work
-            strictly SPRING_BOOT_VERSION
+
+    [ 'spring-beans', 'spring-web' ].each {
+        implementation("org.springframework:$it") {
+            version {
+                // Will fail the build if the override doesn't work
+                strictly SPRING_VERSION
+            }
         }
-        exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
     }

     [ 'tomcat-embed-core', 'tomcat-embed-jasper', 'tomcat-embed-el' ].each {
diff --git a/spring/boot-actuator-autoconfigure/build.gradle b/spring/boot-actuator-autoconfigure/build.gradle
index 93c2aedc4..22fbd7fab 100644
--- a/spring/boot-actuator-autoconfigure/build.gradle
+++ b/spring/boot-actuator-autoconfigure/build.gradle
@@ -3,6 +3,8 @@ dependencies {
     api 'javax.inject:javax.inject'
     compileOnly 'javax.validation:validation-api'

+    implementation 'org.springframework.boot:spring-boot-autoconfigure'
+
     testImplementation 'org.springframework.boot:spring-boot-starter-actuator'
     testImplementation 'org.springframework.boot:spring-boot-starter-test'
     testImplementation 'io.projectreactor:reactor-test'
diff --git a/spring/boot-autoconfigure/build.gradle b/spring/boot-autoconfigure/build.gradle
index 3ae48457c..71d2b77d4 100644
--- a/spring/boot-autoconfigure/build.gradle
+++ b/spring/boot-autoconfigure/build.gradle
@@ -3,6 +3,8 @@ dependencies {
     compileOnly project(':thrift')
     implementation project(':logback')

+    implementation 'org.springframework.boot:spring-boot-autoconfigure'
+
     // TODO(anuraaga): Consider removing these since this module does not have related functionality.
     optionalApi 'io.micrometer:micrometer-registry-prometheus'
     optionalApi 'io.dropwizard.metrics:metrics-json'

@anuraaga
Copy link
Collaborator

Instead of adding the plugin can add a platform dependency on spring boot dependencies like here

https://github.com/anuraaga/aws-xray-sdk-with-opentelemetry-sample/blob/both-otel-and-xray/build.gradle.kts#L38

I guess it's nicer since uses modern Gradle features

@matsumana
Copy link
Member Author

Thank you for the info.
I could delete dependency-management-plugin.
But I still need these settings for compilation.
https://github.com/line/armeria/pull/2720/files#r426353588

I'm still investigating.

@trustin
Copy link
Member

trustin commented May 19, 2020

Hmm, that's interesting. Does Spring Boot Gradle plugin override our common dependencies?

@minwoox minwoox added this to the 0.99.6 milestone May 20, 2020
@ikhoon
Copy link
Contributor

ikhoon commented May 20, 2020

@matsumana Could you merge master branch to fix the failed test?

BraveServiceIntegrationTest > spanHandlerSeesException_async FAILED

@matsumana
Copy link
Member Author

merged master branch.
but seems the tests are still failing..

@matsumana
Copy link
Member Author

I'm still investigating but I realized this issue is occurring in bootJar task.
compileJava is finished without problem.

> Task :checkJavaVersion
> Task :core:compileJava UP-TO-DATE
> Task :core:versionProperties UP-TO-DATE
> Task :core:processResources UP-TO-DATE
> Task :docs-client:nodeSetup UP-TO-DATE
> Task :docs-client:yarnSetup UP-TO-DATE
> Task :docs-client:yarn UP-TO-DATE
> Task :docs-client:buildWeb UP-TO-DATE
> Task :docs-client:copyWeb UP-TO-DATE
> Task :core:classes UP-TO-DATE
> Task :core:checkstyleMain UP-TO-DATE
> Task :core:compileJava9Java UP-TO-DATE
> Task :core:processJava9Resources NO-SOURCE
> Task :core:java9Classes UP-TO-DATE
> Task :core:checkstyleJava9 UP-TO-DATE
> Task :core:jar UP-TO-DATE
> Task :logback:compileJava UP-TO-DATE
> Task :logback:versionProperties UP-TO-DATE
> Task :logback:processResources UP-TO-DATE
> Task :logback:classes UP-TO-DATE
> Task :logback:checkstyleMain UP-TO-DATE
> Task :logback:jar UP-TO-DATE
> Task :annotation-processor:compileJava UP-TO-DATE
> Task :annotation-processor:processResources UP-TO-DATE
> Task :annotation-processor:classes UP-TO-DATE
> Task :annotation-processor:jar UP-TO-DATE
> Task :annotation-processor:checkstyleMain UP-TO-DATE
> Task :thrift:compileJava UP-TO-DATE
> Task :thrift:versionProperties UP-TO-DATE
> Task :thrift:processResources UP-TO-DATE
> Task :thrift:classes UP-TO-DATE
> Task :thrift:checkstyleMain UP-TO-DATE
> Task :spring:boot-autoconfigure:extractIncludeProto UP-TO-DATE
> Task :spring:boot-autoconfigure:extractProto UP-TO-DATE
> Task :spring:boot-autoconfigure:generateProto NO-SOURCE
> Task :spring:boot-autoconfigure:compileJava UP-TO-DATE
> Task :spring:boot-autoconfigure:versionProperties UP-TO-DATE
> Task :spring:boot-autoconfigure:processResources UP-TO-DATE
> Task :spring:boot-autoconfigure:classes UP-TO-DATE
> Task :spring:boot-autoconfigure:checkstyleMain UP-TO-DATE
> Task :spring:boot-starter:compileJava NO-SOURCE
> Task :spring:boot-starter:versionProperties UP-TO-DATE
> Task :spring:boot-starter:processResources UP-TO-DATE
> Task :spring:boot-starter:classes UP-TO-DATE
> Task :spring:boot-starter:checkstyleMain NO-SOURCE
> Task :examples:spring-boot-minimal:compileJava
> Task :examples:spring-boot-minimal:processResources
> Task :examples:spring-boot-minimal:classes
> Task :examples:spring-boot-minimal:checkstyleMain
> Task :spring:boot-actuator-autoconfigure:copyFiles UP-TO-DATE
> Task :spring:boot-actuator-autoconfigure:compileJava UP-TO-DATE
> Task :spring:boot-actuator-autoconfigure:versionProperties UP-TO-DATE
> Task :spring:boot-actuator-autoconfigure:processResources UP-TO-DATE
> Task :spring:boot-actuator-autoconfigure:classes UP-TO-DATE
> Task :spring:boot-actuator-autoconfigure:checkstyleMain UP-TO-DATE
> Task :spring:boot-actuator-autoconfigure:jar UP-TO-DATE
> Task :spring:boot-actuator-starter:compileJava NO-SOURCE
> Task :spring:boot-actuator-starter:versionProperties UP-TO-DATE
> Task :spring:boot-actuator-starter:processResources UP-TO-DATE
> Task :spring:boot-actuator-starter:classes UP-TO-DATE
> Task :spring:boot-actuator-starter:checkstyleMain NO-SOURCE
> Task :spring:boot-actuator-starter:jar UP-TO-DATE
> Task :spring:boot-autoconfigure:jar UP-TO-DATE
> Task :spring:boot-starter:jar UP-TO-DATE
> Task :examples:spring-boot-minimal:bootJar FAILED

@codecov
Copy link

codecov bot commented May 21, 2020

Codecov Report

Merging #2720 into master will increase coverage by 0.01%.
The diff coverage is 83.33%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2720      +/-   ##
============================================
+ Coverage     72.62%   72.63%   +0.01%     
- Complexity    11631    11637       +6     
============================================
  Files          1025     1026       +1     
  Lines         45605    45636      +31     
  Branches       5683     5688       +5     
============================================
+ Hits          33119    33148      +29     
- Misses         9566     9568       +2     
  Partials       2920     2920              
Impacted Files Coverage Δ Complexity Δ
...ecorp/armeria/common/logging/RequestScopedMdc.java 87.73% <83.33%> (ø) 23.00 <3.00> (ø)
...n/java/com/linecorp/armeria/server/HttpServer.java 40.00% <0.00%> (-20.00%) 2.00% <0.00%> (-1.00%)
.../com/linecorp/armeria/client/DefaultWebClient.java 89.74% <0.00%> (-2.15%) 13.00% <0.00%> (+1.00%) ⬇️
...com/linecorp/armeria/server/HttpServerHandler.java 81.00% <0.00%> (-1.34%) 79.00% <0.00%> (-2.00%)
...a/com/linecorp/armeria/common/util/Exceptions.java 37.30% <0.00%> (-0.80%) 30.00% <0.00%> (-1.00%)
...inecorp/armeria/server/grpc/ArmeriaServerCall.java 87.20% <0.00%> (-0.39%) 84.00% <0.00%> (-1.00%)
...nal/server/annotation/AnnotatedServiceFactory.java 87.53% <0.00%> (-0.38%) 82.00% <0.00%> (+2.00%) ⬇️
...gframework/boot/minimal/HelloAnnotatedService.java 66.66% <0.00%> (ø) 2.00% <0.00%> (ø%)
...r/annotation/processor/DocumentationProcessor.java 0.00% <0.00%> (ø) 0.00% <0.00%> (ø%)
...erver/annotation/ProcessedDocumentationHelper.java 100.00% <0.00%> (ø) 1.00% <0.00%> (?%)
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f3b96e0...7cacee1. Read the comment docs.

@matsumana matsumana changed the title [WIP] Upgrade to Spring Boot 2.3.0 Upgrade to Spring Boot 2.3.0 May 21, 2020
@matsumana
Copy link
Member Author

Updated.
Thank you for your comments.

Copy link
Contributor

@minwoox minwoox left a comment

Choose a reason for hiding this comment

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

Thanks, @matsumana!

Copy link
Contributor

@ikhoon ikhoon left a comment

Choose a reason for hiding this comment

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

Thanks! @matsumana and @minwoox

Copy link
Member

@trustin trustin left a comment

Choose a reason for hiding this comment

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

Thanks a lot, folks! @matsumana, could you send a pull request to line/gradle-scripts before I merge this?

@matsumana
Copy link
Member Author

Sure, created.
line/gradle-scripts#74

trustin pushed a commit to line/gradle-scripts that referenced this pull request May 22, 2020
This PR adds support for Spring Boot 2.3.
See: line/armeria#2720
@trustin trustin merged commit eb20c4e into line:master May 22, 2020
@matsumana matsumana deleted the feature/upgrade-spring-boot-2.3.0 branch May 22, 2020 07:04
@matsumana
Copy link
Member Author

Thank you!

fmguerreiro pushed a commit to fmguerreiro/armeria that referenced this pull request Sep 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants