Skip to content

issues with @file:CompilerOpts and order of annotations #173

@NikkyAI

Description

@NikkyAI

it seems like using the CompilerOpts annotation is finicky
it seems to only work when the other annotations are in a certain order and when there is no import statements, needless to say that import statements are kind important

the //COMPILER_OPTS option is unusable for me because of #153

here is a simplified example

error:

[kscript] [ERROR] compilation of 'samples/test.kt' failed
/tmp/tmp3954722483065654192.tmp/scriptlet.7611720b7401b424.kt:6:1: error: this annotation is not applicable to target 'object' and use site target '@file'
@file:CompilerOpts("-jvm-target 1.8")
^
/tmp/tmp3954722483065654192.tmp/scriptlet.7611720b7401b424.kt:6:2: error: '@file:' annotations can only be applied before package declaration
@file:CompilerOpts("-jvm-target 1.8")
 ^

source:

#!/usr/bin/env kscript
@file:CompilerOpts("-jvm-target 1.8")
@file:Include("Dep.kt")
@file:DependsOnMaven("ch.qos.logback:logback-classic:1.2.3")
@file:MavenRepository("kotlinx", "https://kotlin.bintray.com/kotlinx")

import java.io.File

fun main(args: Array<String>) {
    println("hello")
    println(File("test").path)
}

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