首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >尽管我添加了java插件,但Gradle还是找不到testCompile。

尽管我添加了java插件,但Gradle还是找不到testCompile。
EN

Stack Overflow用户
提问于 2021-05-06 14:28:09
回答 3查看 5.9K关注 0票数 6

几天后詹金斯的测试就被取消了。我所犯的错误是:

配置根项目“MyAutomationTest”时出现问题。

没有找到名为“testCompile”的配置。

这是我的build.gradle文件:

代码语言:javascript
运行
复制
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath "io.qameta.allure:allure-gradle:2.3"

    }
}

group 'xyz'
version '1.0-SNAPSHOT'

apply plugin: 'io.qameta.allure'

repositories {
    mavenCentral()
}


def props = new Properties()
file("testsConfig.properties").withInputStream { props.load(it) }

allure {
    version = '2.4.1'
    aspectjweaver = true
    autoconfigure = true
    resultsDir = file(props.getProperty("projectPath")+'/allure-results')
    reportDir = file('raport/allure-results')
    clean
}

apply plugin: 'java'
apply plugin: 'idea'
sourceCompatibility = 1.8

subprojects {
    dependencies {
        testCompile 'junit:junit:4.12'
        testCompile 'io.appium:java-client:7.0.0'
        testCompile 'org.assertj:asertj-core:3.12.2'
        testCompile 'org.testng:testng:6.14.3'
        testCompile 'io.qameta.allure:allure-testng:2.13.1'
        testCompile 'log4j:log4j:1.2.17'
        testCompile 'com.jcabi:jcabi-log:0.17.2'
        testCompile 'org.slf4j:slf4j-log4j12:1.7.30'
        testCompile 'org.testobject:testobject-appium-java-api:0.1.14'
        testCompile 'io.rest-assured:rest-assured:4.3.2'
    }

}

test {
    System.setProperty("log4j.defaultInitOverride", "false")
    dependsOn cleanTest
    test.testLogging.showStandardStreams = false
    useTestNG() {
        systemProperties(props)
        systemProperties = System.getProperties()
        options.suites("src/test/resources/testng.xml")
    }
}

我们在詹金斯的自动测试直到几天前还很正常。从那时起,他们就不会用这个问题一开始就出现的错误进行编译。在代码的依赖块中存在“实现组”,但我最近将其更改为testCompile。“实现组”工作得很好,但是它开始弹出testCompile的错误。根据我的理解,在将java插件应用到依赖项之后,配置应该在那里,但不知怎么的,它不起作用。

我试过的是:

  1. 尝试使用testCompile()或testImplementation、testImplementation组等,也将名称约定从'junit‘、名称:'junit’、version:'4.12‘更改为它现在存在的版本。
  2. 应用思想插件
  3. 在gradle构建的最顶层应用java插件
  4. 将testCompile改为testImplementation
  5. 在每一个代码块中应用java插件(原语,但我的想法用完了)
  6. 项目中更新的依赖项

我可以看到它使用/path/to/. Gradle /daemon/7.0,但最终会收到信息:在此构建中使用了废弃的Gradle特性,使得它与Gradle 8.0不兼容,但是我不认为Gradle本身是一个问题。之前,我们有一个7.0级,它是非常好的工作与给定的吐露,它总是弹出同样的错误。

如果可能的话请帮忙。

问候

EN

回答 3

Stack Overflow用户

发布于 2021-07-17 13:10:08

此链接中提到的解决方案对我来说很好。

只需将以下代码块添加到build.gradle文件中即可:

代码语言:javascript
运行
复制
configurations {
   testCompile
}
票数 11
EN

Stack Overflow用户

发布于 2021-12-28 15:10:18

如果您正在使用Kotlin,请将以下内容添加到build.gradle.kts文件中:

代码语言:javascript
运行
复制
val testCompile by configurations.creating

代码语言:javascript
运行
复制
configurations {
    create("testCompile")
}
票数 1
EN

Stack Overflow用户

发布于 2021-05-21 13:48:11

对于那些和我一样面临同样问题的人:

我通过"./ gradle“命令触发了gradle。我把它改成了"./gradlew“,它很有魅力。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67420176

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档