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

Duplicated startup script names in universal zip #1016

Closed
atrosinenko opened this issue Aug 23, 2017 · 2 comments
Closed

Duplicated startup script names in universal zip #1016

atrosinenko opened this issue Aug 23, 2017 · 2 comments
Labels
bug universal Zip, tar.gz, tgz and bash issues

Comments

@atrosinenko
Copy link
Contributor

When the project contains several main classes with the same name in different packages, universal zip contains multiple startup scripts with the same name inside the bin/ directory.

How to reproduce

  1. Unzip the attached example: native-packager-bug.zip
  2. Run sbt 'universal:packageBin'

Expected behaviour

Create differently named startup scripts (for example, prepend their name with package name when clashes occur).

Actual behaviour

The created file contains duplicated file names:

$ unzip -l target/universal/test-1.0.zip 
Archive:  target/universal/test-1.0.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
     5403  2017-08-23 15:00   test-1.0/lib/test.test-1.0.jar
  5246851  2017-07-25 13:47   test-1.0/lib/org.scala-lang.scala-library-2.12.3.jar
     9159  2017-08-23 15:00   test-1.0/bin/test
     9159  2017-08-23 15:00   test-1.0/bin/test
     4064  2017-08-23 15:00   test-1.0/bin/test.bat
     4064  2017-08-23 15:00   test-1.0/bin/test.bat
---------                     -------
  5278700                     6 files
$ unzip target/universal/test-1.0.zip 
Archive:  target/universal/test-1.0.zip
  inflating: test-1.0/lib/test.test-1.0.jar  
  inflating: test-1.0/lib/org.scala-lang.scala-library-2.12.3.jar  
  inflating: test-1.0/bin/test       
replace test-1.0/bin/test? [y]es, [n]o, [A]ll, [N]one, [r]ename: 

Information

Version information:
sbt: 1.0.0
sbt-native-packager: 1.2.2
build system: Ubuntu 16.04.3 LTS

@muuki88 muuki88 added bug universal Zip, tar.gz, tgz and bash issues labels Aug 23, 2017
@muuki88
Copy link
Contributor

muuki88 commented Aug 23, 2017

Thanks a lot for your detailed bug report.

Do you have the time to open a pull request for this? This is the code line responsible for this behavior. I'll guide and help you if you feel unsure if you are up to the task ( which I'm sure you are 😎 )

@atrosinenko
Copy link
Contributor Author

I hope I can look at it on the weekend. Meanwhile, why upper case names mangled like UIExample -> u-i-example? What if generate names with the original capitalization and resort to this scheme only when name clashes occur (on case-insensitive filesystems) -- wouldn't it look more readable?

@atrosinenko atrosinenko changed the title Duplicated file names in universal zip Duplicated startup script names in universal zip Sep 11, 2017
muuki88 pushed a commit that referenced this issue Jan 8, 2018
* Change startup script name generation

This commit tries to lower the chance of generation of multiple scripts
with equal names in one archive. Fixes #1016.

Additionally, an attempt was made to improve the word splitting
for the script names, so, for example "UITest" becomes "ui-test"
and not "u-i-test".

* Heuristics for disambiguating names: second try

* Implement simpler disambiguating heuristics

* Fix indentation

* Fix for the case of single main class

* Drop some beautifying logic

* Fix formatting

* Add note to the documentation on script name generation

* Refactor Universal JavaAppPackaging

Factor out common code from `BashStartScriptPlugin` and `BatStartScriptPlugin`

* Show warning when script name collision is detected

* Fix docs formatting

* Fix comments and simplify executable bit logic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug universal Zip, tar.gz, tgz and bash issues
Projects
None yet
Development

No branches or pull requests

2 participants