如何添加Gradle Kotlin依赖项编译组:';org.seleniumhq.selenium';?

如何添加Gradle Kotlin依赖项编译组:';org.seleniumhq.selenium';?,selenium,gradle,kotlin,dependencies,gradle-kotlin-dsl,Selenium,Gradle,Kotlin,Dependencies,Gradle Kotlin Dsl,使用Gradle Kotlin DSL作为依赖项的Selenium的语法是什么 错误: thufir@dur:~/NetBeansProjects/HelloKotlinWorld$ thufir@dur:~/NetBeansProjects/HelloKotlinWorld$ gradle clean > Configure project : e: /home/thufir/NetBeansProjects/HelloKotlinWorld/build.gradle.kts:18:

使用
Gradle Kotlin DSL
作为依赖项的
Selenium
的语法是什么

错误:

thufir@dur:~/NetBeansProjects/HelloKotlinWorld$ 
thufir@dur:~/NetBeansProjects/HelloKotlinWorld$ gradle clean

> Configure project :
e: /home/thufir/NetBeansProjects/HelloKotlinWorld/build.gradle.kts:18:18: Expecting an element
e: /home/thufir/NetBeansProjects/HelloKotlinWorld/build.gradle.kts:18:20: Unexpected tokens (use ';' to separate expressions on the same line)
e: /home/thufir/NetBeansProjects/HelloKotlinWorld/build.gradle.kts:18:5: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: 
public val NamedDomainObjectContainer<Configuration>.compile: NamedDomainObjectProvider<Configuration> defined in org.gradle.kotlin.dsl

FAILURE: Build failed with an exception.

* Where:
Build file '/home/thufir/NetBeansProjects/HelloKotlinWorld/build.gradle.kts' line: 18

* What went wrong:
Script compilation errors:

  Line 18:     compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.+'
                            ^ Expecting an element

  Line 18:     compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.+'
                              ^ Unexpected tokens (use ';' to separate expressions on the same line)

  Line 18:     compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.+'
               ^ Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: 
                   public val NamedDomainObjectContainer<Configuration>.compile: NamedDomainObjectProvider<Configuration> defined in org.gradle.kotlin.dsl

3 errors

* 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

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.0/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 2s
thufir@dur:~/NetBeansProjects/HelloKotlinWorld$ 
thufir@dur:~/NetBeansProjects/HelloKotlinWorld$
thufir@dur:~/NetBeansProjects/HelloKotlinWorld$gradle clean
>配置项目:
e:/home/thufir/NetBeansProjects/HelloKotlinWorld/build.gradle.kts:18:18:需要元素
e:/home/thufir/NetBeansProjects/HelloKotlinWorld/build.gradle.kts:18:20:意外标记(使用“;”分隔同一行上的表达式)
e:/home/thufir/NetBeansProjects/HelloKotlinWorld/build.gradle.kts:18:5:未解析引用。由于接收器类型不匹配,以下候选项均不适用:
public val NamedDomainObjectContainer.compile:org.gradle.kotlin.dsl中定义的NamedDomainObjectProvider
失败:生成失败,出现异常。
*其中:
生成文件“/home/thufir/NetBeansProjects/HelloKotlinWorld/Build.gradle.kts”行:18
*出了什么问题:
脚本编译错误:
第18行:编译组:'org.seleniumhq.selenium',名称:'seleniumjava',版本:'3.+'
^需要一个元素
第18行:编译组:'org.seleniumhq.selenium',名称:'seleniumjava',版本:'3.+'
^意外标记(使用“;”分隔同一行上的表达式)
第18行:编译组:'org.seleniumhq.selenium',名称:'seleniumjava',版本:'3.+'
^未解析的引用。由于接收器类型不匹配,以下候选项均不适用:
public val NamedDomainObjectContainer.compile:org.gradle.kotlin.dsl中定义的NamedDomainObjectProvider
3个错误
*尝试:
使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获得更多日志输出。使用--scan运行以获得完整的洞察力。
*得到更多的帮助https://help.gradle.org
此版本中使用了不推荐的Gradle功能,使其与Gradle 6.0不兼容。
使用“--warning mode all”显示单个弃用警告。
看见https://docs.gradle.org/5.0/userguide/command_line_interface.html#sec:command_line_warnings
2秒内生成失败
thufir@dur:~/NetBeansProjects/HelloKotlinWorld$
生成文件:

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

plugins {
    kotlin("jvm") version "1.3.11"
    id("com.github.johnrengelman.shadow") version "2.0.4"
}

group = "xxx.yyy"
version = "1.0-SNAPSHOT"

repositories {
    mavenCentral()
}

dependencies {
    implementation(kotlin("stdlib-jdk8"))
    compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.+'
}

tasks.withType<KotlinCompile> {
    kotlinOptions.jvmTarget = "1.8"
}

tasks.withType<ShadowJar> {

    baseName = "app"
    classifier = "inajar"
    version = "9"


    manifest.attributes.apply {
        put("Implementation-Title", "Gradle Jar File Example")
        //put("Implementation-Version" version)
        put("Main-Class", "HelloKotlinWorld.App")
    }

}
import org.jetbrains.kotlin.gradle.tasks.kotlincomfile
导入com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
插件{
kotlin(“jvm”)版本“1.3.11”
id(“com.github.johnrengelman.shadow”)版本“2.0.4”
}
group=“xxx.yyy”
version=“1.0-SNAPSHOT”
存储库{
mavenCentral()
}
依赖关系{
实施(kotlin(“stdlib-jdk8”))
编译组:'org.seleniumhq.selenium',名称:'seleniumjava',版本:'3.+'
}
tasks.withType{
kotlinOptions.jvmTarget=“1.8”
}
tasks.withType{
baseName=“应用程序”
分类器=“inajar”
version=“9”
manifest.attributes.apply{
put(“实现标题”、“Gradle Jar文件示例”)
//put(“实施版本”版本)
put(“主类”、“HelloKotlinWorld.App”)
}
}
参见本文档: 对于模块依赖项,Groovy DSL和Kotlin DSL的语法不同:

Groovy:

dependencies {
    runtime group: 'org.springframework', name: 'spring-core', version: '2.5'
}
科特林:

dependencies {
    runtime(group = "org.springframework", name = "spring-core", version = "2.5")
请注意,您还需要用双引号替换单引号(请参阅)

在你的情况下,你应该写信

compile  (group= "org.seleniumhq.selenium", name = "selenium-java", version =  "3.+" )