Skip to content

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

Goooler
Copy link
Member

@Goooler Goooler commented Apr 16, 2025

@Goooler Goooler force-pushed the g/22050416/fix-issue-232 branch from 6e070d3 to 7ab3258 Compare April 16, 2025 06:55
Goooler added 2 commits April 17, 2025 18:14
# Conflicts:
#	src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/RelocationTest.kt
@Goooler Goooler force-pushed the g/22050416/fix-issue-232 branch from ad4a70a to de55c7b Compare April 17, 2025 10:21
@Goooler Goooler marked this pull request as ready for review April 23, 2025 09:37
@Goooler Goooler requested a review from Copilot April 24, 2025 03:01
Copy link
Contributor

@Copilot Copilot AI left a 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('.')))
Copy link
Preview

Copilot AI Apr 24, 2025

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.

Suggested change
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The plugin changes constants with values similar to package names
1 participant