sbt / sbt-osgi

sbt plugin for creating OSGi bundles
Apache License 2.0
47 stars 43 forks source link

Duplicated `META-INF/MANIFEST.MF` entries when using `packageWithJVMJar := true` on Windows #113

Closed He-Pin closed 7 months ago

He-Pin commented 7 months ago
sbt:pekko-bench-jmh> last actor / osgiBundle
[info] Validating all packages are set private or exported for OSGi explicitly...
[warn] bnd: Unused -privatepackage instructions , no such package(s) on the class path: [org.apache.pekko.osgi.impl]
[warn] bnd: Unused Import-Package instructions: [scala.compat.java8.*]
[error] java.util.zip.ZipException: duplicate entry: META-INF/MANIFEST.MF
[error]         at java.base/java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:233)
[error]         at java.base/java.util.jar.JarOutputStream.putNextEntry(JarOutputStream.java:109)
[error]         at sbt.io.IO$.addFileEntry$1(IO.scala:717)
[error]         at sbt.io.IO$.$anonfun$writeZip$6(IO.scala:726)
[error]         at sbt.io.IO$.$anonfun$writeZip$6$adapted(IO.scala:726)
[error]         at scala.collection.immutable.Stream.foreach(Stream.scala:533)
[error]         at sbt.io.IO$.writeZip(IO.scala:726)
[error]         at sbt.io.IO$.$anonfun$archive$2(IO.scala:676)
[error]         at sbt.io.IO$.$anonfun$archive$2$adapted(IO.scala:673)
[error]         at sbt.io.IO$.$anonfun$withZipOutput$1(IO.scala:773)
[error]         at sbt.io.IO$.$anonfun$withZipOutput$1$adapted(IO.scala:753)
[error]         at sbt.io.Using.apply(Using.scala:28)
[error]         at sbt.io.IO$.withZipOutput(IO.scala:753)
[error]         at sbt.io.IO$.archive(IO.scala:673)
[error]         at sbt.io.IO$.jar(IO.scala:621)
[error]         at com.typesafe.sbt.osgi.Osgi$.$anonfun$bundleTask$1(Osgi.scala:187)
[error]         at scala.Option.getOrElse(Option.scala:189)
[error]         at com.typesafe.sbt.osgi.Osgi$.withCache(Osgi.scala:112)
[error]         at com.typesafe.sbt.osgi.Osgi$.bundleTask(Osgi.scala:139)
[error]         at com.typesafe.sbt.osgi.SbtOsgi$.$anonfun$defaultOsgiSettings$1(SbtOsgi.scala:57)
[error]         at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error]         at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:63)
[error]         at sbt.std.Transform$$anon$4.work(Transform.scala:69)
[error]         at sbt.Execute.$anonfun$submit$2(Execute.scala:283)
[error]         at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:24)
[error]         at sbt.Execute.work(Execute.scala:292)
[error]         at sbt.Execute.$anonfun$submit$1(Execute.scala:283)
[error]         at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error]         at sbt.CompletionService$$anon$2.call(CompletionService.scala:65)
[error]         at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error]         at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[error]         at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error]         at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[error]         at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[error]         at java.base/java.lang.Thread.run(Thread.java:829)
[error] (actor / osgiBundle) java.util.zip.ZipException: duplicate entry: META-INF/MANIFEST.MF
mdedetrich commented 7 months ago

I think this is windows related? Unfortunately I don't have a Windows machine on me but willing to accept any PR that solves the issue.

Also we do run against Windows in our CI so its interesting we are not getting problems there.

Roiocam commented 7 months ago

Also we do run against Windows in our CI so its interesting we are not getting problems there.

Maybe the CI doesn't run any benchmarks?

mdedetrich commented 7 months ago

Maybe the CI doesn't run any benchmarks?

Well benchmarks aren't really relevant here. There may be an interesting interaction between sbt-jmh and sbt-osgi in which case the best way to replicated this would be write a scripted test that adds sbt-jmh as a plugin to try and reproduce it.

The best way to diagnose this would be to minimize the issue as a sbt-scripted test within this project.

An interesting thing to note specifically wrt Pekko, sbt-osgi has been updated some weeks ago where sbt-jmh was updated recently so maybe thats the root cause? Would be good to bisect which at which exact Pekko commit the issues are being caused.

He-Pin commented 7 months ago

seems it's ok on mac, but fails on Windows 11.

mdedetrich commented 7 months ago

seems it's ok on mac, but fails on Windows 11.

Also fine on Linux otherwise CI would be breaking. Try the find the commit which causes the breakage.

mdedetrich commented 7 months ago

See https://github.com/apache/incubator-pekko/issues/986#issuecomment-1903253424 for likely cause

mdedetrich commented 7 months ago

@He-Pin Also what JDK are you using, is it 8, 11, 17 or 21?

He-Pin commented 7 months ago

@mdedetrich tested both java 8 and java 11, both fails.

mdedetrich commented 7 months ago

@mdedetrich tested both java 8 and java 11, both fails.

Thanks, created a PR at https://github.com/sbt/sbt-osgi/pull/115 to create a basic test with packageWithJVMJar := true to see if I can replicate it on Windows CI.

mdedetrich commented 7 months ago

@He-Pin So good news, I managed to replicate this with a trivial test in the Windows CI