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

Fix packageWithJVMJar := true not working on Windows #115

Merged
merged 1 commit into from
Jan 22, 2024

Conversation

mdedetrich
Copy link
Collaborator

@mdedetrich mdedetrich commented Jan 22, 2024

Resolves: #113

@mdedetrich
Copy link
Collaborator Author

Found the most likely root cause, https://github.com/sbt/sbt-osgi/pull/81/files#diff-2530a9c505dd4cb34217eb195d5db3cab065049f033db306f485078da72edd5dR89-R90 would not work on Windows, trying a fix now.

@mdedetrich mdedetrich force-pushed the add-test-for-packageWithJvmJar branch from 51b4952 to ab55102 Compare January 22, 2024 07:51
@mdedetrich mdedetrich changed the title Add test for packageWithJVMJar Fix packageWithJVMJar := true not working on Windows Jan 22, 2024
@mdedetrich mdedetrich force-pushed the add-test-for-packageWithJvmJar branch 2 times, most recently from 8a78930 to d1d7403 Compare January 22, 2024 07:55
@mdedetrich
Copy link
Collaborator Author

mdedetrich commented Jan 22, 2024

Ended up being a simple fix, we used a hardcoded "META-INF/MANIFEST.MF" as a string which obviously fails on Windows, the solution was to use the proper file/path API which takes into account the different separators for Windows.

@eed3si9n @romainreuillon Do you mind taking a quick look at this? Its a fairly simple fix and its currently breaking Windows users.

@@ -181,7 +181,9 @@ private object Osgi {
import _root_.java.nio.file._
import _root_.scala.collection.JavaConverters._
val path = tmpArtifactDirectoryPath.toPath
Files.walk(path).iterator.asScala.map(f => f.toFile -> path.relativize(f).toString).filterNot { case (_, p) => p == "META-INF/MANIFEST.MF" }.toTraversable
Files.walk(path).iterator.asScala.map(f => f.toFile -> path.relativize(f))
.collect { case (f, p) if p != (file("META-INF") / "MANIFEST.MF").toPath => (f, p.toString) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the fix is using the / operator?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kind of problem I was fixed in pekko/akka spec too:)

Copy link
Collaborator Author

@mdedetrich mdedetrich Jan 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the fix is using the / operator?

Yes its part of the sbt API which is just a wrapper over new java.io.File(a, b)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I understand the reason, Because line.separator in Windows cannot be represented with /.

Copy link
Contributor

@He-Pin He-Pin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@He-Pin
Copy link
Contributor

He-Pin commented Jan 22, 2024

image
It's tested with Windows.

@romainreuillon
Copy link
Contributor

@mdedetrich Sorry I am under a lot of load at work right now, but the fix seems okay to me. If I remember correctly, we filter of that file to avoid a duplicate entry error with the manifest provided as parameter of to IO.jar

@He-Pin
Copy link
Contributor

He-Pin commented Jan 22, 2024

@romainreuillon Take care, me too, heavy work..., I can take a try locally when I find time, still testing the Virtual thread reafactory at work:(

@mdedetrich
Copy link
Collaborator Author

@mdedetrich Sorry I am under a lot of load at work right now, but the fix seems okay to me. If I remember correctly, we filter of that file to avoid a duplicate entry error with the manifest provided as parameter of to IO.jar

Thanks, even though you didn't make an actual approval via Github UI I will accept this as a yes and use admin rights to merge given its currently its broken for Windows users.

@mdedetrich mdedetrich merged commit b4dd37f into sbt:main Jan 22, 2024
10 checks passed
@mdedetrich mdedetrich deleted the add-test-for-packageWithJvmJar branch January 22, 2024 21:04
Copy link

@Roiocam Roiocam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -181,7 +181,9 @@ private object Osgi {
import _root_.java.nio.file._
import _root_.scala.collection.JavaConverters._
val path = tmpArtifactDirectoryPath.toPath
Files.walk(path).iterator.asScala.map(f => f.toFile -> path.relativize(f).toString).filterNot { case (_, p) => p == "META-INF/MANIFEST.MF" }.toTraversable
Files.walk(path).iterator.asScala.map(f => f.toFile -> path.relativize(f))
.collect { case (f, p) if p != (file("META-INF") / "MANIFEST.MF").toPath => (f, p.toString) }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I understand the reason, Because line.separator in Windows cannot be represented with /.

@mdedetrich
Copy link
Collaborator Author

@Roiocam This has already been merged, apache/pekko#1024 still needs to be reviewed to fix the issue in Pekko

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

Successfully merging this pull request may close these issues.

Duplicated META-INF/MANIFEST.MF entries when using packageWithJVMJar := true on Windows
4 participants