简体   繁体   English

Gradle:无法在 Intellij 中设置未知属性“classDumpFile”

[英]Gradle: could not set unknown property 'classDumpFile' in Intellij

I have been searching through the Internet and asking on irc chats but none of them were or did not give any answer for trying to solve my problem.我一直在通过互联网搜索并询问 irc 聊天,但他们都没有或没有给出任何试图解决我的问题的答案。

I am trying to make my project to use JaCoCo on Intellij IDE, the tests are going to be done in a Jenkins server, i have set some settings in my gradle.build file for JaCoCo but build compilation fails saying Could not set unknown property 'classDumpFile' for object of type org.gradle.testing.jacoco.plugins.JacocoTaskExtension.我试图让我的项目在Intellij IDE 上使用JaCoCo ,测试将在Jenkins服务器中完成,我在我的 gradle.build 文件中为JaCoCo设置了一些设置,但构建编译失败,说Could not set unknown property 'classDumpFile' for object of type org.gradle.testing.jacoco.plugins.JacocoTaskExtension.

The build file is like this:构建文件是这样的:

version '1.0-SNAPSHOT'

apply plugin: 'java'
apply plugin: 'jacoco'

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenCentral()
}

jacoco{
    toolVersion = '0.7.6.201602180812'
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    testCompile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.5'
    compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.6'
    compile group: 'org.json', name: 'json', version: '20180130'
}
test{
    jacoco {
        append = false
        destinationFile = file("$buildDir/jacoco/jacocoTest.exec")
        classDumpFile = file("$buildDir/jacoco/classpathdumps")
    }
}

this is a gradle file generated by IntelliJ when creating the project and i have been adding some dependencies manually, now the developer that is managing the jenkins server told me to use these JaCoCo settings for sonarQube to work well, IntelliJ fails to make any compilation but when submitting the code to Jenkins it works fine.这是在创建项目时由IntelliJ生成的 gradle 文件,我一直在手动添加一些依赖项,现在管理jenkins服务器的开发人员告诉我使用这些JaCoCo设置使sonarQube正常工作, IntelliJ无法进行任何编译,但是将代码提交给Jenkins它工作正常。

I have been searching why does this happens and i have found out this might be due to gradle version and should use classDumpDir instead, this makes IntelliJ work but Jenkins server fails to build the project.我一直在寻找为什么会发生这种情况,我发现这可能是由于 gradle 版本造成的,应该改用classDumpDir ,这使IntelliJ工作但Jenkins服务器无法构建项目。

I believe this might be due to gradle version or something but i am still learning how to work with Java and IntelliJ , other developers are working with Eclipse and they do not get this error but i don't want to switch to Eclipse cause i am already too comfortable with IntelliJ我相信这可能是由于 gradle 版本或其他原因,但我仍在学习如何使用JavaIntelliJ ,其他开发人员正在使用Eclipse ,他们没有收到此错误,但我不想切换到Eclipse因为我是IntelliJ已经太舒服了

In case is necessary here are the versions i am using:如果有必要,这里是我正在使用的版本:

  • CLI Gradle version: 2.10 CLI Gradle 版本:2.10
  • Java version: Ubuntu openjdk 1.8.0_151 Java 版本:Ubuntu openjdk 1.8.0_151
  • IntelliJ version: 2017.3.4 Community Edition IntelliJ 版本:2017.3.4 社区版

Looks like they changed the Variable, from classDumpFile to classDumpDir.看起来他们改变了变量,从 classDumpFile 到 classDumpDir。

test {
    jacoco {
        append = false
        classDumpDir = file("$buildDir/jacoco/classpathdumps")
    }
}

This worked for me这对我有用

After long hours of searching, testing and failing i have finally found the way to fix this issue.经过长时间的搜索、测试和失败,我终于找到了解决这个问题的方法。

I have found out in the directory gradle/wrapper there is a file with the gradle properties, in this file there was a variable that defines which gradle to use and on my file it was set to use gradle 4.5:我发现在gradle/wrapper目录中有一个带有 gradle 属性的文件,在这个文件中有一个变量定义了要使用的 gradle,在我的文件中它被设置为使用 gradle 4.5:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5-all.zip

i've asked the DevOps engineer which gradle version jenkins is using and he said it should be 3.0 so i changed the distributionUrl value to use 3.0 version and it works我问过 DevOps 工程师 jenkins 正在使用哪个 gradle 版本,他说应该是 3.0,所以我将distributionUrl值更改为使用 3.0 版本并且它可以工作

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法在 Gradle 中设置未知属性“applicationDefaultJvmArgs” - Could not set unknown property 'applicationDefaultJvmArgs' in Gradle 无法在Gradle中获得任务的未知属性? - Could not get unknown property for task in Gradle? 无法获取未知属性“运行时”Gradle 7.0 - Could not get unknown property "runtime" Gradle 7.0 无法为 org.springframework.boot.gradle.dsl.SpringBootExtension 类型的对象设置未知属性“mainClass” - Could not set unknown property 'mainClass' for object of type org.springframework.boot.gradle.dsl.SpringBootExtension 使用Gradle 5.4.1签名maven jar导致无法设置未知属性'keyId' - Signing maven jar with Gradle 5.4.1 results in Could not set unknown property 'keyId' 无法为 org.springframework.boot.gradle.dsl.SpringBootExtension 类型的扩展“springBoot”设置未知属性“mainClassName” - Could not set unknown property 'mainClassName' for extension 'springBoot' of type org.springframework.boot.gradle.dsl.SpringBootExtension 无法为类型com.android.build.gradle.internal.api.DefaultAndroidSourceSet的源集主设置未知属性's' - Could not set unknown property 's' for source set main of type com.android.build.gradle.internal.api.DefaultAndroidSourceSet 无法为扩展“应用程序”设置未知属性“mainClass” - Could not set unknown property 'mainClass' for extension 'application 无法为 org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler 类型的对象设置未知属性“nav_version” - Could not set unknown property 'nav_version' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler groovy.lang.MissingPropertyException: Could not set unknown property 'useIR' for object of type org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptionsImpl - groovy.lang.MissingPropertyException: Could not set unknown property 'useIR' for object of type org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptionsImpl
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM