I seem to have stumbled upon a very simple problem (which should be very straight-forward) but unable to find an answer for the last 4 hrs.
I am trying to configure a custom checkstyle config in my gradle project from a dependency (JAR) that has been imported into my project. The dependency is successfully pulled from our internal nexus maven repo (I can see the files under External libraries in IntelliJ).
Here’s my build.gradle
:
plugins {
id 'checkstyle'
}
repositories {
mavenCentral()
maven {
url = uri('https://repository..../repository/maven-releases')
}
}
dependencies {
implementation("tech.qa:UICheckstyle:1.0.8")
}
I have ensured the checkstyle is available under config/checkstyle/checkstyle.xml
(the default location) inside UIcheckstyle
repo.
Here is everything I have tried:
- When I run
gradle build
for the above setup, I get the following error:
Execution failed for task ':checkstyleMain'.
> A failure occurred while executing org.gradle.api.plugins.quality.internal.CheckstyleAction
> An unexpected error occurred configuring and executing Checkstyle.
> Unable to create Root Module: config {/Users/arjunvijayakumar/Desktop/workspaces/ui-automation/config/checkstyle/checkstyle.xml}, classpath {null}.
- Update the dependencies to:
dependencies {
checkstyle("tech.qa:UICheckstyle:1.0.8")
}
The error is:
Execution failed for task ':checkstyleMain'.
> A failure occurred while executing org.gradle.api.plugins.quality.internal.CheckstyleAction
> java.lang.ClassNotFoundException: com.puppycrawl.tools.checkstyle.ant.CheckstyleAntTask
- Added
checkstyle
block:
checkstyle {
configFile = rootProject.file("config/configuration/checkstyle.xml")
// This is obviously wrong. I am not sure how to access the file inside the JAR
}
Do I have to go down this path to access the file through ClassLoader
. Sounds very primitive and I feel there has to be a much simpler way.
Kindly let me know if anyone can help me with this?
Thanks in advance.