Class AnalyzeCustomPropertiesTask
java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
io.github.timoIpeters.custompropertyanalyzer.AnalyzeCustomPropertiesTask
- All Implemented Interfaces:
Comparable<org.gradle.api.Task>,org.gradle.api.internal.DynamicObjectAware,org.gradle.api.internal.TaskInternal,org.gradle.api.Named,org.gradle.api.plugins.ExtensionAware,org.gradle.api.Task,org.gradle.util.Configurable<org.gradle.api.Task>
public class AnalyzeCustomPropertiesTask
extends org.gradle.api.DefaultTask
Analyzes a Spring Boot project's Java source files to discover all custom properties
defined via
@Value and @ConfigurationProperties annotations.
The task scans all .java files in the main source set, extracts property keys
and their default values, and writes the results to a JSON report file. Default values
are resolved by consulting application.properties, application.yml, or
application.yaml in src/main/resources. Additional profile-specific
files can be included via getAdditionalPropertiesPattern().
Usage:
./gradlew analyzeCustomProperties ./gradlew analyzeCustomProperties --verbose ./gradlew analyzeCustomProperties --outputFile=my-report.json ./gradlew analyzeCustomProperties --additionalPropertiesPattern="application-*.yml"The report is written to
build/reports/custom-properties-analysis.json by default.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.gradle.api.Task
org.gradle.api.Task.Namer -
Field Summary
Fields inherited from interface org.gradle.api.Task
TASK_ACTION, TASK_CONSTRUCTOR_ARGS, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidanalyze()Task action that drives the full property analysis.Glob pattern for additional property files to include in default value resolution, beyond the baselineapplication.properties,application.yml, andapplication.yaml.The name of the generated JSON report file.org.gradle.api.provider.Provider<org.gradle.api.file.RegularFile>The output file to which the JSON property report is written.booleanWhether to print the full analysis results to the console in addition to the JSON report.voidsetAdditionalPropertiesPattern(String additionalPropertiesPattern) Option to set an additional properties glob patternvoidsetOutputFile(String outputFile) Option to set a custom output filevoidsetVerboseMode(boolean verboseMode) Option to enable/disable verbose modeMethods inherited from class org.gradle.api.DefaultTask
compareTo, configure, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, finalizedBy, getActions, getAnt, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExtensions, getFinalizedBy, getGroup, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOutputs, getPath, getProject, getShouldRunAfter, getState, getTaskDependencies, getTemporaryDir, getTimeout, hasProperty, mustRunAfter, onlyIf, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesServiceMethods inherited from class org.gradle.api.internal.AbstractTask
acceptServiceReferences, appendParallelSafeAction, doNotTrackState, getAsDynamicObject, getConvention, getIdentityPath, getImpliesSubProjects, getLifecycleDependencies, getOnlyIf, getReasonNotToTrackState, getReasonTaskIsIncompatibleWithConfigurationCache, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isCompatibleWithConfigurationCache, isEnabled, isHasCustomActions, notCompatibleWithConfigurationCache, prependParallelSafeAction, setImpliesSubProjectsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.gradle.api.Task
doNotTrackState, getConvention, notCompatibleWithConfigurationCache
-
Constructor Details
-
AnalyzeCustomPropertiesTask
public AnalyzeCustomPropertiesTask()
-
-
Method Details
-
getOutputFile
The name of the generated JSON report file.The file is written to
build/reports/<outputFile>. Defaults tocustom-properties-analysis.json.- Returns:
- The output file name
-
getAdditionalPropertiesPattern
Glob pattern for additional property files to include in default value resolution, beyond the baselineapplication.properties,application.yml, andapplication.yaml.Example values:
application-dev.properties- exact file nameapplication-dev*.properties- all dev variant filesapplication-*.yml- all profile-specific YAML files
- Returns:
- The additional properties glob pattern
-
getVerboseMode
@Input public boolean getVerboseMode()Whether to print the full analysis results to the console in addition to the JSON report. Defaults tofalse.- Returns:
- True if verbose mode is enabled, otherwise false
-
setOutputFile
Option to set a custom output file- Parameters:
outputFile- The name of the generated JSON report file
-
setAdditionalPropertiesPattern
Option to set an additional properties glob pattern- Parameters:
additionalPropertiesPattern- Glob pattern for additional .properties files to include in default value analysis (e.g. 'application-dev*.properties')
-
setVerboseMode
public void setVerboseMode(boolean verboseMode) Option to enable/disable verbose mode- Parameters:
verboseMode- Enable verbose console output
-
getReportFile
@OutputFile public org.gradle.api.provider.Provider<org.gradle.api.file.RegularFile> getReportFile()The output file to which the JSON property report is written. Resolved tobuild/reports/<outputFile>.- Returns:
- The output file provider, the JSON property is written to
-
analyze
public void analyze()Task action that drives the full property analysis.
-