| /** |
| * 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. |
| */ |
| |
| import com.github.davidmc24.gradle.plugin.avro.GenerateAvroJavaTask |
| |
| // TODO: @vidakovic we should publish this lib to Maven Central; do in separate PR |
| description = 'Fineract Avro Schemas' |
| |
| apply plugin: 'com.github.davidmc24.gradle.plugin.avro-base' |
| |
| apply from: 'dependencies.gradle' |
| |
| task preprocessAvroSchemas() { |
| doLast { |
| copy { |
| from "$projectDir/src/main/avro" |
| into "$buildDir/generated/avro/src/main/avro" |
| filter { line -> |
| line.replaceAll("\"bigdecimal\"", new File("$projectDir/src/main/resources/avro-templates/bigdecimal.avsc").getText("UTF-8")) |
| } |
| } |
| } |
| } |
| |
| task buildJavaSdk(type: GenerateAvroJavaTask) { |
| source("$buildDir/generated/avro/src/main/avro") |
| outputDir = file("$buildDir/generated/java/src/main/java") |
| templateDirectory = "$projectDir/src/main/resources/avro-generator-templates/" |
| } |
| |
| spotless { |
| json { |
| target '**/*.avsc' // TODO: include generated AVSCs as well |
| targetExclude '' |
| simple() |
| } |
| } |
| |
| buildJavaSdk.dependsOn(preprocessAvroSchemas, spotlessJsonApply) |
| compileJava.dependsOn(buildJavaSdk, licenseFormatMain) |
| |
| java { |
| // keep this at Java 8, not 17 |
| sourceCompatibility = JavaVersion.VERSION_1_8 |
| targetCompatibility = JavaVersion.VERSION_1_8 |
| } |
| |
| tasks.withType(JavaCompile) { |
| options.compilerArgs -= ["-Werror"] |
| } |
| |
| configurations { |
| generatedCompileClasspath.extendsFrom implementation |
| generatedRuntimeClasspath.extendsFrom runtimeClasspath |
| } |
| |
| test { |
| useJUnitPlatform() |
| } |
| |
| sourceSets.main.java.srcDir new File(buildDir, "generated/java/src/main/java") |
| |
| licenseFormatMain.dependsOn buildJavaSdk |
| licenseMain.dependsOn licenseFormatMain |