英文:
How to fix execution task failure for ':compileTestJava'?
问题
我已开始使用 Gradle
进行一个 Java 项目,我已将必要的 Spring Boot
库导入到了 build.gradle
中。在构建项目时,出现了以下错误:
错误信息
任务“:compileTestJava”执行失败。
> 无法解析配置“:testCompileClasspath”的所有文件。
> 找不到 org.apache.httpcomponents:httpclient:1.2.5。
所需位置:
项目:
> 找不到 org.apache.httpcomponents:httpclient:1.2.5。
所需位置:
项目: > io.rest-assured:rest-assured:4.1.2
> 找不到 org.apache.httpcomponents:httpclient:1.2.5。
所需位置:
项目: > com.microsoft.sqlserver:mssql-jdbc:6.1.0.jre8 > com.microsoft.azure:azure-keyvault:0.9.3
项目: > com.microsoft.sqlserver:mssql-jdbc:6.1.0.jre8 > com.microsoft.azure:azure-keyvault:0.9.3 > com.microsoft.azure:azure-core:0.9.3
> 找不到 org.apache.httpcomponents:httpclient:1.2.5。
所需位置:
项目: > io.rest-assured:rest-assured:4.1.2 > org.apache.httpcomponents:httpmime:4.5.12
可能的解决方案:
- 声明提供该构件的仓库,参见 https://docs.gradle.org/current/userguide/declaring_repositories.html
Build.Gradle
应用插件:'java'
sourceCompatibility = 1.8
targetCompatibility = 1.8
group 'AbtMainTestControl'
version '1.0-SNAPSHOT'
// 依赖版本
wrapper.gradleVersion = '5.5.1'
def cucumberVersion = '4.7.1'
def junitVersion = '5.5.0'
def restVersion = '4.1.2'
def apacheDrillVersion = '1.17.0'
仓库 {
jcenter()
mavenCentral()
}
依赖项 {
编译组:'org.codehaus.jackson',名称:'jackson-core-asl',版本:'1.9.13'
编译组:'com.opencsv',名称:'opencsv',版本:'4.0'
编译组:'org.apache.httpcomponents',名称:'httpclient',版本:'1.2.5'
// https://mvnrepository.com/artifact/org.apache.drill.tools/tools-parent
编译组:'org.apache.drill.tools',名称:'tools-parent',版本:"${apacheDrillVersion}",扩展:'pom'
// Cucumber Pretty Report Plugin
编译组:'de.monochromata.cucumber',名称:'reporting-plugin',版本:'3.0.9'
测试编译组:'com.microsoft.sqlserver',名称:'mssql-jdbc',版本:'6.1.0.jre8'
编译组:'org.apache.commons',名称:'commons-dbcp2',版本:'2.7.0'
测试实施 "io.cucumber:cucumber-java:${cucumberVersion}"
测试实施 "io.cucumber:cucumber-junit:${cucumberVersion}"
测试实施 "io.rest-assured:rest-assured:${restVersion}"
测试实施 "io.rest-assured:json-path:${restVersion}"
测试实施 "io.rest-assured:json-schema-validator:${restVersion}"
测试实施 "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
测试运行时仅 "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
测试运行时仅 "org.junit.vintage:junit-vintage-engine:${junitVersion}"
实施 'junit:junit:4.12'
}
配置 {
cucumberRuntime {
扩展自 testImplementation
}
}
任务 黄瓜() {
依赖于 集结, compileTestJava
最终 {
javaexec {
main = "io.cucumber.core.cli.Main"
classpath = 配置.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
args = ['--plugin',
'pretty',
'--glue',
'gradle.cucumber',
'src/test/resources/features',
]
}
}
}
测试 {
//useJUnitPlatform()
系统属性 "cucumber.options", System.properties.getProperty("cucumber.options")
}
在这个情况下,我已将 Spring Boot 库移除,以便查看问题是否出现在 Build.Gradle
文件中。
有人能够推荐解决方案/帮助我尝试解决这个问题吗?您的建议将不胜感激
英文:
I have embarked on a Java Project using Gradle
where I have imported the necessary Spring Boot
libs into the build.gradle
. As I was building the project, it gave me this error below:
Error
Execution failed for task ':compileTestJava'.
> Could not resolve all files for configuration ':testCompileClasspath'.
> Could not find org.apache.httpcomponents:httpclient:1.2.5.
Required by:
project :
> Could not find org.apache.httpcomponents:httpclient:1.2.5.
Required by:
project : > io.rest-assured:rest-assured:4.1.2
> Could not find org.apache.httpcomponents:httpclient:1.2.5.
Required by:
project : > com.microsoft.sqlserver:mssql-jdbc:6.1.0.jre8 > com.microsoft.azure:azure-keyvault:0.9.3
project : > com.microsoft.sqlserver:mssql-jdbc:6.1.0.jre8 > com.microsoft.azure:azure-keyvault:0.9.3 > com.microsoft.azure:azure-core:0.9.3
> Could not find org.apache.httpcomponents:httpclient:1.2.5.
Required by:
project : > io.rest-assured:rest-assured:4.1.2 > org.apache.httpcomponents:httpmime:4.5.12
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
Build.Gradle
apply plugin: 'java'
sourceCompatibility = 1.8
targetCompatibility = 1.8
group 'AbtMainTestControl'
version '1.0-SNAPSHOT'
// Versioning of dependencies
wrapper.gradleVersion = '5.5.1'
def cucumberVersion = '4.7.1'
def junitVersion = '5.5.0'
def restVersion = '4.1.2'
def apacheDrillVersion = '1.17.0'
repositories {
jcenter()
mavenCentral()
}
dependencies {
compile group: 'org.codehaus.jackson', name: 'jackson-core-asl', version: '1.9.13'
compile group: 'com.opencsv', name: 'opencsv', version: '4.0'
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '1.2.5'
// https://mvnrepository.com/artifact/org.apache.drill.tools/tools-parent
compile group: 'org.apache.drill.tools', name: 'tools-parent', version: "${apacheDrillVersion}", ext: 'pom'
// Cucumber Pretty Report Plugin
compile group: 'de.monochromata.cucumber', name: 'reporting-plugin', version: '3.0.9'
testCompile group: 'com.microsoft.sqlserver', name: 'mssql-jdbc', version: '6.1.0.jre8'
compile group: 'org.apache.commons', name: 'commons-dbcp2', version: '2.7.0'
testImplementation "io.cucumber:cucumber-java:${cucumberVersion}"
testImplementation "io.cucumber:cucumber-junit:${cucumberVersion}"
testImplementation "io.rest-assured:rest-assured:${restVersion}"
testImplementation "io.rest-assured:json-path:${restVersion}"
testImplementation "io.rest-assured:json-schema-validator:${restVersion}"
testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:${junitVersion}"
implementation 'junit:junit:4.12'
}
configurations {
cucumberRuntime {
extendsFrom testImplementation
}
}
task cucumber() {
dependsOn assemble, compileTestJava
doLast {
javaexec {
main = "io.cucumber.core.cli.Main"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
args = ['--plugin',
'pretty',
'--glue',
'gradle.cucumber',
'src/test/resources/features',
]
}
}
}
test {
//useJUnitPlatform()
systemProperty "cucumber.options", System.properties.getProperty("cucumber.options")
}
I have taken out the Spring Boot libs in this case so as to see where the problem lies in the Build.Gradle
file
Can anybody recommend solutions/help me in trying to solve the problem? Your suggestions will be greatly appreciated
答案1
得分: 0
httpclient
的版本 -- 1.2.5 -- 看起来有点不对;最新版本是 4.5.12。
英文:
The version for httpclient
-- 1.2.5 -- looks a bit off; the latest version is 4.5.12.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论