The aim of this plugin is to adapt the Confluent schema registry maven plugin for Gradle builds.
See gradle plugins portal for instructions about how to add the plugin to your build configuration.
When you do so, three tasks are added under registry group:
- downloadSchemasTask
- testSchemasTask
- registerSchemasTask What these tasks do and how to configure them is described in the following sections.
Like the name of the task imply, this task is responsible of retrieving schemas from a schema registry.
A DSL is available to configure the task:
schemaRegistry {
url = 'http://localhost:8081/'
download {
subject('topic1-key', 'src/main/avro')
subject('topic1-value', 'src/main/avro/values')
}
}
You have to put the url where the script can reach the Schema Registry.
You need to specify the pairs (subjectName, outputDir) for all the schemas you want to download.
This task test compatibility between local schemas and schemas stored in the Schema Registry.
A DSL is available to specify what to test:
schemaRegistry {
url = 'http://localhost:8081'
compatibility {
subject('mySubject', 'file/path.avsc')
subject('otherSubject', 'other/path.avsc')
subject('subjectWithDependencies', 'dependent/path.avsc', ['firstDependency/path.avsc', 'secondDependency/path.avsc'])
}
}
You have to put the url where the script can reach the Schema Registry.
You have to list all the (subject, avsc file path) pairs that you want to test.
If you have dependencies with other schemas required before the compatibility check, you can add a third parameter with the needed paths.
The order of the file paths in the list is significant.
Basically you need to follow the logical order of the types used.
If an User
need an Address
record which itself needs a Street
record
you will need to define the dependencies like this:
compatibility{
subject('userSubject', 'path/user.avsc', ['path/address.avsc', 'path/street.avsc'])
}
Once again the name speaks for itself. This task register schemas from a local path to a Schema Registry.
A DSL is available to specify what to register:
schemaRegistry {
url = 'http://localhost:8081'
register {
subject('mySubject', 'file/path.avsc')
subject('otherSubject', 'other/path.avsc')
subject('subjectWithDependencies', 'dependent/path.avsc', ['firstDependency/path.avsc', 'secondDependency/path.avsc'])
}
}
You have to put the url where the script can reach the Schema Registry.
You have to list all the (subject, avsc file path) pairs that you want to send.
If you have dependencies with other schemas required before the register phase, you can add a third parameter with the needed paths.
The order of the file paths in the list is significant.
Basically you need to follow the logical order of the types used.
If an User
need an Address
record which itself needs a Street
record
you will need to define the dependencies like this:
register{
subject('userSubject', 'path/user.avsc', ['path/address.avsc', 'path/street.avsc'])
}