gpt4 book ai didi

java - 如何修复 build.gradle 文件中的依赖项

转载 作者:行者123 更新时间:2023-11-30 07:29:04 25 4
gpt4 key购买 nike

I am new to gradle, i need to configure my build.gradle file . Am using selenium webdriver and i have list of .jar files. how do i include this jar files as dependencies in my build.gradle file?. i have this .jar in a folder called lib in my package. and i have

dependencies {
compile fileTree(dir: 'lib', includes: '*.jar')

}但我一直遇到以下错误:

FAILURE: Build failed with an exception.

其中:构建文件“/home/ola/workspace/build.gradle”行:20

出了什么问题:评估根项目“工作空间”时出现问题。无法将类“java.lang.String”的对象“*.jar”转换为类“java.lang.Iterable”

please can anyone point me to how to write dependencies for a webdriver project using gradle.This is the path to my lib folder: "/home/user/workspace/mainsite_automation/src/autoTest/lib/"

谢谢

最佳答案

您只需要指定依赖项存储库和 selenium webdriver 依赖项,这样您最终将得到类似于以下内容的 build.gradle:

apply plugin: 'java'
apply plugin: 'jetty'

repositories {
mavenCentral()
}

sourceSets {
selenium
}

dependencies {
seleniumCompile 'junit:junit:4.11'
seleniumCompile 'org.seleniumhq.selenium:selenium-java:2.30.0'
}

task jettyDaemon(type: org.gradle.api.plugins.jetty.JettyRun) {
daemon = true
}

task selenium(type: Test, dependsOn: jettyDaemon) {
testClassesDir = sourceSets.selenium.output.classesDir
classpath = sourceSets.selenium.runtimeClasspath
}

对于 Eclipse,您可以将 selenium 依赖项添加到类路径中,并将其添加到您的 build.gradle 中:

eclipse {
classpath {
plusConfigurations += configurations.seleniumCompile
}
}

然后您可以使用grade clean selenium来重建您的项目。

来源:

https://docs.gradle.org/current/userguide/artifact_dependencies_tutorial.html http://www.dreamchain.com/gradle-selenium-webdriver-task/

关于java - 如何修复 build.gradle 文件中的依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36403539/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com