[GRADLE-2208] Provide a default config file for checkstyle plugin Created: 03/Apr/12  Updated: 10/Feb/17  Resolved: 10/Feb/17

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: None

Type: Improvement
Reporter: Gradle Forums Assignee: Unassigned
Resolution: Won't Fix Votes: 5


At the moment, if the user does not provide a config file the build will fail. We should provide a default.

Comment by Justin Ryan [ 23/Sep/13 ]

In lieu of a pull request, this is what my Checkstyle wrapper plugin does to help in this regard, which might help other people who have this problem.

package netflix.nebula.checkstyle

import netflix.nebula.ClasspathHelper
import netflix.nebula.GradleHelper
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.internal.IConventionAware
import org.gradle.api.logging.Logger
import org.gradle.api.logging.Logging
import org.gradle.api.plugins.quality.CheckstyleExtension
import org.gradle.api.plugins.quality.CheckstylePlugin

class NebulaCheckstylePlugin implements Plugin<Project> {
    private static Logger logger = Logging.getLogger(NebulaCheckstylePlugin);

    protected Project project

    void apply(Project project) {
        this.project = project


        CheckstyleExtension extension = project.extensions.getByType(CheckstyleExtension)

        // This is what we have in extlib
        extension.ignoreFailures = true

        // extension.configFile requires a real filesystem. Ironically the ant task, underlying the Checkstyle task,
        // actually supports a String pointing to ClassLoader.getResource()
        // According to http://checkstyle.sourceforge.net/anttask.html

        extension.configFile = copyCheckstyleXml()

    def copyCheckstyleXml() {
        File tmpDir = new GradleHelper(project).getTempDir('checkstyle')
        File to = new File(tmpDir, 'checkstyle.xml')
        return ClasspathHelper.copyResource('netflix/nebula/codequality/checkstyle.xml', to)

And of course I have a src/main/resources/nebula/nebula/codequality/checkstyle.xml file, which is pretty stock Sun recommendations.

Comment by Piotr Jagielski [ 22/Jan/16 ]

There is an unfinished pull request that attempted to address it in case someone is interested in picking it up: https://github.com/gradle/gradle/pull/420.

Comment by Benjamin Muschko [ 15/Nov/16 ]

As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub.

We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to.

Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:

  • Checking that your issues contain requisite context, impact, behaviors, and examples as described in our published guidelines.
  • Leave a comment on the JIRA issue or open a new GitHub issue confirming that the above is complete.

We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle!

Comment by Benjamin Muschko [ 10/Feb/17 ]

Thanks again for reporting this issue. We haven't heard back from you after our inquiry from November 15th. We are closing this issue now. Please create an issue on GitHub if you still feel passionate about getting it resolved.

Generated at Wed Jun 30 12:15:39 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.