aaschmid/gradle-cpd-plugin

Configuring CPDCheck as a seperate gradle file throwing below error

RameshbabuJaga opened this issue ยท 14 comments

  • What went wrong:
    Some problems were found with the configuration of task ':app:testCodeCpdCheck' (type 'Cpd').

No value has been specified for property 'reports.csv.outputLocation'.
No value has been specified for property 'reports.text.outputLocation'.
No value has been specified for property 'reports.vs.outputLocation'.
No value has been specified for property 'reports.xml.outputLocation'.
No value has been specified for property 'skipBlocksPattern'.

My cpdcheck.gradle file like belo

            import de.aaschmid.gradle.plugins.cpd.Cpd
            
            apply plugin: "de.aaschmid.cpd"
            
            buildscript {
                repositories {
                    maven {
                        url "https://plugins.gradle.org/m2/"
                    }
                }
                dependencies {
                    classpath "de.aaschmid:gradle-cpd-plugin:3.2"
                }
            }
            
           // for source code cpd check (below task was running fine)
            cpd {
                language = 'java'
                toolVersion = '6.10.0'
                minimumTokenCount = 100 // approximately 5-10 lines
            }
            
            cpdCheck {
                reports {
                    text.enabled = true
                    xml.enabled = false
                }
            
                source = fileTree(dir: "$rootDir.absolutePath", includes: [
                        "app/src/main/java/**",
                        "utility/src/main/java/**",
                ])
            }
            
           // for test code cpd check -- (the error come from the below task) 
            task testCodeCpdCheck(type: Cpd) {
                skipLexicalErrors = false
                minimumTokenCount = 200
                language = 'java'
                pmdClasspath = fileTree('src/test/java')
            
                reports {
                    text.enabled = true
                    xml.enabled = false
                }
                source = fileTree('src/test/java')
            }

my build.gradle version: 4.0.2
Distributions gradle-6.1.1

Which gradle-cpd-plugin version do you use @RameshbabuJaga?

@aaschmid am using gradle-cpd-plugin:3.2

Basically, I want to configure the Source code and Test code with two different gradle files. So that I can manage duplicate codes based on the minimumTokenCount. For this, I am trying the above way.

Ah ok, if you look at the documentation on https://github.com/aaschmid/gradle-cpd-plugin#supported-versions, the v3.2 is no longer supported with Gradle < 6.6. Can your try to upgrade either Gradle or use gradle-cpd-plugin:3.1?

@aaschmid still same error

  • What went wrong:
    Some problems were found with the configuration of task ':app:testCodeCpdCheck' (type 'Cpd').

No value has been specified for property 'encoding'.
No value has been specified for property 'reports.csv.outputLocation'.
No value has been specified for property 'reports.text.outputLocation'.
No value has been specified for property 'reports.vs.outputLocation'.
No value has been specified for property 'skipBlocksPattern'.

What have you tried? Both, upgrade Gradle and downgrade de.aaschmid.cpd?

Unfortunately, I have no further ideas yet. Therefore, I need to deeper investigate into that. Any further information would appreciated as I could not easily reproduce it ...

Edit: Working OSS examples: https://github.com/C-Otto/playground and https://github.com/TNG/junit-dataprovider.

I have tried to upgrade Gradle and downgrade de.aaschmid.cpd few versions.

Have you ever seen a working version or did you set it up from scratch?
(I need further information in order reproduce it...)

@aaschmid I have started this myself from the scratch. Actually, I want to take this CPD part out of the app build gradle file.
So I created cpdcheck.gradle file and pointed app build gradle like this

apply from: '../gradle-config/cpdcheck.gradle'
afterEvaluate {
assembleDebug.dependsOn cpdCheck
}

Everything fine here. When I run cpdCheck on the source code it's working fine. Same way when I run the test code
task testCodeCpdCheck

I am getting this error.

@aaschmid basically any idea how to create two different configurations for the Source and Test codes. So that I can manage easily at the time of each build.

@aaschmid I have started this myself from the scratch. Actually, I want to take this CPD part out of the app build gradle file.

Ah ok. It is working currently but no longer working after your refactoring, right?

@aaschmid basically any idea how to create two different configurations for the Source and Test codes. So that I can manage easily at the time of each build.

Now I got it. You want to have two Cpd tasks. You can create multiple cpd tasks by

  task anotherCpdTask(type: Cpd) {
    // config goes here
  }

with source being once subprojects*.sourceSets*.main*.java*.srcDirs (prod code) and once subprojects*.sourceSets*.test*.java*.srcDirs (test code)

(However, if you reuse the pre-configured cpdCheck task and configure and use it twice, does not explain the error message for me...)

@aaschmid Further I will look into it. But still, I have no idea from where that error popped up. As you saw that I have two different cpd checks with respect to the source. Still wondering about the error.

Any news on this @RameshbabuJaga ?

Closing due to no answers anymore, please feel free to reopen upon further information.