Gradle执行任务“:compileTestJava”失败。

huangapple go评论76阅读模式
英文:

Gradle execution failed for task ':compileTestJava'

问题

以下是翻译好的内容:

Error StackTrace

执行任务 ':compileTestJava' 失败。
> 无法解析配置的所有文件 ':testCompileClasspath'。
   > 无法找到 android.arch.persistence.room:runtime:1.1.1。
     所需位置:
         项目 :

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'

// 依赖项版本控制
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'

    // 引入 ModelMapper 库用于 DTO
    compile 'org.modelmapper:modelmapper:2.3.3'

    // 引入 Spring Boot 依赖
    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'

    // 用于 DTO 的 Lombok 插件
    compileOnly 'org.projectlombok:lombok:1.18.12'
    annotationProcessor 'org.projectlombok:lombok:1.18.12'

    // MapStruct Mapper Framework 用于序列化 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")
}
英文:

I have encountered an error when running my Gradle program in Intellij-IDEA. I'm unsure why it gave me an error. I believe one of the dependencies might be deprecated if that's the case. Please enlighten me on this. Thanks. I have posted the Error StackTrace and Build.Gradle files below.

Error 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")
}

Note: I have re-posted the Build.Gradle file.

答案1

得分: 0

我认为正确的答案是,我程序的重点在于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的映射。

英文:

The answer that I thought was that my program focuses on DTO which the dependency that I had an issue with has got nothing to do with my program.

implementation 'android.arch.persistence.room:runtime:1.1.1'

In fact, the dependency includes android as the root word for the dependency which is more catered towards Android which doesn't make any sense with my DTO Program.

So what I did was to remove implementation 'android.arch.persistence.room:runtime:1.1.1' together with annotationProcessor 'android.arch.persistence.room:compiler:1.1.1'. Eventually, the program works fine as I'm already using the MapStruct Annotation Processor to do mapping with DTO.

huangapple
  • 本文由 发表于 2020年10月21日 11:27:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/64456237.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定