I referred to this site. http://irtakt.hatenablog.com/entry/2014/05/04/233312
It seems that it may or may not occur depending on the environment. I checked Checkstyle ⇒ "Activate Checkstyle in this project" in the project properties of Eclipse, but This is a workaround when the check is unchecked when "Refresh Gradle project" [^ ref] is executed.
And the check is unchecked
The cause is that gradle's eclipse plugin is called in "Refresh Gradle project", This is because the ".project" file will be rebuilt and Checkstyle's buildCommand and nature will be out of sync.
http://gradle.monochromeroad.com/docs/userguide/eclipse_plugin.html
Add the following description to the build.gradle file.
build.gradle
apply plugin: 'eclipse'
eclipse {
project {
natures 'net.sf.eclipsecs.core.CheckstyleNature'
buildCommand 'net.sf.eclipsecs.core.CheckstyleBuilder'
}
}
Now, when you "Refresh Gradle project" [^ ref], the buildCommand and nature for Checkstyle will be described in the ".project" file, and you can always turn on the Checkstyle active setting of Eclipse.
Below is the created ".project" file
.project
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<!--・ ・ ・ ・-->
<buildSpec>
<!--・ ・ ・ ・-->
<buildCommand>
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
<!--・ ・ ・ ・-->
</buildSpec>
<natures>
<!--・ ・ ・ ・-->
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
<!--・ ・ ・ ・-->
</natures>
</projectDescription>
[^ ref]: Or run gradle eclipse
.