-
Notifications
You must be signed in to change notification settings - Fork 411
Support disabling of string constant remapping #1401
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
base: main
Are you sure you want to change the base?
Conversation
Goooler
commented
Apr 16, 2025
•
edited
Loading
edited
- Closes The plugin changes constants with values similar to package names #232.
- Ports [MSHADE-156] - Allow non relocating string literals apache/maven-shade-plugin#249.
- CHANGELOG's "Unreleased" section has been updated, if applicable.
6e070d3
to
7ab3258
Compare
5042c45
to
233e9e0
Compare
# Conflicts: # src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/RelocationTest.kt
ad4a70a
to
de55c7b
Compare
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.
Pull Request Overview
This PR adds support for disabling string constant remapping by introducing a new flag which, when enabled, prevents string literals from being remapped. Key changes include:
- Adding a new property (skipStringLiteral) in both SimpleRelocator and Relocator interfaces.
- Updating RelocatorRemapper’s mapping logic to respect the new flag.
- Adjusting functional tests and documentation to verify and record the new behavior.
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/relocation/SimpleRelocator.kt | Added skipStringLiteral property and updated equality/hashCode. |
src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/relocation/Relocator.kt | Introduced skipStringLiteral in the Relocator interface. |
src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/internal/RelocatorRemapper.kt | Modified remapping logic to conditionally skip string literal remapping. |
src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/RelocationTest.kt | Added tests to verify behavior with both enabled and disabled flag. |
docs/changes/README.md | Updated changelog to document the new feature. |
Files not reviewed (1)
- api/shadow.api: Language not supported
override fun map(name: String): String { | ||
override fun map(internalName: String): String = mapName(internalName) | ||
|
||
fun mapPath(path: String): String = map(path.substring(0, path.indexOf('.'))) |
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.
The use of path.indexOf('.') does not check for -1, which could lead to an exception if the input does not contain a period. Consider adding validation or a fallback mechanism to handle such cases.
fun mapPath(path: String): String = map(path.substring(0, path.indexOf('.'))) | |
fun mapPath(path: String): String { | |
val dotIndex = path.indexOf('.') | |
return if (dotIndex == -1) { | |
path // Return the original path if no period is found | |
} else { | |
map(path.substring(0, dotIndex)) | |
} | |
} |
Copilot uses AI. Check for mistakes.