generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Extract Java and Kotlin runtimes into seperate artifacts. (#2380)
At present the only difference is code gen and some dependencies.
- Loading branch information
1 parent
34e9734
commit ebb66ad
Showing
96 changed files
with
981 additions
and
399 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
350 changes: 0 additions & 350 deletions
350
...ntime/ftl-runtime/deployment/src/main/java/xyz/block/ftl/deployment/FTLCodeGenerator.java
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
...ime/deployment/src/main/resources/META-INF/services/io.quarkus.deployment.CodeGenProvider
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
126 changes: 126 additions & 0 deletions
126
...tl-runtime/common/deployment/src/main/java/xyz/block/ftl/deployment/JVMCodeGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
package xyz.block.ftl.deployment; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Stream; | ||
|
||
import org.eclipse.microprofile.config.Config; | ||
|
||
import io.quarkus.bootstrap.prebuild.CodeGenException; | ||
import io.quarkus.deployment.CodeGenContext; | ||
import io.quarkus.deployment.CodeGenProvider; | ||
import xyz.block.ftl.v1.schema.Data; | ||
import xyz.block.ftl.v1.schema.Enum; | ||
import xyz.block.ftl.v1.schema.Module; | ||
import xyz.block.ftl.v1.schema.Topic; | ||
import xyz.block.ftl.v1.schema.Type; | ||
import xyz.block.ftl.v1.schema.Verb; | ||
|
||
public abstract class JVMCodeGenerator implements CodeGenProvider { | ||
|
||
public static final String PACKAGE_PREFIX = "ftl."; | ||
|
||
@Override | ||
public String providerId() { | ||
return "ftl-clients"; | ||
} | ||
|
||
@Override | ||
public String inputDirectory() { | ||
return "ftl-module-schema"; | ||
} | ||
|
||
@Override | ||
public boolean trigger(CodeGenContext context) throws CodeGenException { | ||
if (!Files.isDirectory(context.inputDir())) { | ||
return false; | ||
} | ||
List<Module> modules = new ArrayList<>(); | ||
Map<DeclRef, Type> typeAliasMap = new HashMap<>(); | ||
try (Stream<Path> pathStream = Files.list(context.inputDir())) { | ||
for (var file : pathStream.toList()) { | ||
String fileName = file.getFileName().toString(); | ||
if (!fileName.endsWith(".pb")) { | ||
continue; | ||
} | ||
var module = Module.parseFrom(Files.readAllBytes(file)); | ||
for (var decl : module.getDeclsList()) { | ||
if (decl.hasTypeAlias()) { | ||
var data = decl.getTypeAlias(); | ||
typeAliasMap.put(new DeclRef(module.getName(), data.getName()), data.getType()); | ||
} | ||
} | ||
modules.add(module); | ||
} | ||
} catch (IOException e) { | ||
throw new CodeGenException(e); | ||
} | ||
try { | ||
for (var module : modules) { | ||
String packageName = PACKAGE_PREFIX + module.getName(); | ||
for (var decl : module.getDeclsList()) { | ||
if (decl.hasVerb()) { | ||
var verb = decl.getVerb(); | ||
if (!verb.getExport()) { | ||
continue; | ||
} | ||
generateVerb(module, verb, packageName, typeAliasMap, context.outDir()); | ||
} else if (decl.hasData()) { | ||
var data = decl.getData(); | ||
if (!data.getExport()) { | ||
continue; | ||
} | ||
generateDataObject(module, data, packageName, typeAliasMap, context.outDir()); | ||
|
||
} else if (decl.hasEnum()) { | ||
var data = decl.getEnum(); | ||
if (!data.getExport()) { | ||
continue; | ||
} | ||
generateEnum(module, data, packageName, typeAliasMap, context.outDir()); | ||
} else if (decl.hasTopic()) { | ||
var data = decl.getTopic(); | ||
if (!data.getExport()) { | ||
continue; | ||
} | ||
generateTopicSubscription(module, data, packageName, typeAliasMap, context.outDir()); | ||
} | ||
} | ||
} | ||
|
||
} catch (Exception e) { | ||
throw new CodeGenException(e); | ||
} | ||
return true; | ||
} | ||
|
||
protected abstract void generateTopicSubscription(Module module, Topic data, String packageName, | ||
Map<DeclRef, Type> typeAliasMap, Path outputDir) throws IOException; | ||
|
||
protected abstract void generateEnum(Module module, Enum data, String packageName, Map<DeclRef, Type> typeAliasMap, | ||
Path outputDir) throws IOException; | ||
|
||
protected abstract void generateDataObject(Module module, Data data, String packageName, Map<DeclRef, Type> typeAliasMap, | ||
Path outputDir) throws IOException; | ||
|
||
protected abstract void generateVerb(Module module, Verb verb, String packageName, Map<DeclRef, Type> typeAliasMap, | ||
Path outputDir) throws IOException; | ||
|
||
@Override | ||
public boolean shouldRun(Path sourceDir, Config config) { | ||
return true; | ||
} | ||
|
||
public record DeclRef(String module, String name) { | ||
} | ||
|
||
protected static String className(String in) { | ||
return Character.toUpperCase(in.charAt(0)) + in.substring(1); | ||
} | ||
|
||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>ftl-jvm-runtime-parent</artifactId> | ||
<groupId>xyz.block.ftl</groupId> | ||
<version>1.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>ftl-jvm-runtime-common-parent</artifactId> | ||
<name>FTL Java Runtime - Common Parent</name> | ||
<packaging>pom</packaging> | ||
<modules> | ||
<module>deployment</module> | ||
<module>runtime</module> | ||
</modules> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions
9
jvm-runtime/ftl-runtime/common/runtime/src/main/resources/META-INF/quarkus-extension.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name: FTL JVM Common Runtime | ||
#description: Do something useful. | ||
metadata: | ||
# keywords: | ||
# - ftl-java-runtime | ||
# guide: ... # To create and publish this guide, see https://github.com/quarkiverse/quarkiverse/wiki#documenting-your-extension | ||
# categories: | ||
# - "miscellaneous" | ||
# status: "preview" |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>xyz.block.ftl</groupId> | ||
<artifactId>ftl-java-runtime-parent</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>ftl-java-runtime-deployment</artifactId> | ||
<name>Ftl Java Runtime - Deployment</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>xyz.block.ftl</groupId> | ||
<artifactId>ftl-java-runtime</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>xyz.block.ftl</groupId> | ||
<artifactId>ftl-jvm-runtime-deployment</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.squareup</groupId> | ||
<artifactId>javapoet</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-junit5-internal</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<annotationProcessorPaths> | ||
<path> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-extension-processor</artifactId> | ||
<version>${quarkus.version}</version> | ||
</path> | ||
</annotationProcessorPaths> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
Oops, something went wrong.