jbang icon indicating copy to clipboard operation
jbang copied to clipboard

Binary distributions do not include version.txt

Open aalmiray opened this issue 4 years ago • 5 comments

Apparently the build is set to copy tmp/version.txt into the generated distribution

https://github.com/jbangdev/jbang/blob/3adf1b50133ccd652048aeed2b6173e93940a77c/build.gradle#L116-L130

However this file is not created at the appropriate time and it's missing from the final distribution archives

$ tar tvf ~/Downloads/jbang-0.81.2.tar 
drwxr-xr-x  0 0      0           0 Jan  2  1970 jbang-0.81.2/
drwxr-xr-x  0 0      0           0 Jan  2  1970 jbang-0.81.2/bin/
-rw-r--r--  0 0      0     6216055 Jan  2  1970 jbang-0.81.2/bin/jbang.jar
-rwxr-xr-x  0 0      0        6324 Jan  2  1970 jbang-0.81.2/bin/jbang
-rw-r--r--  0 0      0        5385 Jan  2  1970 jbang-0.81.2/bin/jbang.cmd
-rw-r--r--  0 0      0        7173 Jan  2  1970 jbang-0.81.2/bin/jbang.ps1
drwxr-xr-x  0 0      0           0 Jan  2  1970 jbang-0.81.2/tmp/
$ unzip -l ~/Downloads/jbang-0.81.2.zip 
Archive:  /Users/aalmiray/Downloads/jbang-0.81.2.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  02-01-1980 00:00   jbang-0.81.2/
        0  02-01-1980 00:00   jbang-0.81.2/bin/
  6216055  02-01-1980 00:00   jbang-0.81.2/bin/jbang.jar
     6324  02-01-1980 00:00   jbang-0.81.2/bin/jbang
     5385  02-01-1980 00:00   jbang-0.81.2/bin/jbang.cmd
     7173  02-01-1980 00:00   jbang-0.81.2/bin/jbang.ps1
        0  02-01-1980 00:00   jbang-0.81.2/tmp/
---------                     -------
  6234937                     7 files

If this file is to be included then the versionTxt() task must be set as a dependency or distZip, distTar, latestDistZip, and latestDistTar.

aalmiray avatar Oct 24 '21 11:10 aalmiray

thanks for the bug @aalmiray - whats worse is that if doing a clean build even jbang.cmd/jbang/jbang.ps1 are missing which got into 0.82 release ...sometihng definitely wonky here.

would it not be enough to make versiontxt dependent on assemble ?

maxandersen avatar Oct 31 '21 08:10 maxandersen

No, I don't think it would be enough as assemble depends on the distribution tasks already. Gradle usually runs tasks in alphabetical order when there are no dependencies between them thus versionText might run after the distribution tasks that require its outputs.

You can either add a task dependency (explicit, old idiom) or add an input file dependency (new idiom).

aalmiray avatar Oct 31 '21 09:10 aalmiray

"add an input file dependency (new idiom)." ... how would that work?

maxandersen avatar Oct 31 '21 09:10 maxandersen

It would look something like this https://docs.gradle.org/current/userguide/more_about_tasks.html#sec:runtime_api_for_adhoc

aalmiray avatar Oct 31 '21 10:10 aalmiray

FWIW explicit task dependency (old idiom) is the easiest way to make it work. Will only become a problem in Gradle 8.0 when this option is flagged as an error or gets removed.

aalmiray avatar Oct 31 '21 11:10 aalmiray