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

Don't work @file:Import("absolute/path/to/myutils.kt") #393

Open
lsmobile opened this issue Feb 6, 2023 · 2 comments
Open

Don't work @file:Import("absolute/path/to/myutils.kt") #393

lsmobile opened this issue Feb 6, 2023 · 2 comments

Comments

@lsmobile
Copy link

lsmobile commented Feb 6, 2023

An attempt to include my utils per
@file:Import("absolute/path/to/myutils.kt")
doesn't work.
More precisely: Unresolved reference: myFunction

@aartiPl
Copy link
Collaborator

aartiPl commented Feb 7, 2023

Please provide additional information:

  • kscript version,
  • OS
  • exact, relevant test case

I have tested it with kscript 4.2.1, and both (absolute and relative) imports work.

@lsmobile
Copy link
Author

lsmobile commented Feb 7, 2023

It works in terminal, but it doesn't work in IDEA.

  • kscript version: 4.2.1
  • OS: Linux Mint 20.2, core 5.15
  • exact, relevant test case:

myutils.kt:

fun myprint(text: String) { println(text) }

myscript.kts:

#!/usr/bin/env kscript
@file:Import("/absolute/path/to/myutils.kt")
myprint("test")

build.gradle.kts:

plugins {
    id("org.jetbrains.kotlin.jvm") version "1.7.21"
}
repositories {
    mavenLocal()
    mavenCentral() 
}
dependencies {
    implementation("org.jetbrains.kotlin:kotlin-stdlib")
    implementation("org.jetbrains.kotlin:kotlin-script-runtime:1.7.21")
    implementation("io.github.kscripting:kscript-annotations:1.5.0")
}
sourceSets.getByName("main").java.srcDirs("src")
sourceSets.getByName("test").java.srcDirs("src")

Response:
e: /home/user/.cache/kscript/idea_4fc...aa4/src/myscript.kts: (5, 1): Unresolved reference: myprint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants