Skip to content

Commit b005f81

Browse files
committed
Work on #51 - Replace shared API classes with codegen from OpenAPI/JSON schema - implemented FtgoApiDependencyResolverPlugin to 'download' and unpack API specification JARs
1 parent 78a4da2 commit b005f81

File tree

14 files changed

+75
-8
lines changed

14 files changed

+75
-8
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import org.gradle.api.Plugin
2+
import org.gradle.api.Project
3+
4+
class FtgoApiDependencyResolverPlugin implements Plugin<Project> {
5+
6+
@Override
7+
void apply(Project project) {
8+
9+
project.ext.ftgoApiSpecsDir = "${project.buildDir}/ftgo-api-specs"
10+
11+
def c = project.configurations.create('ftgoApiSpecification')
12+
13+
project.configurations.implementation.extendsFrom(c)
14+
15+
project.task("ftgoResolveAPIDependencies",
16+
type: FtgoResolveAPIDependencies,
17+
group: 'build setup',
18+
description: "fetch API dependencies")
19+
}
20+
21+
}

buildSrc/src/main/groovy/FtgoJSONSchema2PojoPlugin.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ class FtgoJSONSchema2PojoPlugin implements Plugin<Project> {
55

66
@Override
77
void apply(Project project) {
8+
9+
project.apply(plugin: FtgoApiDependencyResolverPlugin)
10+
811
def jsonSchemaSources = project.container(JSONSchemaSource)
912
project.extensions.add('ftgoJsonSchema2Pojo', jsonSchemaSources)
1013

@@ -19,6 +22,7 @@ class FtgoJSONSchema2PojoPlugin implements Plugin<Project> {
1922

2023
source.codeGen.targetDirectory = new File(project.buildDir, "generated-js2p-code-${source.name}")
2124

25+
source.codeGen.dependsOn(project.tasks.ftgoResolveAPIDependencies)
2226

2327
project.afterEvaluate {
2428
project.sourceSets[source.sourceSet].java.srcDirs += [source.codeGen.targetDirectory]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import org.gradle.api.tasks.Sync
2+
3+
class FtgoResolveAPIDependencies extends Sync {
4+
5+
FtgoResolveAPIDependencies() {
6+
7+
8+
from {
9+
project.configurations.ftgoApiSpecification.resolve().collect {
10+
project.zipTree(it)
11+
}
12+
}
13+
include("**/*.json")
14+
exclude("**/META-INF/**")
15+
into(project.ext.ftgoApiSpecsDir )
16+
17+
includeEmptyDirs = false
18+
19+
}
20+
21+
}

ftgo-common-jpa/src/main/resources/META-INF/orm.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@
1010
</basic>
1111
</attributes>
1212
</embeddable>
13+
<embeddable class="net.chrisrichardson.ftgo.common.PersonName" access="FIELD">
14+
<attributes>
15+
<basic name="firstName">
16+
<column name="firstName"/>
17+
</basic>
18+
<basic name="lastName">
19+
<column name="lastName"/>
20+
</basic>
21+
</attributes>
22+
</embeddable>
1323
<embeddable class="net.chrisrichardson.ftgo.common.Address" access="FIELD">
1424
<attributes>
1525
<basic name="street1">

ftgo-common/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ dependencies {
44

55
compile "org.springframework.boot:spring-boot-starter-data-jpa:$springBootVersion"
66

7+
// compile "org.springframework.boot:spring-boot-starter:$springBootVersion"
8+
79
compile "io.eventuate.common:eventuate-common-json-mapper:$eventuateCommonVersion"
810

911
testCompile "org.springframework.boot:spring-boot-starter-test:$springBootVersion"

ftgo-common/src/main/java/net/chrisrichardson/ftgo/common/PersonName.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package net.chrisrichardson.ftgo.common;
22

3-
import javax.persistence.Embeddable;
4-
5-
@Embeddable
63
public class PersonName {
74
private String firstName;
85
private String lastName;

ftgo-consumer-service/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ dependencies {
1616

1717
compile project(":common-swagger")
1818
compile project(":ftgo-consumer-service-api")
19+
compile project(":ftgo-consumer-service-api-spec")
1920

2021
compile "org.springframework.boot:spring-boot-starter-data-jpa:$springBootVersion"
2122
compile "org.springframework.boot:spring-boot-starter-web:$springBootVersion"

0 commit comments

Comments
 (0)