Data Schemas in Gradle projects
In Gradle projects, the Kotlin DataFrame library provides
Annotation processing for generation of extension properties
Annotation processing for
DataSchemainference from datasets.Gradle task for
DataSchemainference from datasets.
Configuration
To use the extension properties API in Gradle project add the dataframe plugin as follows:
Annotation processing
Declare data schemas in your code and use them to access data in DataFrame objects. A data schema is a class or interface annotated with @DataSchema:
Execute the assemble task to generate type-safe accessors for schemas:
Schema inference
Specify schema with preferred method and execute the assemble task.
@ImportDataSchema annotation must be above package directive. You can import schemas from a URL or from the relative path of a file. Relative path by default is resolved to the project root directory. You can configure it by passing dataframe.resolutionDir option to preprocessor. For example:
Note that due to incremental processing, imported schema will be re-generated only if some source code has changed from the previous invocation, at least one character.
For the following configuration, file Repository.Generated.kt will be generated to build/generated/ksp/ folder in the same package as file containing the annotation.
See KDocs for @ImportDataSchema in IDE or GitHub for more details.
Put this in build.gradle or build.gradle.kts For the following configuration, file Repository.Generated.kt will be generated to build/generated/dataframe/org/example folder.
After assemble, the following code should compile and run: