-
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Configuration" example for Groovy Gradle files #26
Comments
Hello, thanks for this awesome plugin 🎉 ! I too think a sample for configuring the plugin via a groovy build script, would be of great help. |
The Kotlin DSL classes in the plugin don't lend themselves conveniently for expressing the same thing in Groovy. This is a Groovy conversion of the example in the README.md. Please note that the default rule parameters need to be explicitly specified. I believe adding plugins {
id 'com.appmattus.markdown' version '0.6.0'
}
import com.appmattus.markdown.rules.config.HeaderStyle
import com.appmattus.markdown.rules.ConsistentHeaderStyleRule
import com.appmattus.markdown.rules.NoDuplicateHeaderRule
import com.appmattus.markdown.rules.SingleH1Rule
markdownlint.with {
// Optional - Use to override settings for individual rules or add in custom rules
rules { rb ->
// Change the default settings of a rule
rb.unaryPlus(new ConsistentHeaderStyleRule(HeaderStyle.Atx, {rsb -> }))
rb.unaryPlus(new NoDuplicateHeaderRule(false, { rsb ->
// Include files using RegEx for this rule, default=".*" (i.e. all files)
includes = [".*/directory_to_include/.*"]
// Exclude files using RegEx for this rule, default=empty (i.e. exclude nothing)
excludes = [".*/a_file_to_exclude.md"]
}))
// Disable a rule by setting active to false
rb.unaryPlus(new SingleH1Rule(1, { rsb ->
rsb.active = false
}))
}
// Optional - Include files using RegEx for ALL rules, default=".*" (i.e. all files in root project directory)
includes = [".*/directory_to_include/.*"]
// Optional - Exclude files using RegEx for ALL rules, default=empty (i.e. exclude nothing)
excludes = [".*/a_file_to_exclude.md"]
// Optional - Specify the reports to generate, default=html,checkstyle
// If you specify the reports block the plugin will output only the types
// specified i.e. to output no reports implement an empty block
reports { rb ->
// enable html report
rb.html()
// enable checkstyle xml report
rb.checkstyle()
}
// Optional - Specify the error count threshold that triggers a failed build, default=0
threshold = 10
} |
Thanks @davidburstromspotify for the helpful comment. I've been meaning to look into this myself for quite a while! Since I wrote the initial version of the plugin I'm certain there are better ways I can create the configuration that would provide better compatibility for both Groovy and Kotlin DSL. |
Hi,
Is possible to provide an example with "Configuration" but not for .kts Gradle files?
Thanks for a very useful library!
The text was updated successfully, but these errors were encountered: