Package com.diffplug.gradle.spotless
Class JavaExtension
- java.lang.Object
-
- com.diffplug.gradle.spotless.FormatExtension
-
- com.diffplug.gradle.spotless.JavaExtension
-
- All Implemented Interfaces:
HasBuiltinDelimiterForLicense
public class JavaExtension extends FormatExtension implements HasBuiltinDelimiterForLicense
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classJavaExtension.CleanthatJavaConfigclassJavaExtension.EclipseConfigclassJavaExtension.FormatAnnotationsConfigclassJavaExtension.GoogleJavaFormatConfigclassJavaExtension.ImportOrderConfigclassJavaExtension.PalantirJavaFormatConfig-
Nested classes/interfaces inherited from class com.diffplug.gradle.spotless.FormatExtension
FormatExtension.BiomeGeneric, FormatExtension.ClangFormatConfig, FormatExtension.EclipseWtpConfig, FormatExtension.LicenseHeaderConfig, FormatExtension.NpmStepConfig<T extends FormatExtension.NpmStepConfig<?>>, FormatExtension.PrettierConfig, FormatExtension.RomeGeneric
-
-
Field Summary
-
Fields inherited from class com.diffplug.gradle.spotless.FormatExtension
steps, target, targetExclude, targetExcludeContentPattern
-
-
Constructor Summary
Constructors Constructor Description JavaExtension(SpotlessExtension spotless)
-
Method Summary
All Methods Instance Methods Concrete Methods Default Methods Modifier and Type Method Description JavaExtension.CleanthatJavaConfigcleanthat()Apply CleanThat refactoring rules.JavaExtension.EclipseConfigeclipse()JavaExtension.EclipseConfigeclipse(java.lang.String version)JavaExtension.FormatAnnotationsConfigformatAnnotations()Removes newlines between type annotations and types.default FileCollectiongetSources(Project project, java.lang.String message, java.util.function.Function<SourceSet,SourceDirectorySet> sourceSetSourceDirectory, Spec<? super java.io.File> filterSpec)JavaExtension.GoogleJavaFormatConfiggoogleJavaFormat()Uses the google-java-format jar to format source code.JavaExtension.GoogleJavaFormatConfiggoogleJavaFormat(java.lang.String version)Uses the given version of google-java-format to format source code.JavaExtension.ImportOrderConfigimportOrder(java.lang.String... importOrder)JavaExtension.ImportOrderConfigimportOrderFile(java.lang.Object importOrderFile)FormatExtension.LicenseHeaderConfiglicenseHeader(java.lang.String licenseHeader)FormatExtension.LicenseHeaderConfiglicenseHeaderFile(java.lang.Object licenseHeaderFile)JavaExtension.PalantirJavaFormatConfigpalantirJavaFormat()Uses the palantir-java-format jar to format source code.JavaExtension.PalantirJavaFormatConfigpalantirJavaFormat(java.lang.String version)Uses the given version of palantir-java-format to format source code.voidremoveUnusedImports()Removes any unused imports.voidremoveUnusedImports(java.lang.String formatter)protected voidsetupTask(SpotlessTask task)If the user hasn't specified the files yet, we'll assume he/she means all of the java files.-
Methods inherited from class com.diffplug.gradle.spotless.FormatExtension
addStep, addStep, biome, biome, bumpThisNumberIfACustomStepChanges, clangFormat, clangFormat, clearSteps, createIndependentApplyTask, createIndependentApplyTaskLazy, custom, custom, eclipseWtp, eclipseWtp, encoding, endWithNewline, getEncoding, getExistingStepIdx, getLineEndings, getProject, getRatchetFrom, ignoreErrorForPath, ignoreErrorForStep, indentWithSpaces, indentWithSpaces, indentWithTabs, indentWithTabs, isLicenseHeaderStep, licenseHeader, licenseHeaderFile, nativeCmd, noDefaultTargetException, parseTarget, prettier, prettier, prettier, provisioner, ratchetFrom, replace, replaceRegex, replaceStep, rome, rome, setEncoding, setEncoding, setLineEndings, setRatchetFrom, target, targetExclude, targetExcludeIfContentContains, targetExcludeIfContentContainsRegex, toggleOffOn, toggleOffOn, toggleOffOnDisable, toggleOffOnRegex, trimTrailingWhitespace, withinBlocks, withinBlocks, withinBlocksRegex, withinBlocksRegex
-
-
-
-
Constructor Detail
-
JavaExtension
@Inject public JavaExtension(SpotlessExtension spotless)
-
-
Method Detail
-
licenseHeader
public FormatExtension.LicenseHeaderConfig licenseHeader(java.lang.String licenseHeader)
- Specified by:
licenseHeaderin interfaceHasBuiltinDelimiterForLicense- Parameters:
licenseHeader- Content that should be at the top of every file.
-
licenseHeaderFile
public FormatExtension.LicenseHeaderConfig licenseHeaderFile(java.lang.Object licenseHeaderFile)
- Specified by:
licenseHeaderFilein interfaceHasBuiltinDelimiterForLicense- Parameters:
licenseHeaderFile- Content that should be at the top of every file.
-
importOrder
public JavaExtension.ImportOrderConfig importOrder(java.lang.String... importOrder)
-
importOrderFile
public JavaExtension.ImportOrderConfig importOrderFile(java.lang.Object importOrderFile)
-
removeUnusedImports
public void removeUnusedImports()
Removes any unused imports.
-
removeUnusedImports
public void removeUnusedImports(java.lang.String formatter)
-
googleJavaFormat
public JavaExtension.GoogleJavaFormatConfig googleJavaFormat()
Uses the google-java-format jar to format source code.
-
googleJavaFormat
public JavaExtension.GoogleJavaFormatConfig googleJavaFormat(java.lang.String version)
Uses the given version of google-java-format to format source code.Limited to published versions. See issue #33 for a workaround for using snapshot versions.
-
palantirJavaFormat
public JavaExtension.PalantirJavaFormatConfig palantirJavaFormat()
Uses the palantir-java-format jar to format source code.
-
palantirJavaFormat
public JavaExtension.PalantirJavaFormatConfig palantirJavaFormat(java.lang.String version)
Uses the given version of palantir-java-format to format source code.Limited to published versions. See issue #33 for a workaround for using snapshot versions.
-
eclipse
public JavaExtension.EclipseConfig eclipse()
-
eclipse
public JavaExtension.EclipseConfig eclipse(java.lang.String version)
-
formatAnnotations
public JavaExtension.FormatAnnotationsConfig formatAnnotations()
Removes newlines between type annotations and types.
-
cleanthat
public JavaExtension.CleanthatJavaConfig cleanthat()
Apply CleanThat refactoring rules.
-
setupTask
protected void setupTask(SpotlessTask task)
If the user hasn't specified the files yet, we'll assume he/she means all of the java files.- Overrides:
setupTaskin classFormatExtension
-
getSources
public default FileCollection getSources(Project project, java.lang.String message, java.util.function.Function<SourceSet,SourceDirectorySet> sourceSetSourceDirectory, Spec<? super java.io.File> filterSpec)
-
-