Skip to content

Commit a1ab808

Browse files
committed
FINERACT-2380: create feign client
1 parent d6323be commit a1ab808

File tree

61 files changed

+7883
-14
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+7883
-14
lines changed

build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ buildscript {
4444
'twofactor-tests',
4545
'oauth2-tests',
4646
'fineract-client',
47+
'fineract-client-feign',
4748
'fineract-avro-schemas',
4849
'fineract-e2e-tests-core',
4950
'fineract-e2e-tests-runner',
@@ -55,6 +56,7 @@ buildscript {
5556
[
5657
'fineract-avro-schemas',
5758
'fineract-client',
59+
'fineract-client-feign',
5860
'fineract-core',
5961
'fineract-cob',
6062
'fineract-validation',
@@ -558,6 +560,9 @@ configure(project.fineractJavaProjects) {
558560
if (project.path == ':fineract-client') {
559561
excludedPaths = '.*/build/generated/java/src/main/java/.*'
560562
}
563+
if (project.path == ':fineract-client-feign') {
564+
excludedPaths = '.*/build/generated/java/src/main/java/.*'
565+
}
561566
disable(
562567
// TODO Remove disabled checks from this list, by fixing remaining usages
563568
"UnusedVariable",
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
**/README.md
2+
**/pom.xml
3+
**/build.sbt
4+
**/*.gradle
5+
**/.gitignore
6+
**/git_push.sh
7+
**/api/*
8+
**/gradle*
9+
**/gradle
10+
**/src/main/AndroidManifest.xml
11+
12+
# https://issues.apache.org/jira/browse/FINERACT-1231
13+
**/feign/*.java
14+
!**/feign/CollectionFormats.java
15+
!**/feign/StringUtil.java
16+
17+
# Manual API overrides - do not regenerate
18+
# https://issues.apache.org/jira/browse/FINERACT-1263
19+
**/services/RunReportsApi.java
20+
**/services/ImagesApi.java
21+
**/services/DocumentsApiFixed.java
22+
23+
# Utility classes - do not regenerate
24+
**/util/*.java
25+
**/adapter/*.java
26+
27+
# Feign configuration - do not regenerate
28+
**/feign/FineractFeignClient.java
29+
**/feign/FineractFeignClientConfig.java
30+
**/feign/BasicAuthRequestInterceptor.java
31+
**/feign/ObjectMapperFactory.java
32+
**/feign/FeignException.java

fineract-client-feign/build.gradle

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
apply plugin: 'org.openapi.generator'
20+
apply plugin: 'jacoco'
21+
description = 'Fineract Client with Feign'
22+
23+
apply from: 'dependencies.gradle'
24+
25+
openApiMeta {
26+
generatorName = 'Fineract-Feign'
27+
packageName = 'org.apache.fineract.client.feign'
28+
outputFolder = "$buildDir/meta".toString()
29+
}
30+
31+
openApiValidate {
32+
inputSpec = "file:///$swaggerFile"
33+
recommend = true
34+
}
35+
36+
tasks.register('buildJavaSdk', org.openapitools.generator.gradle.plugin.tasks.GenerateTask) {
37+
generatorName = 'java'
38+
library = 'feign'
39+
verbose = false
40+
validateSpec = false
41+
skipValidateSpec = true
42+
inputSpec = "file:///$swaggerFile"
43+
outputDir = "$buildDir/generated/temp-java".toString()
44+
templateDir = "$projectDir/src/main/resources/templates/java"
45+
groupId = 'org.apache.fineract'
46+
apiPackage = 'org.apache.fineract.client.feign.services'
47+
invokerPackage = 'org.apache.fineract.client.feign'
48+
modelPackage = 'org.apache.fineract.client.models'
49+
generateModelTests = false
50+
generateApiTests = false
51+
ignoreFileOverride = "$projectDir/.openapi-generator-ignore"
52+
configOptions = [
53+
dateLibrary : 'java8',
54+
library : 'feign',
55+
feignVersion : '13.6',
56+
feignApacheHttpClient : 'true',
57+
useFeign13 : 'true',
58+
useFeignApacheHttpClient : 'true',
59+
hideGenerationTimestamp : 'true',
60+
containerDefaultToNull : 'true',
61+
oauth2Implementation : 'none',
62+
useJakartaEe : 'true'
63+
64+
]
65+
dependsOn(':fineract-provider:resolve')
66+
}
67+
68+
sourceSets {
69+
main {
70+
java {
71+
srcDirs = [
72+
new File(buildDir, "generated/java/src/main/java"),
73+
"$projectDir/src/main/java"
74+
]
75+
destinationDirectory = layout.buildDirectory.dir('classes/java/main').get().asFile
76+
}
77+
output.resourcesDir = layout.buildDirectory.dir('resources/main').get().asFile
78+
}
79+
test {
80+
java {
81+
destinationDirectory = layout.buildDirectory.dir('classes/java/test').get().asFile
82+
}
83+
output.resourcesDir = layout.buildDirectory.dir('resources/test').get().asFile
84+
}
85+
}
86+
87+
tasks.withType(Jar).configureEach {
88+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
89+
}
90+
91+
task cleanupGeneratedJavaFiles() {
92+
def tempDir = file("$buildDir/generated/temp-java")
93+
def targetDir = file("$buildDir/generated/java")
94+
95+
inputs.dir(tempDir)
96+
outputs.dir(targetDir)
97+
98+
doFirst {
99+
delete fileTree(tempDir) {
100+
include "src/main/java/org/apache/fineract/client/auth/OAuthOkHttpClient.java"
101+
}
102+
delete fileTree(targetDir) {
103+
include "src/main/java/org/apache/fineract/client/auth/OAuthOkHttpClient.java"
104+
}
105+
}
106+
doLast {
107+
copy {
108+
from tempDir
109+
into targetDir
110+
filter { line ->
111+
line
112+
.replaceAll("import org\\.joda\\.time\\.\\*;", "")
113+
.replaceAll(", \\)", ")")
114+
.replaceAll(", , @HeaderMap", ", @HeaderMap")
115+
.replaceAll("\\(, ", "(")
116+
}
117+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
118+
}
119+
}
120+
dependsOn("buildJavaSdk")
121+
}
122+
123+
tasks.named('compileJava') {
124+
outputs.cacheIf { true }
125+
dependsOn(buildJavaSdk, cleanupGeneratedJavaFiles, licenseFormatMain, spotlessMiscApply)
126+
mustRunAfter(licenseFormatMain, cleanupGeneratedJavaFiles)
127+
}
128+
129+
tasks.named('sourcesJar') {
130+
dependsOn(cleanupGeneratedJavaFiles)
131+
mustRunAfter(cleanupGeneratedJavaFiles)
132+
133+
from(sourceSets.main.java.srcDirs) {
134+
include "**/*.java"
135+
}
136+
}
137+
138+
tasks.named('licenseFormatMain') {
139+
dependsOn(cleanupGeneratedJavaFiles)
140+
mustRunAfter(cleanupGeneratedJavaFiles)
141+
source = sourceSets.main.java.srcDirs
142+
}
143+
144+
tasks.named('licenseMain') {
145+
dependsOn(licenseFormatMain)
146+
mustRunAfter(licenseFormatMain)
147+
}
148+
149+
java {
150+
sourceCompatibility = JavaVersion.VERSION_1_8
151+
targetCompatibility = JavaVersion.VERSION_1_8
152+
}
153+
154+
tasks.withType(JavaCompile).configureEach {
155+
options.encoding = 'UTF-8'
156+
options.compilerArgs << '-parameters'
157+
options.errorprone {
158+
excludedPaths = '.*/build/generated/java/src/main/java/.*'
159+
}
160+
}
161+
162+
test {
163+
useJUnitPlatform()
164+
}
165+
166+
configurations {
167+
generatedCompileClasspath.extendsFrom implementation
168+
generatedRuntimeClasspath.extendsFrom runtimeClasspath
169+
}
170+
171+
javadoc {
172+
options.encoding = 'UTF-8'
173+
}
174+
175+
spotbugsMain {
176+
enabled = false
177+
}
178+
179+
spotbugsTest {
180+
enabled = false
181+
}
182+
183+
jacoco {
184+
toolVersion = "0.8.11"
185+
}
186+
187+
jacocoTestReport {
188+
dependsOn test
189+
reports {
190+
xml.required = true
191+
html.required = true
192+
csv.required = false
193+
}
194+
afterEvaluate {
195+
classDirectories.setFrom(files(classDirectories.files.collect {
196+
fileTree(dir: it, exclude: [
197+
'**/build/generated/**',
198+
'**/org/apache/fineract/client/models/**',
199+
'**/org/apache/fineract/client/services/**Api.class',
200+
'**/org/apache/fineract/client/auth/**'
201+
])
202+
}))
203+
}
204+
}
205+
206+
test {
207+
finalizedBy jacocoTestReport
208+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
dependencies {
20+
// Feign dependencies
21+
implementation(
22+
'io.github.openfeign:feign-core:13.6',
23+
'io.github.openfeign:feign-jackson:13.6',
24+
'io.github.openfeign:feign-slf4j:13.6',
25+
'io.github.openfeign:feign-hc5:13.6',
26+
'io.github.openfeign.form:feign-form:3.8.0',
27+
'org.apache.httpcomponents.client5:httpclient5:5.2.1',
28+
'com.fasterxml.jackson.core:jackson-databind',
29+
'com.fasterxml.jackson.datatype:jackson-datatype-jsr310',
30+
'com.fasterxml.jackson.datatype:jackson-datatype-jdk8',
31+
'jakarta.annotation:jakarta.annotation-api:3.0.0',
32+
'io.swagger.core.v3:swagger-annotations-jakarta:2.2.15',
33+
'org.apache.commons:commons-lang3:3.12.0',
34+
'org.slf4j:slf4j-api:1.7.36',
35+
'org.projectlombok:lombok'
36+
)
37+
38+
// Test dependencies
39+
testImplementation(
40+
'org.junit.jupiter:junit-jupiter-api:5.11.3',
41+
'org.junit.jupiter:junit-jupiter-engine:5.11.3',
42+
'org.mockito:mockito-core:5.14.2',
43+
'org.assertj:assertj-core:3.26.3',
44+
'org.slf4j:slf4j-simple:1.7.36',
45+
'org.wiremock:wiremock-standalone'
46+
)
47+
}

0 commit comments

Comments
 (0)