JavaPackager icon indicating copy to clipboard operation
JavaPackager copied to clipboard

[mac] bundled universalJavaApplicationStub is not correct EOL

Open umjammer opened this issue 2 years ago • 5 comments

I'm submitting a…

  • [x] bug report
  • [ ] feature request
  • [ ] other

Short description of the issue/suggestion:

an app created by javapackager plugin doesn't work.

Steps to reproduce the issue/enhancement:

  1. create pom.xml
  2. mvn package -Dmaven.test.skip=true
  3. click the application created

What is the expected behavior?

the application works.

What is the current behavior?

mac said "cannot open the application"

Do you have outputs, screenshots, demos or samples which demonstrate the problem or enhancement?

$ target/Notificator/Notificator.app/Contents/MacOS/universalJavaApplicationStub
zsh: target/Notificator/Notificator.app/Contents/MacOS/universalJavaApplicationStub: bad interpreter: /bin/bash^M: no such file or directory
$ dos2unix target/Notificator/Notificator.app/Contents/MacOS/universalJavaApplicationStub
dos2unix: converting file target/Notificator/Notificator.app/Contents/MacOS/universalJavaApplicationStub to Unix format...
$ target/Notificator/Notificator.app/Contents/MacOS/universalJavaApplicationStub                                                                                                                                     1.2.1
Hello World!

after dos2unix, the application works. provided universalJavaApplicationStub's EOL is wrong.

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

  • JavaPackager version: 1.6.7
  • OS version: macos 11.6.6
  • JDK version: 1.8.0_291
  • Build tool:
    • [x] Maven
    • [ ] Gradle

Other information (e.g. related issues, suggestions how to fix, links for us to have context)

umjammer avatar Jul 24 '22 19:07 umjammer

Hi @umjammer!

I'm sorry ... I fear I reintroduced an old issue 😞

On the one hand, there's a new feature in version 1.6.7 that allows you to select the binary/script used to start the application (macConfig.macStartup=SCRIPT|UNIVERSAL|X86_64|ARM64). On the other hand, there's a problem when releasing the plugin to Maven Central from Windows, whereby line breaks in resource files are replaced by \r\n.

What does one thing has to do with the other?

When adding the new feature, I forgot to have in mind replacing line breaks when choosing SCRIPT option, as in 1.6.6:

https://github.com/fvarrui/JavaPackager/blob/dd2fa512609aaa7020357afa4d6cab9000ab4677/src/main/java/io/github/fvarrui/javapackager/packagers/MacPackager.java#L113-L123

Last param is unixStyleNewLines=true:

FileUtils.copyResourceToFile("/mac/universalJavaApplicationStub", appStubFile, true); 

This replaces \r\n with \n.

And right now, in 1.6.7, this is done so:

https://github.com/fvarrui/JavaPackager/blob/edd95e565f5cbf0ead7a91c8d59593d02a02e499/src/main/java/io/github/fvarrui/javapackager/packagers/MacPackager.java#L112-L122

Notice the missing third parameter when copying the resource.

Yes!!! I know, I should add unit tests to the plugin, but I haven't had time 😢

fvarrui avatar Jul 26 '22 10:07 fvarrui

A possible work around could be to use macConfig.macStartup=UNIVERSAL|X86_64|ARM64 instead of SCRIPT. Please, try this and give us some feedback. Thanks!!!

fvarrui avatar Jul 26 '22 10:07 fvarrui

macConfig.macStartup=X86_64

works fine!

but i intend to wait patiently this issue will be resolved 👍

umjammer avatar Jul 26 '22 12:07 umjammer

Fixed in devel branch (JavaPackager 1.7.0-SNAPSHOT).

fvarrui avatar Jul 30 '22 12:07 fvarrui

1.7.0-SNAPSHOT

works well!

thanks 😄

umjammer avatar Jul 31 '22 07:07 umjammer

Thank you, I also got this problem. However when running with 1.7.0-SNAPSHOT on {macOS11.4, Apple M1, Azul JDK 11}, running mvn clean package throws

[ERROR] Failed to execute goal io.github.fvarrui:javapackager:1.7.0-SNAPSHOT:package (default) on project quantum: Could not remove folder 
/Users/martin/Dev/jzy3d/external/quantum/target/Quantum/Quantum.app/Contents/PlugIns/jre/Contents/Home/legal: Unable to delete directory 
/Users/martin/Dev/jzy3d/external/quantum/target/Quantum/Quantum.app/Contents/PlugIns/jre/Contents/Home/legal.

Thanks in advance!

jzy3d avatar Dec 05 '22 13:12 jzy3d

Hi @jzy3d! There seems to be a bug with commons-io:commons-io:2.7, which has been fixed in 2.11.0. I've just upgraded this dependency in branch issue-239. Please, could you try the fix and give some feedback? Thanks!

fvarrui avatar Dec 05 '22 14:12 fvarrui

Thank you a lot for your prompt reply @fvarrui. I confirm that using branch issue-239 resolve the above failure. And now I get the EOL problem solved! Congratulation and thank you so much for your work.

jzy3d avatar Dec 05 '22 14:12 jzy3d

Great!!! Branch issue-239 merged into devel, ready to be released in v1.7.0. Thanks!!

fvarrui avatar Dec 05 '22 14:12 fvarrui

JavaPackager 1.7.0 released to Maven Central

fvarrui avatar Feb 08 '23 02:02 fvarrui