Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
794 views
in Technique[技术] by (71.8m points)

gradle - Kotlin script failing to build

I am trying to get Kotlin scripting to work but both Gradle and IntelliJ IDEA are failing to build the project as they are unable to find the methods that are defined in the base script definition.

For a sample project, see https://github.com/sinoz/sample-kts. It includes a simple script that adds two values using an add method defined in the base script definition and a script template file that references said script definition.

Running gradle build:

~/Documents/Hobby/untitled1$ gradle build
> Task :compileKotlin FAILED
e: /home/sino/Documents/Hobby/untitled1/src/main/kotlin/me/sino/add.kts: (3, 1): Unresolved reference: add

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileKotlin'.
> Compilation error. See log for more details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
1 actionable task: 1 executed

I am using IntelliJ IDEA 2020.2, Gradle 6.8, Kotlin 1.4.10 and OpenJDK 11. Kotlin scripting used to work before until I reinstalled Linux-and Windows (So I assume there was some caching involved that allowed Kotlin scripting to continue to function).

IDEA is also not giving me the option to apply a new script context as it used to do. I am not sure how to do this manually as I am unable to find any documentation on it whatsoever.

question from:https://stackoverflow.com/questions/65901900/kotlin-script-failing-to-build

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...