File tree Expand file tree Collapse file tree 3 files changed +12
-2
lines changed
plugin/src/main/kotlin/io/github/androa/gradle/plugin/avro Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,12 @@ abstract class AvroExtension
2626 */
2727 abstract val outputDir: DirectoryProperty
2828
29+ /* *
30+ * Directory where intermediate files will be placed.
31+ * Default: build/intermediates/avro
32+ */
33+ abstract val intermediateDir: DirectoryProperty
34+
2935 /* *
3036 * Set the encoding of the output files.
3137 * Possible values: UTF-8, UTF-16, etc.
@@ -79,6 +85,7 @@ abstract class AvroExtension
7985 init {
8086 schemas.convention(objects.fileTree().from(" src/main/avro" ))
8187 outputDir.convention(objects.directoryProperty().fileValue(File (" build/generated/sources/avro" )))
88+ intermediateDir.convention(objects.directoryProperty().fileValue(File (" build/intermediates/avro" )))
8289
8390 encoding.convention(" UTF-8" )
8491 stringType.convention(false )
Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ class AvroPlugin : Plugin<Project> {
1313 // Register the task
1414 val generateTask: TaskProvider <GenerateAvroTask > =
1515 project.tasks.register(" generateAvro" , GenerateAvroTask ::class .java) {
16+ it.group = " avro"
17+ it.description = " Generates Java classes from Avro schema files"
18+
1619 it.schemas.convention(extension.schemas)
1720 it.outputDir.convention(extension.outputDir)
1821 it.intermediateDir.convention(project.layout.buildDirectory.dir(" intermediates/avro" ))
@@ -35,7 +38,7 @@ class AvroPlugin : Plugin<Project> {
3538 // Add the generated sources to the source set
3639 project.plugins.withId(" java" ) {
3740 val sourceSets = project.extensions.getByName(" sourceSets" ) as SourceSetContainer
38- sourceSets.getByName(" main" ).java.srcDir(generateTask.get() .outputs.files)
41+ sourceSets.getByName(" main" ).java.srcDir(generateTask.map { it .outputs.files } )
3942 }
4043 }
4144}
Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ abstract class GenerateAvroTask : DefaultTask() {
117117
118118 // Determine if the input directory contains Avro protocol files.
119119 val inputDir = schemas.files.toSet()
120- val intermediateDir = project.file( " build/intermediates/avro " )
120+ val intermediateDir = intermediateDir.get().asFile
121121
122122 // Transform any Avro IDL (.avdl) files to Avro protocol (.avpr) files.
123123 if (transformIdl(inputDir, intermediateDir)) {
You can’t perform that action at this time.
0 commit comments