当我运行gradle kotlin应用程序时,我得到一个编译错误`只允许kotlin标准库使用'kotlin'包''

46scxncf  于 2021-08-25  发布在  Java
关注(0)|答案(1)|浏览(379)

我正在尝试从gradle创建一个测试kotlin应用程序。
当我跑的时候 ./gradlew run 我得到以下错误:

> Task :list:compileKotlin FAILED
e: /Users/jboemo/WorkspaceNexmo/kotlin-gradle-cli-test/list/src/main/kotlin/kotlin/gradle/cli/test/list/LinkedList.kt: (4, 1): Only the Kotlin standard library is allowed to use the 'kotlin' package

FAILURE: Build failed with an exception.

以下是我创建应用程序的步骤:

Select type of project to generate:
  1: basic
  2: application
  3: library
  4: Gradle plugin
Enter selection (default: basic) [1..4] 2

Select implementation language:
  1: C++
  2: Groovy
  3: Java
  4: Kotlin
  5: Scala
  6: Swift
Enter selection (default: Java) [1..6] 4

Split functionality across multiple subprojects?:
  1: no - only one application project
  2: yes - application and library projects
Enter selection (default: no - only one application project) [1..2] 2

Select build script DSL:
  1: Groovy
  2: Kotlin
Enter selection (default: Kotlin) [1..2] 2

Project name (default: kotlin-gradle-cli-test):
Source package (default: kotlin.gradle.cli.test):

> Task :init
Get more help with your project: https://docs.gradle.org/6.9/samples/sample_building_kotlin_applications_multi_project.html

BUILD SUCCESSFUL in 16s
2 actionable tasks: 2 executed
jboemo@VONMAC-C02F51B7MD6P kotlin-gradle-cli-test % ./gradlew run

这些是我的gradle和java版本:

jboemo@VONMAC-C02F51B7MD6P kotlin-gradle-cli-test % gradle -v

------------------------------------------------------------
Gradle 6.9
------------------------------------------------------------

Build time:   2021-05-07 07:28:53 UTC
Revision:     afe2e24ababc7b0213ccffff44970aa18035fc0e

Kotlin:       1.4.20
Groovy:       2.5.12
Ant:          Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM:          11.0.10 (Oracle Corporation 11.0.10+9)
OS:           Mac OS X 11.3.1 x86_64

jboemo@VONMAC-C02F51B7MD6P kotlin-gradle-cli-test % java -version
openjdk version "1.8.0_292"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_292-b10)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.292-b10, mixed mode)

我看到已经有这个问题错误:“只有kotlin标准库才允许使用'kotlin'包”,但我想知道gradle创建的kotlin应用程序怎么可能会出现这个错误(我没有修改任何代码)

fdbelqdn

fdbelqdn1#

多亏了这些评论,我现在只需要在向导中传递一个不同的源程序包。
我所做的是创建一个名为 kotlingradle-cli-test 并使用与以前完全相同的选项在其中运行gradle

相关问题