GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Match annotations behavior of kotlinc · Issue #388 · kscripting/kscript

Match annotations behavior of kotlinc #388

New issue
Copy link
New issue
Copy link
Open
Open
Match annotations behavior of kotlinc#388
Copy link

Description

@gabrielfeo
gabrielfeo
opened on Jan 11, 2023
Issue body actions

It'd be great if kscript could match behavior to be 100% compatible with the 'Kotlin scripting support' annotations. Even if one writes a script aiming for the standard compiler command, I could run it with kscript and benefit from caching and its other features.

vararg support

Adding multiple repositories with a single annotation (source):

@file:Repository("https://jitpack.io", "https://repo.maven.apache.org/maven2")
@file:DependsOn("com.github.gabrielfeo:gradle-enterprise-api-kotlin:0.11.0", "org.jetbrains.kotlinx:dataframe:0.9.1")

but kscript doesn't support vararg in Repository, parsing the second arg as a repository username:

[kscript] Adding repository: Repository(id=, url=https://jitpack.io, user=https://repo.maven.apache.org/maven2, password=)

Line break support

Breaking line inside annotations is supported by kotlinc, but isn't supported by kscript:

Line break in DependsOn

@file:Repository("https://repo.maven.apache.org/maven2")
@file:DependsOn(
    "com.squareup.okio:okio:3.3.0",
    "org.jetbrains.kotlinx:dataframe:0.9.1",
)
[kscript] Adding repository: Repository(id=, url=https://repo.maven.apache.org/maven2, user=, password=)
[kscript] [ERROR] Compilation of scriplet failed:
[kscript] [ERROR] Command     : 'bash -c /opt/homebrew/Cellar/kotlin/1.8.0/libexec/bin/kotlinc   -d '/Users/gabriel.feo/.cache/kscript/jar_6d5e6178bda10b7c462025e5f8fe444a/scriplet.jar' '/Users/gabriel.feo/.cache/kscript/jar_6d5e6178bda10b7c462025e5f8fe444a/Dataframe_test_main.kts' '/Users/gabriel.feo/.cache/kscript/jar_6d5e6178bda10b7c462025e5f8fe444a/Main_Dataframe_test_main.kt''
[kscript] [ERROR] Exit Code   : 1   
[kscript] [ERROR] Stdout      : ''
[kscript] [ERROR] Stderr      : '/Users/gabriel.feo/.cache/kscript/jar_6d5e6178bda10b7c462025e5f8fe444a/Dataframe_test_main.kts:6:2: error: expecting an expression[nl])[nl] ^[nl]/Users/gabriel.feo/.cache/kscript/jar_6d5e6178bda10b7c462025e5f8fe444a/Dataframe_test_main.kts:3:7: error: unresolved reference: DependsOn[nl]@file:DependsOn([nl]      ^[nl]'
[kscript] [ERROR]

Line break in Repository

@file:Repository(
    "https://jitpack.io",
    "https://repo.maven.apache.org/maven2",
)
@file:DependsOn("com.squareup.okio:okio:3.3.0", "org.jetbrains.kotlinx:dataframe:0.9.1")
[kscript] Adding repository: Repository(id=, url=, user=, password=)

Note: using multiple Repository and DependsOn annotations has the same behavior in both kotlinc and kscript, a good workaround to make scripts compatible with both

@file:Repository("https://jitpack.io")
@file:Repository("https://repo.maven.apache.org/maven2")
@file:DependsOn("com.github.gabrielfeo:gradle-enterprise-api-kotlin:0.11.0")
@file:DependsOn("org.jetbrains.kotlinx:dataframe:0.9.1")

Activity

  1. gabrielfeo
    changed the title [-]Match kotlinc behavior for Repository annotation[/-] [+]Match annotations behavior of kotlinc[/+] on Jan 11, 2023
  2. aartiPl commented on Jan 11, 2023

    @aartiPl
    aartiPl
    on Jan 11, 2023
    Collaborator
    More actions

    Yes, your comment is entirely valid. My ultimate goal is to switch to Kotlin scripting backend while keeping all the excellent features of KScript (like interoperability with shell, caching, etc.). The only question is how much effort to put in to stay perfectly compatible, while in the long run, I will switch to Kotlin scripting anyway. Currently, in my opinion, it is not worthy of effort, as I would like to switch to the Kotlin scripting backend after version 4.2, which I am about to release. But still, if anyone wants to improve KScript with such features, I am happy to apply patches.

    Reacted by Gabriel Féo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.