java - 任务 ':compileTestJava'的Gradle执行失败

标签 java gradle intellij-idea

Gradle中运行Intellij-IDEA程序时遇到错误。我不确定为什么会给我一个错误。我相信,在这种情况下,可能会弃用其中一个依赖项。请对此给予启发。谢谢。我在下面发布了错误StackTrace Build.Gradle 文件。
错误StackTrace

Execution failed for task ':compileTestJava'.
> Could not resolve all files for configuration ':testCompileClasspath'.
   > Could not find android.arch.persistence.room:runtime:1.1.1.
     Required by:
         project :
Build.Gradle
    plugins {
    id 'org.springframework.boot' version '2.3.4.RELEASE'
}

apply plugin: 'java'
apply plugin: 'io.spring.dependency-management'


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 {
    implementation 'android.arch.persistence.room:runtime:1.1.1'
    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: '4.5.12'

    // 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'

    // Importing ModelMapper Library for DTO
    compile 'org.modelmapper:modelmapper:2.3.3'

    // Importing Spring Boot Dependency
    implementation('org.springframework.boot:spring-boot-starter-web')
    implementation('org.springframework.boot:spring-boot-starter-data-jpa')
    
    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}"
    annotationProcessor 'android.arch.persistence.room:compiler:1.1.1'
    testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
    testRuntimeOnly "org.junit.vintage:junit-vintage-engine:${junitVersion}"
    implementation 'junit:junit:4.12'

    //Lombok plugin for DTO
    compileOnly 'org.projectlombok:lombok:1.18.12'
    annotationProcessor 'org.projectlombok:lombok:1.18.12'

    //MapStruct Mapper Framework for serialising DTO
    implementation 'org.mapstruct:mapstruct:1.4.0.Final'
    annotationProcessor 'org.mapstruct:mapstruct-processor:1.4.0.Final'

    testCompileOnly 'org.projectlombok:lombok:1.18.12'
    testAnnotationProcessor 'org.projectlombok:lombok:1.18.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")
}
注意:我已经重新发布了Build.Gradle文件。

最佳答案

我认为答案是我的程序集中在DTO上,我遇到问题的依赖关系与我的程序无关。

implementation 'android.arch.persistence.room:runtime:1.1.1'
实际上,该依赖项包括android作为该依赖项的根词,它更适合Android,这对我的DTO程序没有任何意义。
所以我要做的是删除implementation 'android.arch.persistence.room:runtime:1.1.1'annotationProcessor 'android.arch.persistence.room:compiler:1.1.1'。最终,该程序运行良好,因为我已经在使用MapStruct注释处理器与DTO进行了映射。

关于java - 任务 ':compileTestJava'的Gradle执行失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64456237/

相关文章:

java - 如何在 truzip 中获取文件大小

java - 在自定义 java 库模块中编译 android 模块时出现 Gradle 警告 "unspecified depends on libraries but is a jar "

maven - 如何从Gradle访问本地仓库

java - 生成 “build”文件夹下的文件,不应对其进行编辑

java - 配置 @RunWith 以在 IntelliJ 运行器中使用 CucumberWithSerenity.class 而不是 Cucumber.class

java - 无法实例化类 utils.listeners.TestListener。空测试套件

java - 如果简单的数组可以工作,为什么还要在 OpenGL (LWJGL) 中使用缓冲区?

java - 算法选择 - 理解是什么以及为什么

Java 泛型 TypeOf 返回 T

android - native 库(.so 文件)未添加到 android 项目