Skip to content

Relocation does not work properly for some method parameters #1427

Description

@ksaweryr

Expected and Results

Issue

When trying to relocate a library, some method parameters don't get relocated properly. E.g., when trying to include ktor version 3.1.3 into the project and relocate it, some parameters in io.ktor.http.Cookie.<init> don't get relocated correctly.

Expected result

The Cookie constructor has the signature (Ljava/lang/String;Ljava/lang/String;Lcom/example/shadowed/ktor/http/CookieEncoding;Ljava/lang/Integer;Lcom/example/shadowed/ktor/util/date/GMTDate;Ljava/lang/String;Ljava/lang/String;ZZLjava/util/Map;)V

Actual result

The Cookie constructor has the signature (Ljava/lang/String;Ljava/lang/String;Lio/ktor/http/CookieEncoding;Ljava/lang/Integer;Lio/ktor/util/date/GMTDate;Ljava/lang/String;Ljava/lang/String;ZZLjava/util/Map;)V

Related environment and versions

Gradle version: 8.13
shadow version: 8.3.5 (also tested with 9.0.0-beta13, has the same issue)
ktor version: 3.1.3

Reproduction steps

  1. Initialize a new gradle Kotlin application project.
  2. Add ktor as a dependency:
dependencies {
    // Use the Kotlin JUnit 5 integration.
    testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")

    // Use the JUnit 5 integration.
    testImplementation(libs.junit.jupiter.engine)

    testRuntimeOnly("org.junit.platform:junit-platform-launcher")

    // This dependency is used by the application.
    implementation(libs.guava)

    implementation("io.ktor:ktor-client-core:3.1.3")
    implementation("io.ktor:ktor-client-okhttp:3.1.3")
}
  1. Add shadowJar plugin and relocations:
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

plugins {
    // Apply the org.jetbrains.kotlin.jvm Plugin to add support for Kotlin.
    alias(libs.plugins.kotlin.jvm)

    // Apply the application plugin to add support for building a CLI application in Java.
    application
    id("com.gradleup.shadow") version "8.3.5"
}

[...]

tasks {
    named<ShadowJar>("shadowJar") {
        relocate("io.ktor", "org.example.shadowed.ktor")
    }
}
  1. Run $ ./gradlew build
  2. Inspect org/example/shadowed/ktor/http/Cookie.class in app/build/libs/app-all.jar file

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions