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

Files from project's sources overwrite merged dependencies (2.0.0 regression) #513

Open
piotrp opened this issue Nov 19, 2023 · 1 comment

Comments

@piotrp
Copy link

piotrp commented Nov 19, 2023

Presence of a file in META-INF/services/ makes sbt-assembly completely ignore the same file present in dependencies.

To verify this I modified bit tests in src/sbt-test/merging:

  1. Add mustContain(dir / "META-INF" / "services" / "srv", Seq("srv1", "srv2")) to check rules in build.sbt

  2. Prepare test data:

    mkdir -p src/main/1/META-INF/services
    echo "srv1" > src/main/1/META-INF/services/srv
    mkdir -p src/main/2/META-INF/services
    echo "srv2" > src/main/2/META-INF/services/srv
    cd src/main; ./mklibs.sh; cd ../../

Now we can verify that tests pass:

$ sbt -Dplugin.version=2.1.4 'assembly; check'
[info] welcome to sbt 1.7.2 (Eclipse Adoptium Java 11.0.20)
...
[info] 5 file(s) merged using strategy 'FilterDistinctLines' (Run the task at debug level to see the details)
...
[success] Total time: 2 s, completed 19 lis 2023, 19:01:56
[success] Total time: 6 s, completed 19 lis 2023, 19:02:02

So far so good, now let's add a file to local project:

mkdir -p src/main/resources/META-INF/services
echo "srv0" > src/main/resources/META-INF/services/srv

And re-run tests with check rule changed to mustContain(dir / "META-INF" / "services" / "srv", Seq("srv0", "srv1", "srv2")):

$ rm target/scala-2.12/foo.jar; sbt -Dplugin.version=2.1.4 'assembly; check'
[info] welcome to sbt 1.7.2 (Eclipse Adoptium Java 11.0.20)
...
[success] Total time: 1 s, completed 19 lis 2023, 19:14:12
[error] java.lang.Exception: file ...\Temp\sbt_9ee51824\META-INF\services\srv had wrong content:
[error] srv0
[error] *** instead of ***
[error] srv0
[error] srv1
[error] srv2

This worked correctly in sbt-assembly 1.2.0, and got broken with 2.0.0.

@piotrp piotrp changed the title Local files from META-INF/services/ hide files from dependencies (2.0.0 regression) Files from project's sources overwrite merged dependencies (2.0.0 regression) Nov 19, 2023
@piotrp
Copy link
Author

piotrp commented Jan 20, 2025

Issue is still present in 2.3.1, when building on Windows.

I uploaded a simple standalone test to https://github.com/piotrp/sbt-assembly-issue-513: META-INF/services/javax.mail.Provider should contain multiple entries, but it gets overwritten by file from repository.

Build log indicates that parent file is not seen by sbt-assembly, so nothing gets merged - file from project dependencies is ignored.

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

No branches or pull requests

1 participant