Repository: ImFlog/schema-registry-plugin
Pull request #124 (2023-04-03 21:06:53)

Bump io.confluent:kafka-schema-registry-parent from 7.3.1 to 7.3.3
Bumps [io.confluent:kafka-schema-registry-parent](https://github.com/confluentinc/schema-registry) from 7.3.1 to 7.3.3.
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/confluentinc/schema-registry/commit/60f2c10262c071035f11c8d6b2c09c1a5a0bdee3"><code>60f2c10</code></a> Set Confluent to 7.3.3, Kafka to 7.3.3.</li>
<li><a href="https://github.com/confluentinc/schema-registry/commit/d5e833556fd9cb6fc17151f7110c1f8445600ded"><code>d5e8335</code></a> Reset default for leader election delay to false (<a href="https://redirect.github.com/confluentinc/schema-registry/issues/2582">#2582</a>)</li>
<li><a href="https://github.com/confluentinc/schema-registry/commit/ba69f1a959e88203e88e0ff5232265baccdb5333"><code>ba69f1a</code></a> Merge branch '7.2.x' into 7.3.x</li>
<li><a href="https://github.com/confluentinc/schema-registry/commit/330685206fe95647b9ddd578aaebb2f223258605"><code>3306852</code></a> Merge branch '7.1.x' into 7.2.x</li>
<li><a href="https://github.com/confluentinc/schema-registry/commit/e045089ae7bfae770445222c0e03d7dfca2392fa"><code>e045089</code></a> Merge branch '7.0.x' into 7.1.x</li>
<li><a href="https://github.com/confluentinc/schema-registry/commit/b04f05e31380edf425dd6bad407e8f6d0b2c3834"><code>b04f05e</code></a> DGS-6373 Ignore leading dot when merging Protobuf custom options (<a href="https://redirect.github.com/confluentinc/schema-registry/issues/2577">#2577</a>)</li>
<li><a href="https://github.com/confluentinc/schema-registry/commit/5fd538025bcaff7f60be971c77fb924fcc06f930"><code>5fd5380</code></a> Merge branch '7.2.x' into 7.3.x</li>
<li><a href="https://github.com/confluentinc/schema-registry/commit/95313fe44f60f60ee56735529863c80055df9b0f"><code>95313fe</code></a> Merge branch '7.1.x' into 7.2.x</li>
<li><a href="https://github.com/confluentinc/schema-registry/commit/ba94729879405b21379b4a736f5f28f75d73aff3"><code>ba94729</code></a> Merge branch '7.0.x' into 7.1.x</li>
<li><a href="https://github.com/confluentinc/schema-registry/commit/eab6ead937724fe28f58dc982320d4eb30506f57"><code>eab6ead</code></a> Merge branch '6.2.x' into 7.0.x</li>
<li>Additional commits viewable in <a href="https://github.com/confluentinc/schema-registry/compare/v7.3.1...v7.3.3">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=io.confluent:kafka-schema-registry-parent&package-manager=gradle&previous-version=7.3.1&new-version=7.3.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>


Patch:
diff --git a/README.md b/README.md
index 0f1d0cf..23681cf 100644
--- a/README.md
+++ b/README.md
@@ -132,6 +132,22 @@ 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.
 
+Notes:
+* If you want to reuse Subjects with the register task you can define a `Subject` object like so:
+  ```groovy
+  def mySubject = Subject("avroSubject", "/path.avsc", "AVRO")
+  
+  schemaRegistry {
+    url = 'http://registry-url:8081'
+    register {
+      subject(mySubject)
+    }
+    compatibility {
+      subject(mySubject)
+    }
+  }
+  ```
+
 #### Avro
 Mixing local and remote references is perfectly fine for Avro without specific configurations.
 
@@ -163,8 +179,6 @@ schemaRegistry {
     }
 }
 ```
-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.
@@ -174,8 +188,23 @@ 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.
 
-A registered.csv file will be created with the following format `subject, path, id` 
+Notes:
+* A registered.csv file will be created with the following format `subject, path, id` 
 if you need information about the registered id.
+* If you want to reuse Subjects with the compatibility task you can define a `Subject` object like so:
+  ```groovy
+  def mySubject = Subject("avroSubject", "/path.avsc", "AVRO")
+  
+  schemaRegistry {
+    url = 'http://registry-url:8081'
+    register {
+      subject(mySubject)
+    }
+    compatibility {
+      subject(mySubject)
+    }
+  }
+  ```
 
 #### Avro
 Mixing local and remote references is perfectly fine for Avro without specific configurations.
@@ -294,6 +323,8 @@ buildscript {
         classpath "com.github.imflog:kafka-schema-registry-gradle-plugin:X.X.X-SNAPSHOT"
     }
 }
+
+apply plugin: "com.github.imflog.kafka-schema-registry-gradle-plugin"
 ```
 
 ## Thanks to all the sponsors :pray:
diff --git a/build.gradle.kts b/build.gradle.kts
index a7089c1..4c55699 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -7,7 +7,7 @@ version = "1.9.2-SNAPSHOT"
 plugins {
     kotlin("jvm") version "1.8.20"
     id("java-gradle-plugin")
-    id("com.gradle.plugin-publish") version "1.1.0"
+    id("com.gradle.plugin-publish") version "1.2.0"
     id("maven-publish")
 }
 
@@ -18,7 +18,7 @@ repositories {
 
 // Dependencies versions
 val kotlinVersion = "1.8.20"
-val confluentVersion = "7.3.1"
+val confluentVersion = "7.3.3"
 dependencies {
     implementation(gradleApi())
     implementation(kotlin("stdlib", kotlinVersion))
diff --git a/examples/avro/build.gradle b/examples/avro/build.gradle
index 33b8abf..4df868f 100644
--- a/examples/avro/build.gradle
+++ b/examples/avro/build.gradle
@@ -1,6 +1,10 @@
 plugins {
     id "com.github.imflog.kafka-schema-registry-gradle-plugin"
 }
+import com.github.imflog.schema.registry.Subject
+
+Subject locationAddressSubject = new Subject('location-address', 'schemas/avro/location-address.avsc', 'AVRO')
+Subject locationCoordSubject = new Subject('location-latlong', 'schemas/avro/location-latlong.avsc', 'AVRO')
 
 schemaRegistry {
     url = 'http://localhost:8081'
@@ -12,8 +16,8 @@ schemaRegistry {
                 .addLocalReference("Address", "schemas/avro/location-address.avsc")
         subject('user', 'schemas/avro/user.avsc', 'AVRO')
                 .addReference('company', 'company', -1)
-        subject('location-address', 'schemas/avro/location-address.avsc', 'AVRO')
-        subject('location-latlong', 'schemas/avro/location-latlong.avsc', 'AVRO')
+        subject(locationAddressSubject)
+        subject(locationCoordSubject)
     }
 
     config {
@@ -34,7 +38,7 @@ schemaRegistry {
                 .addLocalReference("Address", "schemas/avro/location-address.avsc")
         subject('user', 'schemas/avro/user.avsc', 'AVRO')
                 .addReference('company', 'company', -1)
-        subject('location-address', 'schemas/avro/location-address.avsc', 'AVRO')
-        subject('location-latlong', 'schemas/avro/location-latlong.avsc', 'AVRO')
+        subject(locationAddressSubject)
+        subject(locationCoordSubject)
     }
 }
diff --git a/examples/build.gradle.kts b/examples/build.gradle.kts
index f5f1dd5..5f904a4 100644
--- a/examples/build.gradle.kts
+++ b/examples/build.gradle.kts
@@ -1,15 +1,18 @@
 buildscript {
     repositories {
         gradlePluginPortal()
+        mavenLocal()
         maven {
             url = uri("https://packages.confluent.io/maven/")
         }
     }
+
+    dependencies {
+        classpath("com.github.imflog:kafka-schema-registry-gradle-plugin:1.9.2-SNAPSHOT")
+    }
 }
 
 plugins {
-    // Set it to false to let subproject apply the plugin
-    id("com.github.imflog.kafka-schema-registry-gradle-plugin") version "1.9.1" apply false
     id("com.avast.gradle.docker-compose") version "0.16.8" apply true
 }
 
diff --git a/examples/json/build.gradle b/examples/json/build.gradle
index e3464f4..9b1c1f3 100644
--- a/examples/json/build.gradle
+++ b/examples/json/build.gradle
@@ -2,6 +2,11 @@ plugins {
     id "com.github.imflog.kafka-schema-registry-gradle-plugin"
 }
 
+import com.github.imflog.schema.registry.Subject
+
+Subject locationAddressSubject = new Subject('location-address', 'schemas/json/location-address.json', 'JSON')
+Subject locationCoordSubject = new Subject('location-latlong', 'schemas/json/location-latlong.json', 'JSON')
+
 schemaRegistry {
     url = 'http://localhost:8081'
     quiet = false
@@ -12,8 +17,8 @@ schemaRegistry {
             .addLocalReference('Address', 'schemas/json/location-address.json')
         subject('user', 'schemas/json/user.json', 'JSON')
             .addReference('company', 'company', -1)
-        subject('location-address', 'schemas/json/location-address.json', 'JSON')
-        subject('location-latlong', 'schemas/json/location-latlong.json', 'JSON')
+        subject(locationAddressSubject)
+        subject(locationCoordSubject)
     }
 
     config {
@@ -34,7 +39,7 @@ schemaRegistry {
             .addLocalReference("address", "schemas/json/location-address.json")
         subject('user', 'schemas/json/user.json', 'JSON')
             .addReference('company', 'company', -1)
-        subject('location-address', 'schemas/json/location-address.json', 'JSON')
-        subject('location-latlong', 'schemas/json/location-latlong.json', 'JSON')
+        subject(locationAddressSubject)
+        subject(locationCoordSubject)
     }
 }
diff --git a/examples/protobuf/build.gradle b/examples/protobuf/build.gradle
index ddcc730..548a1ed 100644
--- a/examples/protobuf/build.gradle
+++ b/examples/protobuf/build.gradle
@@ -2,6 +2,11 @@ plugins {
     id "com.github.imflog.kafka-schema-registry-gradle-plugin"
 }
 
+import com.github.imflog.schema.registry.Subject
+
+Subject locationAddressSubject = new Subject('location-address', 'schemas/protobuf/com/example/location-address.proto', 'PROTOBUF')
+Subject locationCoordSubject = new Subject('location-latlong', 'schemas/protobuf/com/example/location-latlong.proto', 'PROTOBUF')
+
 schemaRegistry {
     url = 'http://localhost:8081'
     quiet = false
@@ -11,8 +16,8 @@ schemaRegistry {
         subject('company', 'schemas/protobuf/com/example/company.proto', 'PROTOBUF')
         subject('user', 'schemas/protobuf/com/example/user.proto', 'PROTOBUF')
             .addReference('company', 'company', 1)
-        subject('location-address', 'schemas/protobuf/com/example/location-address.proto', 'PROTOBUF')
-        subject('location-latlong', 'schemas/protobuf/com/example/location-latlong.proto', 'PROTOBUF')
+        subject(locationAddressSubject)
+        subject(locationCoordSubject)
     }
 
     config {
@@ -32,7 +37,7 @@ schemaRegistry {
         subject('company', 'schemas/protobuf/com/example/company_v2.proto', 'PROTOBUF')
         subject('user', 'schemas/protobuf/com/example/user.proto', 'PROTOBUF')
             .addReference('company', 'company', 1)
-        subject('location-address', 'schemas/protobuf/com/example/location-address.proto', 'PROTOBUF')
-        subject('location-latlong', 'schemas/protobuf/com/example/location-latlong.proto', 'PROTOBUF')
+        subject(locationAddressSubject)
+        subject(locationCoordSubject)
     }
 }
diff --git a/src/main/kotlin/com/github/imflog/schema/registry/Subject.kt b/src/main/kotlin/com/github/imflog/schema/registry/Subject.kt
new file mode 100644
index 0000000..f6038a4
--- /dev/null
+++ b/src/main/kotlin/com/github/imflog/schema/registry/Subject.kt
@@ -0,0 +1,26 @@
+package com.github.imflog.schema.registry
+
+import io.confluent.kafka.schemaregistry.client.rest.entities.SchemaReference
+
+data class Subject(
+    val inputSubject: String,
+    val file: String,
+    val type: String
+) {
+    val references: MutableList<SchemaReference> = mutableListOf()
+    val localReferences: MutableList<LocalReference> = mutableListOf()
+
+    fun addReference(name: String, subject: String, version: Int): Subject {
+        references.add(SchemaReference(name, subject, version))
+        return this
+    }
+
+    fun addLocalReference(name: String, path: String): Subject {
+        localReferences.add(LocalReference(name, path))
+        return this
+    }
+
+    // Used for data class destructuring
+    operator fun component4() = references
+    operator fun component5() = localReferences
+}
\ No newline at end of file
diff --git a/src/main/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilitySubjectExtension.kt b/src/main/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilitySubjectExtension.kt
index 43d503f..9a82de8 100644
--- a/src/main/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilitySubjectExtension.kt
+++ b/src/main/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilitySubjectExtension.kt
@@ -1,10 +1,8 @@
 package com.github.imflog.schema.registry.tasks.compatibility
 
-import com.github.imflog.schema.registry.LocalReference
-import com.github.imflog.schema.registry.SchemaType
+import com.github.imflog.schema.registry.Subject
 import com.github.imflog.schema.registry.toSchemaType
 import io.confluent.kafka.schemaregistry.avro.AvroSchema
-import io.confluent.kafka.schemaregistry.client.rest.entities.SchemaReference
 import org.gradle.api.model.ObjectFactory
 import org.gradle.api.provider.ListProperty
 
@@ -13,7 +11,7 @@ open class CompatibilitySubjectExtension(objects: ObjectFactory) {
         const val EXTENSION_NAME = "compatibility"
     }
 
-    val subjects: ListProperty<CompatibilitySubject> = objects.listProperty(CompatibilitySubject::class.java)
+    val subjects: ListProperty<Subject> = objects.listProperty(Subject::class.java)
 
     fun subject(inputSubject: String, file: String) = subject(inputSubject, file, AvroSchema.TYPE)
 
@@ -21,27 +19,11 @@ open class CompatibilitySubjectExtension(objects: ObjectFactory) {
         inputSubject: String,
         file: String,
         type: String
-    ): CompatibilitySubject {
-        val compatibilitySubject = CompatibilitySubject(inputSubject, file, type.toSchemaType())
+    ): Subject {
+        val compatibilitySubject = Subject(inputSubject, file, type)
         subjects.add(compatibilitySubject)
         return compatibilitySubject
     }
-}
-
-data class CompatibilitySubject(
-    val inputSubject: String,
-    val file: String,
-    val type: SchemaType,
-    val references: MutableList<SchemaReference> = mutableListOf(),
-    val localReferences: MutableList<LocalReference> = mutableListOf()
-) {
-    fun addReference(name: String, subject: String, version: Int): CompatibilitySubject {
-        references.add(SchemaReference(name, subject, version))
-        return this
-    }
 
-    fun addLocalReference(name: String, path: String): CompatibilitySubject {
-        localReferences.add(LocalReference(name, path))
-        return this
-    }
+    fun subject(subject: Subject) = subject.apply { subjects.add(subject) }
 }
diff --git a/src/main/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilityTask.kt b/src/main/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilityTask.kt
index b845dab..9be3dcb 100644
--- a/src/main/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilityTask.kt
+++ b/src/main/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilityTask.kt
@@ -1,6 +1,7 @@
 package com.github.imflog.schema.registry.tasks.compatibility
 
 import com.github.imflog.schema.registry.RegistryClientWrapper
+import com.github.imflog.schema.registry.Subject
 import org.gradle.api.DefaultTask
 import org.gradle.api.GradleScriptException
 import org.gradle.api.model.ObjectFactory
@@ -32,7 +33,7 @@ open class CompatibilityTask @Inject constructor(objects: ObjectFactory) : Defau
     val ssl: MapProperty<String, String> = objects.mapProperty(String::class.java, String::class.java)
 
     @Input
-    val subjects: ListProperty<CompatibilitySubject> = objects.listProperty(CompatibilitySubject::class.java)
+    val subjects: ListProperty<Subject> = objects.listProperty(Subject::class.java)
 
     @TaskAction
     fun testCompatibility() {
diff --git a/src/main/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilityTaskAction.kt b/src/main/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilityTaskAction.kt
index c5ff65f..ac65915 100644
--- a/src/main/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilityTaskAction.kt
+++ b/src/main/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilityTaskAction.kt
@@ -1,7 +1,9 @@
 package com.github.imflog.schema.registry.tasks.compatibility
 
 import com.github.imflog.schema.registry.LoggingUtils.infoIfNotQuiet
+import com.github.imflog.schema.registry.Subject
 import com.github.imflog.schema.registry.parser.SchemaParser
+import com.github.imflog.schema.registry.toSchemaType
 import io.confluent.kafka.schemaregistry.client.SchemaRegistryClient
 import io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException
 import io.confluent.kafka.schemaregistry.rest.exceptions.Errors
@@ -12,7 +14,7 @@ import java.io.IOException
 class CompatibilityTaskAction(
     private val client: SchemaRegistryClient,
     private val rootDir: File,
-    private val subjects: List<CompatibilitySubject>,
+    private val subjects: List<Subject>,
 ) {
 
     private val logger = Logging.getLogger(CompatibilityTaskAction::class.java)
@@ -23,7 +25,7 @@ class CompatibilityTaskAction(
             logger.debug("Loading schema for subject($subject) from $path.")
             val isCompatible = try {
                 val parsedSchema = SchemaParser
-                    .provide(type, client, rootDir)
+                    .provide(type.toSchemaType(), client, rootDir)
                     .parseSchemaFromFile(
                         subject,
                         path,
diff --git a/src/main/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterSchemasTask.kt b/src/main/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterSchemasTask.kt
index b7ae4f7..c6830ee 100644
--- a/src/main/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterSchemasTask.kt
+++ b/src/main/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterSchemasTask.kt
@@ -1,6 +1,7 @@
 package com.github.imflog.schema.registry.tasks.register
 
 import com.github.imflog.schema.registry.RegistryClientWrapper
+import com.github.imflog.schema.registry.Subject
 import org.gradle.api.DefaultTask
 import org.gradle.api.GradleScriptException
 import org.gradle.api.model.ObjectFactory
@@ -33,7 +34,7 @@ abstract class RegisterSchemasTask @Inject constructor(objects: ObjectFactory) :
     val ssl: MapProperty<String, String> = objects.mapProperty(String::class.java, String::class.java)
 
     @Input
-    val subjects: ListProperty<RegisterSubject> = objects.listProperty(RegisterSubject::class.java)
+    val subjects: ListProperty<Subject> = objects.listProperty(Subject::class.java)
 
     @Input
     @Optional
diff --git a/src/main/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterSubjectExtension.kt b/src/main/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterSubjectExtension.kt
index 3367c99..43b2c77 100644
--- a/src/main/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterSubjectExtension.kt
+++ b/src/main/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterSubjectExtension.kt
@@ -1,11 +1,8 @@
 package com.github.imflog.schema.registry.tasks.register
 
-import com.github.imflog.schema.registry.LocalReference
-import com.github.imflog.schema.registry.MixedReferenceException
-import com.github.imflog.schema.registry.SchemaType
+import com.github.imflog.schema.registry.Subject
 import com.github.imflog.schema.registry.toSchemaType
 import io.confluent.kafka.schemaregistry.avro.AvroSchema
-import io.confluent.kafka.schemaregistry.client.rest.entities.SchemaReference
 import org.gradle.api.model.ObjectFactory
 import org.gradle.api.provider.ListProperty
 
@@ -14,7 +11,7 @@ open class RegisterSubjectExtension(objects: ObjectFactory) {
         const val EXTENSION_NAME = "register"
     }
 
-    val subjects: ListProperty<RegisterSubject> = objects.listProperty(RegisterSubject::class.java)
+    val subjects: ListProperty<Subject> = objects.listProperty(Subject::class.java)
 
     fun subject(inputSubject: String, file: String) = subject(inputSubject, file, AvroSchema.TYPE)
 
@@ -22,27 +19,11 @@ open class RegisterSubjectExtension(objects: ObjectFactory) {
         inputSubject: String,
         file: String,
         type: String
-    ): RegisterSubject {
-        val subject = RegisterSubject(inputSubject, file, type.toSchemaType())
+    ): Subject {
+        val subject = Subject(inputSubject, file, type)
         subjects.add(subject)
         return subject
     }
-}
-
-data class RegisterSubject(
-    val inputSubject: String,
-    val file: String,
-    val type: SchemaType,
-    val references: MutableList<SchemaReference> = mutableListOf(),
-    val localReferences: MutableList<LocalReference> = mutableListOf()
-) {
-    fun addReference(name: String, subject: String, version: Int): RegisterSubject {
-        references.add(SchemaReference(name, subject, version))
-        return this
-    }
 
-    fun addLocalReference(name: String, path: String): RegisterSubject {
-        localReferences.add(LocalReference(name, path))
-        return this
-    }
+    fun subject(subject: Subject) = subject.apply { subjects.add(subject) }
 }
diff --git a/src/main/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterTaskAction.kt b/src/main/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterTaskAction.kt
index a53e0a8..48bdd49 100644
--- a/src/main/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterTaskAction.kt
+++ b/src/main/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterTaskAction.kt
@@ -3,7 +3,9 @@ package com.github.imflog.schema.registry.tasks.register
 import com.github.imflog.schema.registry.LocalReference
 import com.github.imflog.schema.registry.LoggingUtils.infoIfNotQuiet
 import com.github.imflog.schema.registry.SchemaType
+import com.github.imflog.schema.registry.Subject
 import com.github.imflog.schema.registry.parser.SchemaParser
+import com.github.imflog.schema.registry.toSchemaType
 import io.confluent.kafka.schemaregistry.client.SchemaRegistryClient
 import io.confluent.kafka.schemaregistry.client.rest.entities.SchemaReference
 import org.gradle.api.logging.Logging
@@ -13,7 +15,7 @@ import java.io.File
 class RegisterTaskAction(
     private val client: SchemaRegistryClient,
     private val rootDir: File,
-    private val subjects: List<RegisterSubject>,
+    private val subjects: List<Subject>,
     outputDir: String?
 ) {
 
@@ -27,7 +29,7 @@ class RegisterTaskAction(
         writeOutputFileHeader()
         subjects.forEach { (subject, path, type, references, localReferences) ->
             try {
-                val schemaId = registerSchema(subject, path, type, references, localReferences)
+                val schemaId = registerSchema(subject, path, type.toSchemaType(), references, localReferences)
                 writeRegisteredSchemaOutput(subject, path, schemaId)
             } catch (e: Exception) {
                 logger.error("Could not register schema for '$subject'", e)


Test patch:
diff --git a/src/test/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilityTaskActionTest.kt b/src/test/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilityTaskActionTest.kt
index 66e06ba..fd4aefd 100644
--- a/src/test/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilityTaskActionTest.kt
+++ b/src/test/kotlin/com/github/imflog/schema/registry/tasks/compatibility/CompatibilityTaskActionTest.kt
@@ -1,6 +1,6 @@
 package com.github.imflog.schema.registry.tasks.compatibility
 
-import com.github.imflog.schema.registry.SchemaType
+import com.github.imflog.schema.registry.Subject
 import io.confluent.kafka.schemaregistry.ParsedSchema
 import io.confluent.kafka.schemaregistry.avro.AvroSchema
 import io.confluent.kafka.schemaregistry.client.MockSchemaRegistryClient
@@ -52,7 +52,7 @@ class CompatibilityTaskActionTest {
         folderRule.newFolder("src", "main", "avro", "external")
 
         val subjects =
-            arrayListOf(CompatibilitySubject("test", "src/main/avro/external/test.avsc", SchemaType.AVRO))
+            arrayListOf(Subject("test", "src/main/avro/external/test.avsc", "AVRO"))
         File(folderRule.root, "src/main/avro/external/test.avsc").writeText(
             """
             {"type": "record",
@@ -141,10 +141,10 @@ class CompatibilityTaskActionTest {
         )
 
         val subjects = listOf(
-            CompatibilitySubject(
+            Subject(
                 "test",
                 "src/main/avro/external/test.avsc",
-                SchemaType.AVRO
+                "AVRO"
             )
                 .addReference("Address", "Address", 1)
                 .addReference("Street", "Street", 1)
@@ -239,10 +239,10 @@ class CompatibilityTaskActionTest {
         )
 
         val subjects = listOf(
-            CompatibilitySubject(
+            Subject(
                 "test",
                 "src/main/avro/local/test.avsc",
-                SchemaType.AVRO
+                "AVRO"
             )
                 .addReference("Street", "Street", 1)
                 .addLocalReference("Country", "src/main/avro/local/country.avsc")
@@ -281,7 +281,7 @@ class CompatibilityTaskActionTest {
         folderRule.newFolder("src", "main", "avro", "external")
 
         val subjects =
-            arrayListOf(CompatibilitySubject("test", "src/main/avro/external/test.avsc", SchemaType.AVRO))
+            arrayListOf(Subject("test", "src/main/avro/external/test.avsc", "AVRO"))
         File(folderRule.root, "src/main/avro/external/test.avsc").writeText(
             """
             {"type": "record",
@@ -316,10 +316,10 @@ class CompatibilityTaskActionTest {
         folderRule.newFolder("src", "main", "avro", "external")
 
         val subjects = listOf(
-            CompatibilitySubject(
+            Subject(
                 "test",
                 "src/main/avro/external/test.avsc",
-                SchemaType.AVRO
+                "AVRO"
             )
         )
         File(folderRule.root, "src/main/avro/external/test.avsc").writeText(
diff --git a/src/test/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterTaskActionTest.kt b/src/test/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterTaskActionTest.kt
index a0d6c88..0ae6884 100644
--- a/src/test/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterTaskActionTest.kt
+++ b/src/test/kotlin/com/github/imflog/schema/registry/tasks/register/RegisterTaskActionTest.kt
@@ -1,6 +1,6 @@
 package com.github.imflog.schema.registry.tasks.register
 
-import com.github.imflog.schema.registry.SchemaType
+import com.github.imflog.schema.registry.Subject
 import io.confluent.kafka.schemaregistry.avro.AvroSchema
 import io.confluent.kafka.schemaregistry.avro.AvroSchemaProvider
 import io.confluent.kafka.schemaregistry.client.MockSchemaRegistryClient
@@ -47,7 +47,7 @@ class RegisterTaskActionTest {
         )
 
         val subjects = listOf(
-            RegisterSubject("test", "src/main/avro/external/test.avsc", SchemaType.AVRO)
+            Subject("test", "src/main/avro/external/test.avsc", "AVRO")
         )
 
         // when
@@ -91,10 +91,10 @@ class RegisterTaskActionTest {
         )
 
         val subjects = listOf(
-            RegisterSubject(
+            Subject(
                 "test",
                 "src/main/avro/external/test.avsc",
-                SchemaType.AVRO
+                "AVRO"
             )
         )
 
@@ -174,10 +174,10 @@ class RegisterTaskActionTest {
 
 
         val subjects = listOf(
-            RegisterSubject(
+            Subject(
                 "test",
                 "src/main/avro/external/test.avsc",
-                SchemaType.AVRO
+                "AVRO"
             )
                 .addReference("Address", "Address", 1)
                 .addReference("Street", "Street", 1)
@@ -229,8 +229,8 @@ class RegisterTaskActionTest {
             )
 
         val subjects = listOf(
-            RegisterSubject("test", "src/main/avro/external/test.avsc", SchemaType.AVRO),
-            RegisterSubject("test_2", "src/main/avro/external/test_2.avsc", SchemaType.AVRO),
+            Subject("test", "src/main/avro/external/test.avsc", "AVRO"),
+            Subject("test_2", "src/main/avro/external/test_2.avsc", "AVRO"),
         )
 
         // when