Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

9.0.0-beta9 - adding jar dependency using from doesn't extract jar content #1284

Closed
rjaros opened this issue Feb 26, 2025 · 3 comments · Fixed by #1285
Closed

9.0.0-beta9 - adding jar dependency using from doesn't extract jar content #1284

rjaros opened this issue Feb 26, 2025 · 3 comments · Fixed by #1285
Labels

Comments

@rjaros
Copy link

rjaros commented Feb 26, 2025

Expected and Results

I have a custom ShadowJar task and I'm using from() method to add additional jar files. Up to beta8 the added jar files were extracted and that's what I need. But with beta9 they are not - they are just added as *.jar files to my shadow jar.
I have found some inconsistent comments about the from method usage. According to this:
https://github.com/GradleUp/shadow/blob/main/src/docs/configuration/README.md#adding-extra-files
the content should be extracted. But according to this PR #1250 it should not. So I'm not sure if the change was intentional? If the answer is yes, how can I achieve the old behaviour?

Related environent and versions

No response

Reproduction steps

No response

Anything else?

No response

@rjaros rjaros added the bug label Feb 26, 2025
@Goooler
Copy link
Member

Goooler commented Feb 26, 2025

It's intended.

from means copying the file into the destination in the shadowed jar without unzipping, this is the correct behavior, which aligns with the behavior in Gradle's Jar task. The behavior before 9.0.0-beta9 is wrong...

If you still want to add extracted jars into the shadowed jar, please try out

dependencies {
  implementation file('foo.jar')
  implementation file('bar.jar')
  ..
}

@Goooler Goooler closed this as not planned Won't fix, can't repro, duplicate, stale Feb 26, 2025
@rjaros
Copy link
Author

rjaros commented Feb 26, 2025

And how can I do this in a custom ShadowJar task? My current code looks like this:

tasks.register<ShadowJar>("myShadowTask") {
    // ...
    from(project.tasks["otherJarTask"].outputs.files)
    // ...
}

@Goooler
Copy link
Member

Goooler commented Feb 26, 2025

Try to wrap your project.tasks["otherJarTask"].outputs with the configuration configured by myShadowTask, e.g.

dependencies {
  implementation project.tasks["otherJarTask"].outputs.files
  ..
}

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

Successfully merging a pull request may close this issue.

2 participants