Skip to content
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

Source paths cannot be relocated specifically using include/exclude. #1098

Closed
portlek opened this issue Dec 9, 2024 · 2 comments
Closed
Labels

Comments

@portlek
Copy link
Contributor

portlek commented Dec 9, 2024

When you try to relocate a certain path for a certain source package it doesn't work. #1059 this PR was fixing that specific issue. i cannot use the plugin just because of this problem, and i'll keep using my fork for now to avoid this bug.

Expected and Results

@Test
fun test() {
  val relocator1 = SimpleRelocator(
    "a.b.c",
    "x.y.z.shade.a.b.c",
  )
  val relocator2 = SimpleRelocator(
    "d.e.f",
    "x.y.z.shade.d.e.f"
  )
  relocator1.include("x/y/z/onlyabc/**")
  relocator2.include("x/y/z/onlydef/**")
  assertThat(
    relocator2.applyToSourceContent(
      relocator1.applyToSourceContent(complexSourceFile)
    )
  ).isEqualTo(complexRelocatedFile)
}

private companion object {
  val complexSourceFile = """
    package x.y.z.onlyabc;

    import a.b.c.Example;
    import a.b.c.d.Example;
    import d.e.f.Example;
    import d.e.f.g.Example;

    final class MyClass {}

    package x.y.z.onlydef;

    import a.b.c.Example;
    import a.b.c.d.Example;
    import d.e.f.Example;
    import d.e.f.g.Example;

    final class MyClass {}

    package x.y.z.nochanges;

    import a.b.c.Example;
    import a.b.c.d.Example;
    import d.e.f.Example;
    import d.e.f.g.Example;

    final class MyClass {}
  """.trimIndent()

  val complexRelocatedFile = """
    package x.y.z.onlyabc;

    import x.y.z.shade.a.b.c.Example;
    import x.y.z.shade.a.b.c.d.Example;
    import d.e.f.Example;
    import d.e.f.g.Example;

    final class MyClass {}

    package x.y.z.onlydef;

    import a.b.c.Example;
    import a.b.c.d.Example;
    import x.y.z.shade.d.e.f.Example;
    import x.y.z.shade.d.e.f.g.Example;

    final class MyClass {}

    package x.y.z.nochanges;

    import a.b.c.Example;
    import a.b.c.d.Example;
    import d.e.f.Example;
    import d.e.f.g.Example;

    final class MyClass {}
  """.trimIndent()
}

And this is the result it prints:

package x.y.z.onlyabc;

import x.y.z.shade.a.b.c.Example;
import x.y.z.shade.a.b.c.d.Example;
import x.y.z.shade.d.e.f.Example;
import x.y.z.shade.d.e.f.g.Example;

final class MyClass {}

package x.y.z.onlydef;

import x.y.z.shade.a.b.c.Example;
import x.y.z.shade.a.b.c.d.Example;
import x.y.z.shade.d.e.f.Example;
import x.y.z.shade.d.e.f.g.Example;

final class MyClass {}

package x.y.z.nochanges;

import x.y.z.shade.a.b.c.Example;
import x.y.z.shade.a.b.c.d.Example;
import x.y.z.shade.d.e.f.Example;
import x.y.z.shade.d.e.f.g.Example;

final class MyClass {}

Related environent and versions

Shadow 9.0.0-SNAPSHOT

@portlek portlek added the bug label Dec 9, 2024
@portlek portlek changed the title Include/Exclude for source paths do not work as it should be. Include/Exclude for source paths cannot be relocated specifically. Dec 9, 2024
@portlek portlek changed the title Include/Exclude for source paths cannot be relocated specifically. Source paths cannot be relocated specifically using include/exclude. Dec 9, 2024
@Goooler
Copy link
Member

Goooler commented Dec 10, 2024

I added a test for this in maven-shade-plugin, see Goooler/maven-shade-plugin@23c2a6b, it doesn't work here. We haven't called applyToSourceContent as I commented. If this function has any issue, please file it to maven-shade-plugin first.

@Goooler
Copy link
Member

Goooler commented Dec 13, 2024

Feel free to reopen this if needed.

@Goooler Goooler closed this as not planned Won't fix, can't repro, duplicate, stale Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants