url is where the script can reach the Schema Registry.
quiet is whether you want to disable "INFO" level logs.
This can be useful if you test the compatibility of a lot of schema.
Could be removed if gradle/gradle#1010 is fixed.
Download schemas
Like the name of the task imply, this task is responsible for retrieving schemas from a schema registry.
A DSL is available to configure the task:
schemaRegistry {
url ='http://registry-url:8081/'
download {
// extension of the output file depends on the the schema type
subject('avroSubject', '/absolutPath/src/main/avro')
subject('protoSubject', 'src/main/proto')
subject('jsonSubject', 'src/main/json')
// You can use a regex to download multiple schemas at once
subjectPattern('avro.*', 'src/main/avro')
}
}
Here is the list of all the signatures for the subject extension:
You have to list all the (subject, avsc file path) pairs that you want to test.
If you have references with other schemas stored in the registry that are required before the compatibility check,
you can call the addReference("name", "subject", version), this will add a reference to fetch dynamically from the registry.
The addReference calls can be chained.
If you have local references to add before calling the compatibility in the registry,
you can call the addLocalReference("name", "/a/path"),
this will add a reference from a local file and inline it in the schema registry call.
The addLocalReference calls can be chained.
⚠️ For now you cannot mix local and remote reference (parse order issues).
⚠️ The local reference is not yet supported for JSON and PROTOBUF.
Register schemas
Once again the name speaks for itself.
This task register schemas from a local path to a Schema Registry.
You have to list all the (subject, avsc file path) pairs that you want to send.
If you have references to other schemas required before the register,
you can call the addReference("name", "subject", version), this will add a reference to use from the registry.
The addReference calls can be chained.
If you have local references to add before calling the register,
you can call the addLocalReference("name", "/a/path"),
this will add a reference from a local file and inline it in the schema registry call.
The addLocalReference calls can be chained.
⚠️ For now you cannot mix local and remote reference (parse order issues).
⚠️ The local reference is not yet supported for JSON and PROTOBUF.
Configure subjects
This task sets the schema compatibility level for registered subjects.
A DSL is available to specify which subjects to configure:
See the examples directory to see the plugin in action !
Version compatibility
When using the plugin, a default version of the confluent Schema registry is use.
The 5.5.X version of the schema-registry introduced changes that made the older version of the plugin obsolete.
It was easier to introduce all the changes in one shot instead of supporting both version. Here is what it implies for users:
plugin versions above 1.X.X support the confluent version > 5.5.X (Avro / Json / Protobuf)
plugin versions should support anything below 5.4.X
We are not strictly following confluent version so if you need to change the confluent version for some reason,
take a look at examples/override-confluent-version.
Developing
In order to build the plugin locally, you can run the following commands:
./gradlew build # To compile and test the code
./gradlew publishToMavenLocal # To push the plugin to your mavenLocal
Once the plugin is pushed into your mavenLocal, you can use it by
adding the mavenLocal to the buildscript repositories like so:
buildscript {
repositories {
// The new repository to import, you may not want this in your final gradle configuration.
mavenLocal()
maven {
url "http://packages.confluent.io/maven/"
}
}
dependencies {
classpath "com.github.imflog:kafka-schema-registry-gradle-plugin:X.X.X-SNAPSHOT"
}
}
请发表评论