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
    abstract org.gradle.api.provider.Property<Boolean>
    Whether check depends on formatJavaCheck.
    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.file.RegularFileProperty
    A style file whose rules are applied on top of the preset.
    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.
    • 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.
    • 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(...).