I have the following project structure:
project
checkstyle
checkstyle.xml
subproject1
...
subproject2
...
build.gradle
My configuration for checkstyle in the build.gradle
is as follows:
allprojects {
apply plugin: 'checkstyle'
checkstyle {
configFile = 'checkstyle/checkstyle.xml' as File
}
}
When I was using gradle 2.1, build worked OK. After upgrading to 2.2 or 2.2.1 the error occurs:
:subproject1:checkstyleMain FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':subproject1:checkstyleMain'.
> Unable to create a Checker: unable to find /home/my/project/subproject1/checkstyle/checkstyle.xml
Gradle is now looking for 'checkstyle/checkstyle.xml' in the subproject directory, which is not what I would expect.
I have found that they mentioned this change in 2.2 release notes. But they did not tell how to maintain old behavior of resolving that path. How to do this?
I tried using project.file
but it does not work too.
in your snippet
allprojects {
apply plugin: 'checkstyle'
checkstyle {
configFile = 'checkstyle/checkstyle.xml' as File
}
}
you configure the configfile per project to be relative from the subproject you're currently configuring. you can fix this by replacing
checkstyle {
configFile = 'checkstyle/checkstyle.xml' as File
}
by
checkstyle {
configFile = rootProject.file('checkstyle/checkstyle.xml')
}