Skip to content

Commit

Permalink
FINERACT-1694: Avro schemas project + code generation + some initial …
Browse files Browse the repository at this point in the history
…Avro Schemas
  • Loading branch information
galovics authored and vidakovic committed Aug 30, 2022
1 parent 4808bb3 commit 264022b
Show file tree
Hide file tree
Showing 24 changed files with 1,227 additions and 3 deletions.
5 changes: 4 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ buildscript {
'fineract-client',
'core',
'service',
'starter'
'starter',
'fineract-avro-schemas'
].contains(it.name)
}
fineractPublishProjects = subprojects.findAll{
[
'fineract-avro-schemas',
'fineract-client'
].contains(it.name)
}
Expand Down Expand Up @@ -80,6 +82,7 @@ plugins {
id 'com.github.andygoossens.modernizer' version '1.6.2' apply false
id 'com.github.spotbugs' version '5.0.10' apply false
id 'se.thinkcode.cucumber-runner' version '0.0.11' apply false
id "com.github.davidmc24.gradle.plugin.avro-base" version "1.3.0" apply false
}

apply from: "${rootDir}/buildSrc/src/main/groovy/org.apache.fineract.release.gradle"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,7 @@ dependencyManagement {

dependency 'org.mapstruct:mapstruct:1.5.2.Final'
dependency 'org.mapstruct:mapstruct-processor:1.5.2.Final'

dependency "org.apache.avro:avro:1.11.0"
}
}
59 changes: 59 additions & 0 deletions fineract-avro-schemas/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* 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

description = 'Fineract Avro Schemas'

apply plugin: 'com.github.davidmc24.gradle.plugin.avro-base'

apply from: 'dependencies.gradle'

// TODO: @vidakovic we should publish this lib to Maven Central; do in separate PR
task buildJavaSdk(type: GenerateAvroJavaTask) {
source("$projectDir/src/main/avro")
outputDir = file("$buildDir/generated/java/src/main/java")
}


compileJava.dependsOn(buildJavaSdk, licenseFormatMain, spotlessMiscApply)

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 buildJavaSdk
21 changes: 21 additions & 0 deletions fineract-avro-schemas/dependencies.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* 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.
*/
dependencies {
implementation('org.apache.avro:avro')
}
71 changes: 71 additions & 0 deletions fineract-avro-schemas/src/main/avro/MessageV1.avsc
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* 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.
*/

{
"name": "MessageV1",
"namespace": "org.apache.fineract.avro",
"type": "record",
"fields": [
{
"name": "id",
"type": "int",
"doc": "The ID of the message to be sent"
},
{
"name": "source",
"type": "string",
"doc": "A unique identifier of the source service"
},
{
"name": "type",
"type": "string",
"doc": "The type of event the payload refers to. For example LOAN_APPROVED"
},
{
"name": "version",
"type": "string",
"doc": "The version of the type of event. For example 1, 2, 3, etc"
},
{
"name": "category",
"type": "string",
"doc": "The category of event the payload refers to. For example LOAN"
},
{
"name": "createdAt",
"type": "string",
"doc": "The UTC time of when the event has been raised; in ISO_LOCAL_DATE_TIME format. For example 2011-12-03T10:15:30"
},
{
"name": "tenantId",
"type": "string",
"doc": "The tenantId that the event has been sent from. For example default"
},
{
"name": "idempotencyKey",
"type": "string",
"doc": "The idempotency key for this particular event for consumer de-duplication"
},
{
"name": "payload",
"type": "bytes",
"doc": "The payload serialized into Avro bytes"
}
]
}
82 changes: 82 additions & 0 deletions fineract-avro-schemas/src/main/avro/client/v1/ClientEventV1.avsc
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/**
* 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.
*/

{
"name": "ClientEventV1",
"namespace": "org.apache.fineract.avro.client.v1",
"type": "record",
"fields": [
{
"name": "id",
"type": [
"null",
"int"
]
},
{
"name": "accountNo",
"type": [
"null",
"string"
]
},
{
"name": "status",
"type": [
"null",
"org.apache.fineract.avro.client.v1.ClientEventV1Status"
]
},
{
"name": "active",
"type": [
"null",
"boolean"
]
},
{
"name": "fullName",
"type": [
"null",
"string"
]
},
{
"name": "displayName",
"type": [
"null",
"string"
]
},
{
"name": "officeId",
"type": [
"null",
"int"
]
},
{
"name": "officeName",
"type": [
"null",
"string"
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* 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.
*/

{
"name": "ClientEventV1Status",
"namespace": "org.apache.fineract.avro.client.v1",
"type": "record",
"fields": [
{
"name": "id",
"type": [
"null",
"int"
]
},
{
"name": "code",
"type": [
"null",
"string"
]
},
{
"name": "description",
"type": [
"null",
"string"
]
}
]
}
Loading

0 comments on commit 264022b

Please sign in to comment.