Class 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 the app-level build.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 in Parser. This task reads the createSql property values from the database schema file (the location of which must be specified in a source configuration property, and which is returned by getSource()), replaces the ${TABLE_NAME} and ${VIEW_NAME} placeholders, and writes properly terminated DDL SQL statements to the output file specified in the destination property (which defaults to the value of Extension.DEFAULT_DESTINATION), and returned from getDestination().

    • Constructor Detail

      • Task

        public Task()
    • Method Detail

      • extract

        public void extract()
        Parses the contents of the file referenced by the getSource() 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 by getDestination().