-
Notifications
You must be signed in to change notification settings - Fork 966
Fix :core:shadedClasses failure
#6514
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
Conversation
Motivation:
':core:shadedClasses' fails when JaCoCo report is enabled by
`-Pcoverage`.
```java
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':core:shadedClasses'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:135)
at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:288)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:133)
...
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
at org.gradle.internal.concurrent.AbstractManagedExecutor$1.run(AbstractManagedExecutor.java:47)
Caused by: org.gradle.api.InvalidUserDataException: Cannot expand ZIP '/home/runner/work/armeria/armeria/core/build/libs/armeria-1.33.3-SNAPSHOT-shaded.jar' as it does not exist.
```
It is difficult to analyze why the test fails when JaCoCo is enabled,
but it seems the `archiveClassifier.set('shaded')` configuration used when
upgrading Gradle 9 is causing the problem.
Based on the following two configurations, the path of archiveFile
becomes `<artifact>-untrimmed-<version>-shaded.jar`.
https://github.com/line/armeria/blob/7148df07f3a7fe7cb4640fb1ca761cbaca8b347f/gradle/scripts/lib/java-shade.gradle#L28
https://github.com/line/armeria/blob/7148df07f3a7fe7cb4640fb1ca761cbaca8b347f/gradle/scripts/lib/java-shade.gradle#L118
This is then renamed to `<artifact>-shaded-<version>-shaded.jar` by
`trimShadedJar` task. However, since the input file of `shadedClasses` is
`<artifact>-<version>-shaded.jar`, the task fails to fine the jar file.
Modifications:
- Generate the output file name correctly by removing `untrimmed` infix
from the output jar file instead of renaming it to `shaded`.
Result:
`:core:shadedClasses` runs correctly
WalkthroughTwo Gradle scripts were updated: the shaded JAR filename calculation in Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Dev as Developer/Gradle
participant Pub as publishJarPublicationToMavenLocal
participant Shade as shadedJarTask
participant Repo as mavenLocal
Note over Dev,Pub: New dependency wiring added
Dev->>Pub: run publish to mavenLocal
alt shaded jar task exists
Pub->>Shade: dependsOn (ensure shaded artifact built)
Shade-->>Pub: produces shaded JAR
end
Pub->>Repo: upload artifact (shaded or normal)
Repo-->>Pub: publish complete
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
minwoox
left a comment
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.
👍
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6514 +/- ##
============================================
- Coverage 74.46% 74.18% -0.29%
- Complexity 22234 23273 +1039
============================================
Files 1963 2089 +126
Lines 82437 86975 +4538
Branches 10764 11433 +669
============================================
+ Hits 61385 64519 +3134
- Misses 15918 17002 +1084
- Partials 5134 5454 +320 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jrhee17
left a comment
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.
Double-checked that the actual publish doesn't depend on the trimmed jar's name
Motivation:
':core:shadedClasses' fails when JaCoCo report is enabled by
-PcoveragebecauseshadedClassesis only used in the JaCoco task.armeria/gradle/scripts/lib/java-coverage.gradle
Line 103 in 7148df0
It seems that the
archiveClassifier.set('shaded')configuration used when upgrading Gradle 9 is causing the problem.Based on the following two configurations, the path of archiveFile becomes
<artifact>-untrimmed-<version>-shaded.jar.armeria/gradle/scripts/lib/java-shade.gradle
Line 28 in 7148df0
armeria/gradle/scripts/lib/java-shade.gradle
Line 118 in 7148df0
This is then renamed to
<artifact>-shaded-<version>-shaded.jarbytrimShadedJartask. However, since the input file ofshadedClassesis<artifact>-<version>-shaded.jar, the task fails to fine the jar file.Modifications:
untrimmedinfix from the output jar file instead of renaming it toshaded.publishJarPublicationToMavenLocaldepend onshadedTaskortrimShadedJarto runpublishToMavenLocalsuccessfully.Result:
:core:shadedClassesruns correctlySummary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.