Class GradleBuildWriter
java.lang.Object
io.spring.initializr.generator.buildsystem.gradle.GradleBuildWriter
- Direct Known Subclasses:
GroovyDslGradleBuildWriter, KotlinDslGradleBuildWriter
GradleBuild writer abstraction.- Author:
- Andy Wilkinson, Stephane Nicoll, Jean-Baptiste Nizet, Moritz Halbritter
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract StringReturn the string representation of the given bom.protected StringconfigurationForDependency(Dependency dependency) Return the configuration to use for the given dependency.protected List<StandardGradlePlugin> extractStandardPlugin(GradleBuild build) Return thestandard pluginsof the build.protected Comparator<Dependency> Return theComparatorto use to sort dependencies.protected abstract StringinvocationAsString(Invocation invocation) Return the string representation of the given invocation.protected abstract StringrepositoryAsString(MavenRepository repository) Return the string representation of the given repository.protected abstract voidwriteBuildscript(IndentingWriter writer, GradleBuild build) Write thebuildscriptblock.protected final <T> voidwriteCollection(IndentingWriter writer, Collection<T> collection, Function<T, String> converter) Write each item of the given collection on its own line.protected final <T> voidwriteCollection(IndentingWriter writer, Collection<T> collection, Function<T, String> itemToStringConverter, @Nullable Runnable beforeWriting) Write each item of the given collection on its own line.protected abstract voidwriteConfigurations(IndentingWriter writer, GradleConfigurationContainer configurations) Write the configurations.protected abstract voidwriteDependency(IndentingWriter writer, Dependency dependency) Write the given dependency.protected abstract voidwriteExtraProperties(IndentingWriter writer, Map<String, String> allProperties) Write the extra properties.protected voidwriteJavaSourceCompatibility(IndentingWriter writer, GradleBuildSettings settings) Deprecated, for removal: This API element is subject to removal in a future version.for removal in favor of Gradle toolchainsprotected final <T,U> void writeMap(IndentingWriter writer, Map<T, U> map, BiFunction<T, U, String> converter) Write each entry of the given map on its own line.protected final <T> voidwriteNestedCollection(IndentingWriter writer, String name, Collection<T> collection, Function<T, String> itemToStringConverter) Write the given collection in a block with the given name.protected final <T> voidwriteNestedCollection(IndentingWriter writer, String name, Collection<T> collection, Function<T, String> converter, @Nullable Runnable beforeWriting) Write the given collection in a block with the given name.protected abstract voidwritePlugins(IndentingWriter writer, GradleBuild build) Write thepluginsblock.protected abstract voidwriteProperty(IndentingWriter writer, String name, @Nullable String value) Write the given property.protected final voidwriteRepositories(IndentingWriter writer, GradleBuild build) Write therepositoriesblock.protected final voidwriteTaskCustomization(IndentingWriter writer, GradleTask task) Write the invocations, attributes and nested customizations of the given task.protected abstract voidwriteTasks(IndentingWriter writer, GradleTaskContainer tasks) Write the task customizations.final voidwriteTo(IndentingWriter writer, GradleBuild build) Write a build.gradle using the specified writer.
-
Constructor Details
-
GradleBuildWriter
public GradleBuildWriter()
-
-
Method Details
-
writeTo
Write a build.gradle using the specified writer.- Parameters:
writer- the writer to usebuild- the gradle build to write
-
writeBuildscript
Write thebuildscriptblock.- Parameters:
writer- the writerbuild- the build
-
writePlugins
Write thepluginsblock.- Parameters:
writer- the writerbuild- the build
-
extractStandardPlugin
Return thestandard pluginsof the build.- Parameters:
build- the build- Returns:
- the standard plugins
-
writeJavaSourceCompatibility
@Deprecated(forRemoval=true) protected void writeJavaSourceCompatibility(IndentingWriter writer, GradleBuildSettings settings) Deprecated, for removal: This API element is subject to removal in a future version.for removal in favor of Gradle toolchainsWrites the source compatibility for Java.- Parameters:
writer- the writersettings- the settings
-
writeConfigurations
protected abstract void writeConfigurations(IndentingWriter writer, GradleConfigurationContainer configurations) Write the configurations.- Parameters:
writer- the writerconfigurations- the configurations
-
writeRepositories
Write therepositoriesblock.- Parameters:
writer- the writerbuild- the build
-
repositoryAsString
Return the string representation of the given repository.- Parameters:
repository- the repository- Returns:
- the repository as string
-
writeExtraProperties
protected abstract void writeExtraProperties(IndentingWriter writer, Map<String, String> allProperties) Write the extra properties.- Parameters:
writer- the writerallProperties- the properties to write
-
getDependencyComparator
Return theComparatorto use to sort dependencies.- Returns:
- a dependency comparator
-
writeDependency
Write the given dependency.- Parameters:
writer- the writerdependency- the dependency
-
configurationForDependency
Return the configuration to use for the given dependency.- Parameters:
dependency- the dependency- Returns:
- the configuration, for example
implementation
-
bomAsString
Return the string representation of the given bom.- Parameters:
bom- the bom- Returns:
- the bom as string
-
writeTasks
Write the task customizations.- Parameters:
writer- the writertasks- the tasks
-
writeTaskCustomization
Write the invocations, attributes and nested customizations of the given task.- Parameters:
writer- the writertask- the task
-
invocationAsString
Return the string representation of the given invocation.- Parameters:
invocation- the invocation- Returns:
- the invocation as string
-
writeNestedCollection
protected final <T> void writeNestedCollection(IndentingWriter writer, String name, Collection<T> collection, Function<T, String> itemToStringConverter) Write the given collection in a block with the given name. Does nothing if the collection is empty.- Type Parameters:
T- the type of the items- Parameters:
writer- the writername- the name of the blockcollection- the collectionitemToStringConverter- the converter to use for each item
-
writeNestedCollection
protected final <T> void writeNestedCollection(IndentingWriter writer, String name, Collection<T> collection, Function<T, String> converter, @Nullable Runnable beforeWriting) Write the given collection in a block with the given name. Does nothing if the collection is empty.- Type Parameters:
T- the type of the items- Parameters:
writer- the writername- the name of the blockcollection- the collectionconverter- the converter to use for each itembeforeWriting- callback to invoke before writing, ornull
-
writeCollection
protected final <T> void writeCollection(IndentingWriter writer, Collection<T> collection, Function<T, String> converter) Write each item of the given collection on its own line. Does nothing if the collection is empty.- Type Parameters:
T- the type of the items- Parameters:
writer- the writercollection- the collectionconverter- the converter to use for each item
-
writeCollection
protected final <T> void writeCollection(IndentingWriter writer, Collection<T> collection, Function<T, String> itemToStringConverter, @Nullable Runnable beforeWriting) Write each item of the given collection on its own line. Does nothing if the collection is empty.- Type Parameters:
T- the type of the items- Parameters:
writer- the writercollection- the collectionitemToStringConverter- the converter to use for each itembeforeWriting- callback to invoke before writing, ornull
-
writeMap
protected final <T,U> void writeMap(IndentingWriter writer, Map<T, U> map, BiFunction<T, U, String> converter) Write each entry of the given map on its own line.- Type Parameters:
T- the type of the keysU- the type of the values- Parameters:
writer- the writermap- the mapconverter- the converter to use for each entry
-
writeProperty
Write the given property.- Parameters:
writer- the writername- the name of the propertyvalue- the value of the property
-