kscripting / kscript

Scripting enhancements for Kotlin
MIT License
2.07k stars 124 forks source link

kscript downloading Kotlin Native jars during dependency resolution - why? #417

Closed vsajip closed 7 months ago

vsajip commented 7 months ago

I'm using this Kotlin script to demonstrate:

@file:DependsOn("com.github.ajalt.clikt:clikt:4.2.2")

println("Hello, world!")

I set up this shell script to show the problem:

echo Removing relevant files from local Maven repository ...
rm -rf ~/.m2/repository/com/github/ajalt/clikt/clikt/4.2.2
echo Running script, which will populate relevant files in local Maven repsoitory ...
kscript mctest.kts
echo Listing the newly created files ...
ls -l ~/.m2/repository/com/github/ajalt/clikt/clikt/4.2.2
echo Computing the SHA1 digest of the pom file ...
sha1sum ~/.m2/repository/com/github/ajalt/clikt/clikt/4.2.2/clikt-4.2.2.pom | cut -d" " -f1
echo and it should be ...
cat ~/.m2/repository/com/github/ajalt/clikt/clikt/4.2.2/clikt-4.2.2.pom.sha1
echo
echo Computing the SHA1 digest of the jar file ...
sha1sum ~/.m2/repository/com/github/ajalt/clikt/clikt/4.2.2/clikt-4.2.2.jar | cut -d" " -f1
echo and it should be ...
cat ~/.m2/repository/com/github/ajalt/clikt/clikt/4.2.2/clikt-4.2.2.jar.sha1
echo
echo Listing contents of jar ...
unzip -l ~/.m2/repository/com/github/ajalt/clikt/clikt/4.2.2/clikt-4.2.2.jar

When run, this script downloads a suspiciously small-looking jar, and the SHA1 digests look OK, but the jar seems to contain Kotlin native modules:

$ sh mctest.sh 
Removing relevant files from local Maven repository ...
Running script, which will populate relevant files in local Maven repsoitory ...
[kscript] Resolving com.github.ajalt.clikt:clikt:4.2.2...
Hello, world!
Listing the newly created files ...
total 64
-rw-rw-r-- 1 vinay vinay 48093 Jan 25 18:55 clikt-4.2.2.jar
-rw-rw-r-- 1 vinay vinay    40 Jan 25 18:55 clikt-4.2.2.jar.sha1
-rw-rw-r-- 1 vinay vinay  1920 Jan 25 18:55 clikt-4.2.2.pom
-rw-rw-r-- 1 vinay vinay    40 Jan 25 18:55 clikt-4.2.2.pom.sha1
-rw-rw-r-- 1 vinay vinay   248 Jan 25 18:55 _remote.repositories
Computing the SHA1 digest of the pom file ...
b10231f98a134997df488c24173cc17d65cf1fbe
and it should be ...
b10231f98a134997df488c24173cc17d65cf1fbe
Computing the SHA1 digest of the jar file ...
9fa1ca9cd993e1a908288be631d49af435e6c638
and it should be ...
9fa1ca9cd993e1a908288be631d49af435e6c638
Listing contents of jar ...
Archive:  /home/vinay/.m2/repository/com/github/ajalt/clikt/clikt/4.2.2/clikt-4.2.2.jar
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  1980-02-01 00:00   META-INF/
       25  1980-02-01 00:00   META-INF/MANIFEST.MF
     2525  1980-02-01 00:00   META-INF/kotlin-project-structure-metadata.json
        0  1980-02-01 00:00   commonMain/
        0  1980-02-01 00:00   commonMain/default/
      120  1980-02-01 00:00   commonMain/default/manifest
        0  1980-02-01 00:00   commonMain/default/linkdata/
      724  1980-02-01 00:00   commonMain/default/linkdata/module
        0  1980-02-01 00:00   commonMain/default/linkdata/package_com/
       15  1980-02-01 00:00   commonMain/default/linkdata/package_com/0_com.knm
        0  1980-02-01 00:00   commonMain/default/linkdata/package_com.github/
       22  1980-02-01 00:00   commonMain/default/linkdata/package_com.github/0_github.knm
        0  1980-02-01 00:00   commonMain/default/linkdata/package_com.github.ajalt/
       28  1980-02-01 00:00   commonMain/default/linkdata/package_com.github.ajalt/0_ajalt.knm
[lines elided]
       12  1980-02-01 00:00   commonMain/default/linkdata/root_package/0_.knm
        0  1980-02-01 00:00   nativeMain/
        0  1980-02-01 00:00   nativeMain/default/
        0  1980-02-01 00:00   nativeMain/default/linkdata/
      207  1980-02-01 00:00   nativeMain/default/linkdata/module
        0  1980-02-01 00:00   nativeMain/default/linkdata/package_com.github.ajalt.clikt.mpp/
      357  1980-02-01 00:00   nativeMain/default/linkdata/package_com.github.ajalt.clikt.mpp/0_mpp.knm
[lines elided]
      196  1980-02-01 00:00   nativeMain/default/manifest
        0  1980-02-01 00:00   commonMain/default/resources/
        0  1980-02-01 00:00   nativeMain/default/resources/
        0  1980-02-01 00:00   nativeMain/default/targets/
        0  1980-02-01 00:00   nativeMain/default/targets/linux_x64/
        0  1980-02-01 00:00   nativeMain/default/targets/linux_x64/included/
        0  1980-02-01 00:00   nativeMain/default/targets/linux_x64/kotlin/
        0  1980-02-01 00:00   nativeMain/default/targets/linux_x64/native/
---------                     -------
    63812                     85 files

It's just started doing this. For comparison, here's an older version of the jar - 3.4.2 - which was also done via dependency resolution, but not recently:

$ unzip -l ~/.m2/repository/com/github/ajalt/clikt/clikt/3.4.2/clikt-3.4.2.jar 
Archive:  /home/vinay/.m2/repository/com/github/ajalt/clikt/clikt/3.4.2/clikt-3.4.2.jar
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2022-06-09 19:53   META-INF/
       72  2022-06-09 19:53   META-INF/MANIFEST.MF
        0  2022-06-09 19:53   com/
        0  2022-06-09 19:53   com/github/
        0  2022-06-09 19:53   com/github/ajalt/
        0  2022-06-09 19:53   com/github/ajalt/clikt/
        0  2022-06-09 19:53   com/github/ajalt/clikt/core/
     2116  2022-06-09 19:53   com/github/ajalt/clikt/core/ContextKt$DEFAULT_CORRECTION_SUGGESTOR$1$invoke$$inlined$sortedByDescending$1.class
     3137  2022-06-09 19:53   com/github/ajalt/clikt/core/ContextKt$requireObject$1.class
     4924  2022-06-09 19:53   com/github/ajalt/clikt/core/BadParameterValue.class
     2204  2022-06-09 19:53   com/github/ajalt/clikt/core/ContextKt$findObject$1$getValue$$inlined$findObject$1.class
      963  2022-06-09 19:53   com/github/ajalt/clikt/core/Abort.class
[lines elided]      
     1891  2022-06-09 19:53   com/github/ajalt/clikt/parameters/types/FileKt$file$2.class
     1934  2022-06-09 19:53   com/github/ajalt/clikt/parameters/types/ChoiceKt$enum$3.class
     1017  2022-06-09 19:53   META-INF/clikt.kotlin_module
---------                     -------
  1273381                     332 files

Could I have done something unintentionally to cause this behavior to start occurring?

vsajip commented 7 months ago

It looks like the clikt project changed the relevant artifact ID from clikt to clikt-jvm ...