Skip to content

Commit

Permalink
fineract-avro-schemas module turned to kotlin dsl
Browse files Browse the repository at this point in the history
  • Loading branch information
kjozsa committed Oct 3, 2024
1 parent 196b572 commit af27207
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 21 deletions.
98 changes: 98 additions & 0 deletions fineract-avro-schemas/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// TODO: @vidakovic we should publish this lib to Maven Central; do in separate PR

plugins {
java
id("com.github.davidmc24.gradle.plugin.avro-base") version "1.9.1"
}

description = "Fineract Avro Schemas"

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

dependencies {
implementation("org.apache.avro:avro")
}

//tasks.withType<JavaCompile> {
// options.compilerArgs.add("-Werror")
//}

val avroSourceDir = "$projectDir/src/main/avro"
val avroPreProcessedDir = layout.buildDirectory.dir("generated/avro/src/main/avro")
val avroGeneratedSourcesDir = layout.buildDirectory.dir("generated-src/avro/main")

tasks.register("preprocessAvroSchemas") {
inputs.dir(avroSourceDir)
outputs.dir(avroPreProcessedDir)

doLast {
println("## preprocessing Avro schemas...")
copy {
from(avroSourceDir)
into(avroPreProcessedDir)
filter { line: String ->
line.replace("\"bigdecimal\"", file("$projectDir/src/main/resources/avro-templates/bigdecimal.avsc").readText(Charsets.UTF_8))
}
}
}
}

tasks.register<com.github.davidmc24.gradle.plugin.avro.GenerateAvroJavaTask>("generateAvroJava") {
println("## generating Avro Java sources...")
dependsOn("preprocessAvroSchemas")
inputs.dir(avroPreProcessedDir)
outputs.dir(avroGeneratedSourcesDir)

source(avroPreProcessedDir)
setOutputDir(file(avroGeneratedSourcesDir))
}

sourceSets {
main {
java.srcDir(avroGeneratedSourcesDir)
}
}

tasks.named("compileJava") {
dependsOn("preprocessAvroSchemas", "generateAvroJava", "spotlessJsonApply")
}

spotless {
json {
target("**/*.avsc")
simple()
}
}

tasks.register("cleanGeneratedSources") {
delete(avroPreProcessedDir, avroGeneratedSourcesDir)
}

tasks.named("clean") {
dependsOn("cleanGeneratedSources")
}

tasks.named("licenseMain") {
dependsOn(tasks.named("generateAvroJava"))
}
File renamed without changes.
21 changes: 0 additions & 21 deletions fineract-avro-schemas/dependencies.gradle

This file was deleted.

0 comments on commit af27207

Please sign in to comment.