Class LanguageCheckExtension

java.lang.Object
io.github.sergeloie.languagecheck.LanguageCheckExtension

public abstract class LanguageCheckExtension extends Object
The languageCheck { ... } project extension: everything a user can configure for the language check.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addCustomLanguage(String languageCode, File languageFile)
    Register a single custom language file under languageCode.
    abstract org.gradle.api.provider.MapProperty<String,File>
    User-supplied language files, keyed by language code.
    abstract org.gradle.api.provider.SetProperty<String>
    Relative directories whose whole subtrees are never scanned.
    abstract org.gradle.api.provider.SetProperty<String>
    File extensions that are never scanned (without the leading dot).
    abstract org.gradle.api.provider.SetProperty<String>
    Exact relative file paths that are never scanned.
    abstract org.gradle.api.provider.Property<Boolean>
    True (default): fail the build when violations are found.
    abstract org.gradle.api.provider.Property<Long>
    Timeout for the git ls-files subprocess in GIT scan mode, in seconds.
    abstract org.gradle.api.provider.Property<Long>
    Largest file (bytes) that is still scanned; larger files are skipped.
    abstract org.gradle.api.provider.Property<Integer>
    Most detailed violations to collect per file in the report; the total count is always exact.
    abstract org.gradle.api.file.RegularFileProperty
    Where the task writes its report file.
    abstract org.gradle.api.provider.Property<ScanMode>
    Which file set the scan covers - ScanMode.GIT or ScanMode.ALL.
    abstract org.gradle.api.provider.SetProperty<String>
    Extensions exempt from strict UTF-8 validation (their files are decoded leniently, e.g.
    void
    setExtensions(List<String> extensions, List<String> languages)
    Declarative mapping: assigns language codes (plus the optional formatting and ascii pseudo-languages) to each listed extension, fully replacing those extensions' previous configuration.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LanguageCheckExtension

      public LanguageCheckExtension()
  • Method Details

    • getScanMode

      public abstract org.gradle.api.provider.Property<ScanMode> getScanMode()
      Which file set the scan covers - ScanMode.GIT or ScanMode.ALL.
    • getExcludedFiles

      public abstract org.gradle.api.provider.SetProperty<String> getExcludedFiles()
      Exact relative file paths that are never scanned.
    • getExcludedDirs

      public abstract org.gradle.api.provider.SetProperty<String> getExcludedDirs()
      Relative directories whose whole subtrees are never scanned.
    • getExcludedExtensions

      public abstract org.gradle.api.provider.SetProperty<String> getExcludedExtensions()
      File extensions that are never scanned (without the leading dot).
    • setExtensions

      public void setExtensions(List<String> extensions, List<String> languages)
      Declarative mapping: assigns language codes (plus the optional formatting and ascii pseudo-languages) to each listed extension, fully replacing those extensions' previous configuration. This is the only way to declare the mapping since 0.2.0.

      Extensions are normalized the same way everywhere (trim, lower-case, leading dot stripped). The two pseudo-tokens are case-insensitive:

      • formatting adds the extension to the formatting set (its absence removes it);
      • ascii makes the extension strict ASCII-only and wins over everything else in the same list: other codes and formatting are ignored, the mapping entry is dropped.

      The remaining codes must exist in the language catalog (validated at execution time).

      Example: setExtensions(['md', 'txt'], ['ru', 'fr', 'formatting']).

    • getUtf8ExemptExtensions

      public abstract org.gradle.api.provider.SetProperty<String> getUtf8ExemptExtensions()
      Extensions exempt from strict UTF-8 validation (their files are decoded leniently, e.g. .properties in ISO-8859-1). Declare as a list: utf8ExemptExtensions.addAll(['key', 'props']).
    • getMaxFileSize

      public abstract org.gradle.api.provider.Property<Long> getMaxFileSize()
      Largest file (bytes) that is still scanned; larger files are skipped.
    • getMaxViolationsPerFile

      public abstract org.gradle.api.provider.Property<Integer> getMaxViolationsPerFile()
      Most detailed violations to collect per file in the report; the total count is always exact.
    • getCustomLanguages

      public abstract org.gradle.api.provider.MapProperty<String,File> getCustomLanguages()
      User-supplied language files, keyed by language code.

      Each entry registers code with its JSON file, which is parsed lazily the first time that language is requested (see io.github.sergeloie.languagecheck.model.LanguageCatalog). The file's code field must match the map key. Built-in languages keep their defaults unless overridden here.

      Groovy: customLanguages = ["el": file("config/el.json")]. Kotlin: customLanguages.put("el", file("config/el.json")).

    • addCustomLanguage

      public void addCustomLanguage(String languageCode, File languageFile)
      Register a single custom language file under languageCode.

      Groovy: addCustomLanguage("el", file("config/el.json")).

    • getFailOnViolation

      public abstract org.gradle.api.provider.Property<Boolean> getFailOnViolation()
      True (default): fail the build when violations are found. False: only record them in the report.
    • getGitTimeoutSeconds

      public abstract org.gradle.api.provider.Property<Long> getGitTimeoutSeconds()
      Timeout for the git ls-files subprocess in GIT scan mode, in seconds. Defaults to 60. Large repositories may need more.
    • getReportFile

      public abstract org.gradle.api.file.RegularFileProperty getReportFile()
      Where the task writes its report file. Defaults to build/reports/languageCheck/report.txt.