Class Task
- java.lang.Object
-
- org.gradle.api.internal.AbstractTask
-
- org.gradle.api.DefaultTask
-
- com.nickbenn.room.gradle.Task
-
- All Implemented Interfaces:
Comparable<Task>
,org.gradle.api.internal.DynamicObjectAware
,org.gradle.api.internal.TaskInternal
,ExtensionAware
,Task
,Configurable<Task>
public abstract class Task extends DefaultTask
Implements a Gradle task capable of extracting and replacing placeholders in DDL statements embedded in the JSON database schema files created by the Room ORM, and writing the results to a SQL script file.If the
RoomDatabase
subclass in an Android project that uses Room is configured to write a schema file (the default behavior), and a schema file location is specified in theapp
-levelbuild.gradle
file, a schema file will be written to the specific location when the database class is implemented by the Room annotation processor. In that file, the database schema is represented in a JSON object, structured as shown inParser
. This task reads thecreateSql
property values from the database schema file (the location of which must be specified in asource
configuration property, and which is returned bygetSource()
), replaces the${TABLE_NAME}
and${VIEW_NAME}
placeholders, and writes properly terminated DDL SQL statements to the output file specified in thedestination
property (which defaults to the value ofExtension.DEFAULT_DESTINATION
), and returned fromgetDestination()
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.gradle.api.Task
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 Constructor Description Task()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
extract()
Parses the contents of the file referenced by thegetSource()
return value, replaces the embedded placeholders with the appropriate table and view names, terminates each statement with the semicolon (`;`) character and two line breaks, and writes the result to the location referenced bygetDestination()
.abstract RegularFileProperty
getDestination()
Returns the value of thedestination
property.abstract RegularFileProperty
getSource()
Returns the value of the requiredsource
property.-
Methods 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, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesService
-
Methods inherited from class org.gradle.api.internal.AbstractTask
appendParallelSafeAction, doNotTrackState, getAsDynamicObject, getConvention, getIdentityPath, getImpliesSubProjects, getLifecycleDependencies, getOnlyIf, getReasonNotToTrackState, getReasonTaskIsIncompatibleWithConfigurationCache, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isCompatibleWithConfigurationCache, isEnabled, isHasCustomActions, notCompatibleWithConfigurationCache, prependParallelSafeAction, setImpliesSubProjects
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.gradle.api.Task
doNotTrackState, getConvention, notCompatibleWithConfigurationCache
-
-
-
-
Method Detail
-
getSource
@InputFile public abstract RegularFileProperty getSource()
Returns the value of the requiredsource
property.
-
getDestination
@OutputFile public abstract RegularFileProperty getDestination()
Returns the value of thedestination
property.
-
extract
public void extract()
Parses the contents of the file referenced by thegetSource()
return value, replaces the embedded placeholders with the appropriate table and view names, terminates each statement with the semicolon (`;`) character and two line breaks, and writes the result to the location referenced bygetDestination()
.
-
-