Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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.

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.

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.

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

In case is necessary here are the versions i am using:

  • CLI Gradle version: 2.10
  • Java version: Ubuntu openjdk 1.8.0_151
  • IntelliJ version: 2017.3.4 Community Edition
like image 544
Oscar Reyes Avatar asked Feb 24 '18 04:02

Oscar Reyes


Video Answer


2 Answers

Looks like they changed the Variable, from classDumpFile to classDumpDir.

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

This worked for me

like image 197
djgooner Avatar answered Oct 20 '22 05:10

djgooner


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:

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

like image 20
Oscar Reyes Avatar answered Oct 20 '22 03:10

Oscar Reyes