[英]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 版本或其他原因,但我仍在学习如何使用Java
和IntelliJ
,其他开发人员正在使用Eclipse
,他们没有收到此错误,但我不想切换到Eclipse
因为我是IntelliJ
已经太舒服了
In case is necessary here are the versions i am using:如果有必要,这里是我正在使用的版本:
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.