Class FormatJExtension

java.lang.Object
zone.rong.formatj.gradle.FormatJExtension

public abstract class FormatJExtension extends Object
The formatJ { } block.
formatJ {
    preset = Preset.GOOGLE
    styleFile = file("formatj.toml")
    rule("indent.size", 4)
    sourceSets = listOf("main", "test")
}

Rules are addressed by the same dotted keys the style file and the CLI use, so a project can move a rule between build script and style file without translating anything.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    exclude(String... patterns)
    Adds exclude patterns.
    abstract org.gradle.api.provider.Property<Boolean>
    Whether check depends on formatJavaCheck.
    abstract org.gradle.api.provider.SetProperty<String>
    Ant-style patterns of the files to leave alone, relative to each source directory.
    abstract org.gradle.api.provider.SetProperty<String>
    Ant-style patterns of the files to format, relative to each source directory.
    abstract org.gradle.api.provider.Property<zone.rong.formatj.api.LanguageLevel>
    Syntax level to parse.
    abstract org.gradle.api.provider.Property<zone.rong.formatj.api.Preset>
    Starting point for the rules.
    abstract org.gradle.api.provider.Property<Boolean>
    Whether preview syntax is accepted.
    abstract org.gradle.api.provider.MapProperty<String,String>
    Individual rule overrides, applied last.
    abstract org.gradle.api.provider.ListProperty<String>
    Names of the source sets to format.
    abstract org.gradle.api.provider.Property<String>
    Style document applied on top of the preset, for callers that hold the text rather than a file.
    abstract org.gradle.api.file.RegularFileProperty
    A style file whose rules are applied on top of the preset.
    void
    include(String... patterns)
    Adds include patterns.
    void
    rule(String key, Object value)
    Sets one rule, validating the key against the catalogue immediately.
    void
    rules(Map<String,?> values)
    Sets several rules at once.
    void
    sourceSets(String... names)
    Convenience for sourceSets = listOf(...).

    Methods inherited from class Object

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

    • FormatJExtension

      public FormatJExtension()
  • Method Details

    • getPreset

      public abstract org.gradle.api.provider.Property<zone.rong.formatj.api.Preset> getPreset()
      Starting point for the rules. Defaults to Preset.FORMATJ.
    • getStyleFile

      public abstract org.gradle.api.file.RegularFileProperty getStyleFile()
      A style file whose rules are applied on top of the preset.
    • getStyle

      public abstract org.gradle.api.provider.Property<String> getStyle()
      Style document applied on top of the preset, for callers that hold the text rather than a file.
    • getRules

      public abstract org.gradle.api.provider.MapProperty<String,String> getRules()
      Individual rule overrides, applied last. Values are converted with the option's own parser.
    • getSourceSets

      public abstract org.gradle.api.provider.ListProperty<String> getSourceSets()
      Names of the source sets to format. Defaults to every source set in the project.
    • getIncludes

      public abstract org.gradle.api.provider.SetProperty<String> getIncludes()
      Ant-style patterns of the files to format, relative to each source directory. Defaults to every file.
    • getExcludes

      public abstract org.gradle.api.provider.SetProperty<String> getExcludes()
      Ant-style patterns of the files to leave alone, relative to each source directory.
    • getLanguageLevel

      public abstract org.gradle.api.provider.Property<zone.rong.formatj.api.LanguageLevel> getLanguageLevel()
      Syntax level to parse. Defaults to the newest FormatJ knows.
    • getPreviewFeatures

      public abstract org.gradle.api.provider.Property<Boolean> getPreviewFeatures()
      Whether preview syntax is accepted. Defaults to false.
    • getEnforceOnCheck

      public abstract org.gradle.api.provider.Property<Boolean> getEnforceOnCheck()
      Whether check depends on formatJavaCheck. Defaults to true.
    • rule

      public void rule(String key, Object value)
      Sets one rule, validating the key against the catalogue immediately.
    • rules

      public void rules(Map<String,?> values)
      Sets several rules at once.
    • sourceSets

      public void sourceSets(String... names)
      Convenience for sourceSets = listOf(...).
    • include

      public void include(String... patterns)
      Adds include patterns.
    • exclude

      public void exclude(String... patterns)
      Adds exclude patterns.