I am currently trying to get the CodeNarc plugin for Gradle 8.0.2 to work in my project.
Due to some reasons, the Groovy files have different extensions. At the moment, the plugin only seems to run for the *.groovy files.
Let's say I have a build.gradle file like this:
plugins {
id 'groovy'
id 'java'
id 'codenarc'
}
repository {
mavenCentral()
}
dependencies {
implementation 'org.apache.groovy:groovy-all:4.0.10'
}
sourceSets {
main {
groovy {
srcDirs = ['directory1', 'directory2']
}
}
}
Now I have the following files:
directory1/utils.groovydirectory1/something.groovydirectory2/another.myextension
Running ./gradlew codenarcMain --info will not print:
No matching files found for FileSet with basedir [/home/path/to/project/directory2]
Adding
codenarcMain {
include('**/*.myextension', '**/*.groovy')
}
does not seem to change anything.
What is the correct approach to register custom extensions for the CodeNarc plugin from within Gradle?
I wasn't able to get gradle's in-built
codenarcplugin recognize an extension other than.groovyeven after configuring the groovy compiler to recognize the new extension. However, following an example in the codenarc website, I was able to achieve this by creating a custom codenarc gradle task based on the ant codenarc task. This task is configured to process specific source folder(s)(src/test/groovyin the example) and files with specific extensions(.groovyand.dummyin the example).