-
Notifications
You must be signed in to change notification settings - Fork 926
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 Gradle to 8.1.1 #4854
Upgrade Gradle to 8.1.1 #4854
Conversation
Motivation: [Gradle 8](https://docs.gradle.org/8.0/release-notes.html) has been released. Modifications: - In Gradle 8, dependencies can't be declared in a resolvable configuration (canBeResolved=true). `gradle-scripts` used the resolvable configurations such as `compileClasspath`, `runtimeClasspath` to inject platform dependencies. https://github.com/line/armeria/blob/20969832640bcc0fa66edc68c531891ab35cea25/gradle/scripts/lib/common-dependencies.gradle#L180-L183 ``` * Where: Script '.../gradle/scripts/lib/common-dependencies.gradle' * What went wrong: A problem occurred configuring project ':foobar'. > Dependencies can not be declared against the `compileClasspath` configuration. ``` `platform` dependencies should be added to non resolvable and non configurations. There is no workaround to set dependencies to resolvable configurations. So I changed `common-dependencies.gradle` to set platform dependencies to the non resolvable and non configurations. `shadedTestImplementation` is newly added to declare dependencies while configuring `shadedTest` task. The original `shadedTestRuntime` extends `shadedTestImplementation` and is only used to resolve its dependencies. - Gradle 8 also disallows implicit dependencies between two tasks. The solution was quite simple. I added an explicit dependency for the implcit dependency with `.dependsOn(...)` whenever encounting the error. Result: You can now use Gradle 8 with `gradle-scripts`.
@@ -15,8 +15,6 @@ buildscript { | |||
} | |||
} | |||
|
|||
def managedDependencyOverrides = [] as Set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was an unused code.
tasks.runKtlintCheckOverMainSourceSet.dependsOn(project.ext.getGenerateSourcesTask()) | ||
|
||
// `tasks.withType(KtLintCheckTask)` does not work here. | ||
['Main', 'Test', 'Jmh'].each { name -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jmh
module injects runKtlintCheckOverJmhSourceSet
and compileJmhKotlin
that tasks need explicit dependencies for generated sources from proto or thrift files.
Thanks for looking into this potentially very tricky issue, @ikhoon! Let me wait for the build to pass first at the moment. |
group: 'Verification', | ||
description: 'Runs the TestNG unit tests.', | ||
dependsOn: tasks.shadedTestClasses) { | ||
useTestNG() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gradle prohibits overriding the test engine with Test
tasks.
On the other hand, the JVM Test Suite Plugin supports multiple test engines.
So the test tasks have been migrated to the new test plugin.
…rride it on FixedStreamMessageVerification
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the upgrade. 🙇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much, @ikhoon! This is a labor of love 💘
@@ -38,7 +38,7 @@ | |||
@SpringBootTest(classes = TestConfiguration.class) | |||
@ActiveProfiles({ "local", "settings" }) | |||
@DirtiesContext | |||
class ArmeriaSettingsConfigurationTest { | |||
public class ArmeriaSettingsConfigurationTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Why was this necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ArmeriaSettingsConfigurationTest
uses JUnit 4 which requires a public class.
I don't get why it wasn't detected before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a minor question but looks good to me! Thanks @ikhoon 🙇 👍 🚀
} | ||
|
||
// Use a different JRE for testing if necessary. | ||
if (rootProject.ext.buildJdkVersion != rootProject.ext.testJavaVersion) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question) Would it be better to pull changes from line/gradle-scripts#148 before merging this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea.
add(configuration.name, platform(dependencyManagementProject)) | ||
} | ||
|
||
// Find version overrides in dependency declaration configurations | ||
if (!configuration.canBeResolved && !configuration.canBeConsumed) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question) I'm wondering if we want to target resolvable dependencies instead (since these are the configurations which will actually be applied)
if (!configuration.canBeResolved && !configuration.canBeConsumed) { | |
if (configuration.canBeResolved && !configuration.canBeConsumed) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are three types of configurations.
- Bucket -
implementation
,api
... - Resolvable -
compileClasspath
,runtimeClasspath
, ... - Consumable -
apiElement
, ...
We directly added the dependencies to resolvable configurations. In particular, platform dependencies are added to each configuration here. Unfortunately, in Gradle 8, bucket styles are only allowed to add dependencies, and exceptions are raised if the dependencies are added to resolvable ones.
So I changed to add the platform dependencies to the buckets. It should be fine because they will be eventually inherited into resolvable configurations. All resolvable configurations defined in the Gradle Java plugin have at least one bucket configuration.
https://docs.gradle.org/current/userguide/java_library_plugin.html#sec:java_library_configurations_graph
The only exception was shadedTestRuntime
created by gradle-scripts
that does not have a bucket parent. I added shadedTestImplementation
as a bucket so that we inject the platform dependencies into it. As shadedTestRuntime
extends shadedTestImplementation
, all dependencies added to shadedTestImplementation
will be visible to shadedTestRuntime
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understood the concept while reviewing the PR, but I'm not sure why I left this review 😅 Sorry about that.
In short, I understood that we can't add dependencies to a resolvable configuration 🙇
Co-authored-by: minux <songmw725@gmail.com>
subrepo: subdir: "gradle/scripts" merged: "c20bc5b41" upstream: origin: "https://github.com/line/gradle-scripts" branch: "main" commit: "c20bc5b41" git-subrepo: version: "0.4.5" origin: "https://github.com/ingydotnet/git-subrepo" commit: "dbb99be"
All bugs encountered while upgrading Gradle 8 have been fixed. I will send a PR to line/gradle-scripts. |
See line/armeria#4854 for the detailed motivation and changes.
See line/armeria#4854 for the detailed motivation and changes.
Thanks for reviewing. 🙇♂️ |
Motivation:
Gradle 8 has been released.
Modifications:
In Gradle 8, dependencies can't be declared in a resolvable configuration (
canBeResolved=true
).gradle-scripts
used resolvable configurations such ascompileClasspath
,runtimeClasspath
to inject platform dependencies.armeria/gradle/scripts/lib/common-dependencies.gradle
Lines 180 to 183 in 2096983
platform
dependencies should be added to non resolvable and nonconfigurations. There is no workaround to set dependencies to
resolvable configurations. So I changed
common-dependencies.gradle
to set platform dependencies to the non resolvable and non
configurations.
As a workaround
shadedTestImplementation
is newly added to declaredependencies while configuring
shadedTest
task. The originalshadedTestRuntime
extends
shadedTestImplementation
and is only used to resolve its dependencies.Related discussion: https://discuss.gradle.org/t/problem-with-compileclasspath-after-gradle-8-update/44940
Gradle 8 also disallows implicit dependencies between two tasks. The solution was quite simple. I added an explicit dependency for the implicit dependency with
.dependsOn(...)
whenever encountering the error.Result:
You can now use Gradle 8 with
gradle-scripts
.