diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 94c53e80ca..51bb82cfce 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -17,25 +17,7 @@ jobs:
- name: Init Hermit
uses: cashapp/activate-hermit@v1
- name: Test
- uses: gradle/gradle-build-action@v2
- with:
- arguments: test
- build-root-directory: kotlin-runtime/ftl-runtime
- gradle-executable: ${{ github.workspace }}/bin/gradle
- kotlin-ftl-plugin:
- name: FTL Plugin
- runs-on: ubuntu-latest
- steps:
- - name: Checkout code
- uses: actions/checkout@v3
- - name: Init Hermit
- uses: cashapp/activate-hermit@v1
- - name: Test
- uses: gradle/gradle-build-action@v2
- with:
- arguments: test
- build-root-directory: kotlin-runtime/ftl-plugin
- gradle-executable: ${{ github.workspace }}/bin/gradle
+ run: mvn test
test:
name: Test
runs-on: ubuntu-latest
@@ -110,7 +92,6 @@ jobs:
if: github.ref == 'refs/heads/main'
needs:
- kotlin-runtime
- - kotlin-ftl-plugin
- test
- lint
- console
diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml
index 0b3531a9a2..d05de0927a 100644
--- a/.github/workflows/integration.yml
+++ b/.github/workflows/integration.yml
@@ -17,17 +17,9 @@ jobs:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go
- name: Build Kotlin Runtime
- uses: gradle/gradle-build-action@v2
- with:
- arguments: build
- build-root-directory: kotlin-runtime/ftl-runtime
- gradle-executable: ${{ github.workspace }}/bin/gradle
- - name: Build Kotlin Plugin
- uses: gradle/gradle-build-action@v2
- with:
- arguments: build
- build-root-directory: kotlin-runtime/ftl-plugin
- gradle-executable: ${{ github.workspace }}/bin/gradle
+ run: mvn -pl :ftl-runtime package
+ - name: Build Kotlin Generator
+ run: mvn -pl :ftl-generator package
- name: Docker Compose
run: docker compose up -d --wait
- name: Integration tests
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index bba1aa6cb6..29d5c2aa32 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -80,3 +80,21 @@ jobs:
docker tag ghcr.io/tbd54566975/ftl-controller:latest ghcr.io/tbd54566975/ftl-controller:$GITHUB_SHA
docker tag ghcr.io/tbd54566975/ftl-controller:latest ghcr.io/tbd54566975/ftl-controller:$version
docker push -a ghcr.io/tbd54566975/ftl-controller
+ publish:
+ name: Publish to Maven
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ packages: write
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v3
+ - name: Init Hermit
+ uses: cashapp/activate-hermit@v1
+ - name: Set version
+ run: mvn --batch-mode versions:set -DnewVersion=$(git describe --tags --abbrev=0 | cut -c2-) -DprocessAllModules -DgenerateBackupPoms=false
+ - name: Publish packages
+ run: mvn --batch-mode deploy
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
diff --git a/.gitignore b/.gitignore
index 3e7c833cef..d527a7b3a6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,4 @@ reflex.conf
/logs/
node_modules
*.tsbuildinfo
+generated_ftl_module.go
diff --git a/.mvn/maven.config b/.mvn/maven.config
new file mode 100644
index 0000000000..e89445621b
--- /dev/null
+++ b/.mvn/maven.config
@@ -0,0 +1 @@
+--also-make
diff --git a/Bitfile b/Bitfile
index addf3fbb7c..52696b5c73 100644
--- a/Bitfile
+++ b/Bitfile
@@ -24,8 +24,8 @@ PROTO_OUT = protos/xyz/block/ftl/v1/ftlv1connect/ftl.connect.go \
COMMON_LOG_IN = backend/common/log/api.go
COMMON_LOG_OUT = backend/common/log/log_level_string.go
-KT_RUNTIME_IN = kotlin-runtime/ftl-runtime/**/*.{kt,kts} kotlin-runtime/gradle/libs.versions.toml
-KT_RUNTIME_OUT = kotlin-runtime/ftl-runtime/build/libs/ftl-runtime.jar
+KT_RUNTIME_IN = kotlin-runtime/ftl-runtime/**/*.{kt,kts} pom.xml kotlin-runtime/**/pom.xml
+KT_RUNTIME_OUT = kotlin-runtime/ftl-runtime/target/ftl-runtime-1.0-SNAPSHOT-jar-with-dependencies.jar
CLIENT_OUT = console/client/dist/index.html
CLIENT_IN = console/client/**/*
@@ -55,12 +55,9 @@ implicit %{RELEASE}/%{1}: cmd/*
(cd backend/common/3rdparty/protos && buf generate)
-clean
-export GRADLE_OPTS = -Dorg.gradle.console=plain
-
%{KT_RUNTIME_OUT}: %{KT_RUNTIME_IN} %{PROTO_IN}
- cd kotlin-runtime/ftl-runtime
- build: gradle jar
- +clean: gradle clean
+ build: mvn -pl kotlin-runtime/ftl-runtime install
+ +clean: mvn -pl kotlin-runtime/ftl-runtime clean
build/template/ftl/jars:
build: install -m 0700 -d %{OUT}
diff --git a/Dockerfile.runner b/Dockerfile.runner
index ae5129f800..6a40243e09 100644
--- a/Dockerfile.runner
+++ b/Dockerfile.runner
@@ -21,9 +21,9 @@ RUN go mod download -x
# Build runtime
COPY kotlin-runtime /src/kotlin-runtime
+COPY pom.xml /src/pom.xml
COPY protos /src/protos
-RUN cd kotlin-runtime/ftl-runtime && gradle --info jar
-
+RUN mvn -pl :ftl-runtime package
# Build runner
COPY . /src/
@@ -37,7 +37,7 @@ WORKDIR /root/
ENV PATH="/root/jre/bin:$PATH"
COPY --from=builder /hermit/pkg/openjre-18.0.2.1_1/ ./jre/
-COPY --from=builder /src/kotlin-runtime/ftl-runtime/build/libs/ftl-runtime.jar template/ftl/jars/
+COPY --from=builder /src/kotlin-runtime/ftl-runtime/target/ftl-runtime-1.0-SNAPSHOT-jar-with-dependencies.jar template/ftl/jars/ftl-runtime.jar
COPY --from=builder /src/build/release/ftl-runner .
COPY --from=builder /src/build/release/ftl .
RUN mkdir deployments
diff --git a/Makefile b/Makefile
index 2f00b36e02..febff78775 100644
--- a/Makefile
+++ b/Makefile
@@ -32,6 +32,10 @@ PROTO_OUT = protos/xyz/block/ftl/v1/ftlv1connect/ftl.connect.go \
console/client/src/protos/xyz/block/ftl/v1/console/console_pb.ts
RELEASE_OUT = build/release/ftl build/release/ftl-controller build/release/ftl-runner
+KT_RUNTIME_IN = $(shell find kotlin-runtime/ftl-runtime/src -name '*.kt')
+KT_MVN_OUT = kotlin-runtime/ftl-runtime/target/ftl-runtime-1.0-SNAPSHOT-jar-with-dependencies.jar
+KT_RUNTIME_OUT = build/template/ftl/jars/ftl-runtime.jar
+
.DEFAULT_GOAL := help
.PHONY: help
@@ -44,8 +48,7 @@ all: generate release ## Generate source and build binaries.
.PHONY: clean
clean: ## Clean build artifacts.
rm -rf build $(SQLC_OUT) $(SCHEMA_OUT) $(PROTO_OUT) $(COMMON_LOG_OUT) $(RELEASE_OUT)
- cd kotlin-runtime/ftl-runtime && gradle clean
- cd kotlin-runtime/ftl-plugin && gradle clean
+ mvn clean
.PHONY: release
release: build/release/ftl-controller build/release/ftl-runner build/release/ftl ## Build release binaries.
@@ -53,8 +56,14 @@ release: build/release/ftl-controller build/release/ftl-runner build/release/ftl
build/release/%: console/client/dist/index.html
go build -o $@ -tags release -ldflags "-X main.version=$(VERSION)" ./cmd/$(shell basename $@)
-kotlin-runtime/ftl-runtime/build/libs/ftl-runtime.jar:
- cd kotlin-runtime/ftl-runtime && gradle jar
+$(KT_MVN_OUT): $(KT_RUNTIME_IN)
+ mvn -pl :ftl-runtime clean package
+
+$(KT_RUNTIME_OUT): $(KT_MVN_OUT)
+ mkdir -p build/template/ftl/jars
+ cp $< $@
+
+
console/client/dist/index.html:
cd console/client && npm install && npm run build
diff --git a/bin/.gradle-8.2.1.pkg b/bin/.maven-3.8.6.pkg
similarity index 100%
rename from bin/.gradle-8.2.1.pkg
rename to bin/.maven-3.8.6.pkg
diff --git a/bin/gradle b/bin/gradle
deleted file mode 120000
index 938fc6dd01..0000000000
--- a/bin/gradle
+++ /dev/null
@@ -1 +0,0 @@
-.gradle-8.2.1.pkg
\ No newline at end of file
diff --git a/bin/mvn b/bin/mvn
new file mode 120000
index 0000000000..e51d3a75c9
--- /dev/null
+++ b/bin/mvn
@@ -0,0 +1 @@
+.maven-3.8.6.pkg
\ No newline at end of file
diff --git a/examples/echo-kotlin/build.gradle.kts b/examples/echo-kotlin/build.gradle.kts
deleted file mode 100644
index caa5e4038c..0000000000
--- a/examples/echo-kotlin/build.gradle.kts
+++ /dev/null
@@ -1,22 +0,0 @@
-repositories {
- flatDir {
- dirs("../../kotlin-runtime/ftl-plugin/build/libs")
- }
- mavenCentral()
-}
-
-plugins {
- kotlin("jvm") version "1.9.0"
- `java-library`
- id("xyz.block.ftl")
-}
-
-dependencies {
- implementation("xyz.block:ftl-runtime")
-}
-
-ftl {
- endpoint = "http://localhost:8892"
-}
-
-tasks.findByName("wrapper")?.enabled = false
diff --git a/examples/echo-kotlin/pom.xml b/examples/echo-kotlin/pom.xml
new file mode 100644
index 0000000000..bb05b0aaa2
--- /dev/null
+++ b/examples/echo-kotlin/pom.xml
@@ -0,0 +1,135 @@
+
+
+ 4.0.0
+ xyz.block.ftl
+ echo-kotlin
+ 1.0-SNAPSHOT
+
+
+ 1.0-SNAPSHOT
+ 11
+ 1.9.0
+ true
+
+
+
+
+ org.jetbrains.kotlin
+ kotlin-stdlib
+ ${kotlin.version}
+
+
+ ${project.groupId}
+ ftl-runtime
+ ${ftl.version}
+
+
+ ${project.groupId}
+ ftl-generator
+ ${ftl.version}
+
+
+
+
+
+
+ kotlin-maven-plugin
+ org.jetbrains.kotlin
+ ${kotlin.version}
+
+
+ compile
+
+ compile
+
+
+
+ ${project.basedir}/src/main/kotlin
+
+
+
+
+ test-compile
+
+ test-compile
+
+
+
+ ${project.basedir}/src/test/kotlin
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+ 3.2.0
+
+
+ initialize
+
+ copy
+
+
+
+
+ xyz.block.ftl
+ ftl-generator
+ ${ftl.version}
+ jar-with-dependencies
+ ftl-generator.jar
+
+
+
+
+
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ 3.0.0
+
+
+ initialize
+
+ exec
+
+
+ java
+
+ -jar
+ target/dependency/ftl-generator.jar
+ --endpoint=http://127.0.0.1:8892
+ --dest=${project.build.directory}
+ --module=echo
+
+
+
+
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+ 3.2.0
+
+
+ generate-sources
+
+ add-source
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/echo-kotlin/settings.gradle.kts b/examples/echo-kotlin/settings.gradle.kts
deleted file mode 100644
index c4190b7ba9..0000000000
--- a/examples/echo-kotlin/settings.gradle.kts
+++ /dev/null
@@ -1,3 +0,0 @@
-rootProject.name = "echo"
-
-includeBuild("../../kotlin-runtime")
diff --git a/kotlin-runtime/bin b/kotlin-runtime/bin
deleted file mode 120000
index 19f285ac7c..0000000000
--- a/kotlin-runtime/bin
+++ /dev/null
@@ -1 +0,0 @@
-../bin
\ No newline at end of file
diff --git a/kotlin-runtime/build.gradle.kts b/kotlin-runtime/build.gradle.kts
deleted file mode 100644
index 4677cd8c9a..0000000000
--- a/kotlin-runtime/build.gradle.kts
+++ /dev/null
@@ -1,9 +0,0 @@
-allprojects {
- repositories {
- mavenCentral()
- }
-}
-
-plugins {
- kotlin("jvm") version "1.9.0"
-}
diff --git a/kotlin-runtime/ftl-generator/pom.xml b/kotlin-runtime/ftl-generator/pom.xml
new file mode 100644
index 0000000000..672a2d0271
--- /dev/null
+++ b/kotlin-runtime/ftl-generator/pom.xml
@@ -0,0 +1,100 @@
+
+
+ 4.0.0
+
+
+ xyz.block.ftl
+ ftl
+ 1.0-SNAPSHOT
+ ../../pom.xml
+
+
+ ftl-generator
+ jar
+
+
+ ${basedir}/../..
+ false
+
+
+
+
+ com.squareup
+ kotlinpoet
+ 1.14.2
+
+
+ ${project.groupId}
+ ftl-runtime
+ ${project.parent.version}
+
+
+ com.github.ajalt.clikt
+ clikt-jvm
+ 4.2.0
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+
+
+ package
+
+ single
+
+
+
+
+ xyz.block.ftl.generator.MainKt
+
+
+
+ jar-with-dependencies
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ kotlin-maven-plugin
+ org.jetbrains.kotlin
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+
+
+
+
+
+
+ github
+ GitHub Packages
+ https://maven.pkg.github.com/TBD54566975/ftl
+
+
+
diff --git a/kotlin-runtime/ftl-plugin/src/main/kotlin/xyz/block/ftl/gradle/FTLClient.kt b/kotlin-runtime/ftl-generator/src/main/kotlin/xyz/block/ftl/generator/FTLClient.kt
similarity index 94%
rename from kotlin-runtime/ftl-plugin/src/main/kotlin/xyz/block/ftl/gradle/FTLClient.kt
rename to kotlin-runtime/ftl-generator/src/main/kotlin/xyz/block/ftl/generator/FTLClient.kt
index 35eaf8dae5..1e6dbd2099 100644
--- a/kotlin-runtime/ftl-plugin/src/main/kotlin/xyz/block/ftl/gradle/FTLClient.kt
+++ b/kotlin-runtime/ftl-generator/src/main/kotlin/xyz/block/ftl/generator/FTLClient.kt
@@ -1,4 +1,4 @@
-package xyz.block.ftl.gradle
+package xyz.block.ftl.generator
import com.squareup.wire.GrpcClient
import kotlinx.coroutines.channels.ReceiveChannel
@@ -13,7 +13,7 @@ import xyz.block.ftl.v1.schema.Schema
import java.net.ConnectException
import java.time.Duration
-class FTLClient(ftlEndpoint: String) {
+internal class FTLClient(ftlEndpoint: String) {
private var grpcClient: GrpcClient
private lateinit var sendSchemaChannel: SendChannel
private lateinit var receiveSchemaChannel: ReceiveChannel
diff --git a/kotlin-runtime/ftl-plugin/src/main/kotlin/xyz/block/ftl/gradle/ModuleGenerator.kt b/kotlin-runtime/ftl-generator/src/main/kotlin/xyz/block/ftl/generator/ModuleGenerator.kt
similarity index 77%
rename from kotlin-runtime/ftl-plugin/src/main/kotlin/xyz/block/ftl/gradle/ModuleGenerator.kt
rename to kotlin-runtime/ftl-generator/src/main/kotlin/xyz/block/ftl/generator/ModuleGenerator.kt
index ae36b731d6..6fd4585a3f 100644
--- a/kotlin-runtime/ftl-plugin/src/main/kotlin/xyz/block/ftl/gradle/ModuleGenerator.kt
+++ b/kotlin-runtime/ftl-generator/src/main/kotlin/xyz/block/ftl/generator/ModuleGenerator.kt
@@ -1,4 +1,4 @@
-package xyz.block.ftl.gradle
+package xyz.block.ftl.generator
import com.squareup.kotlinpoet.AnnotationSpec
import com.squareup.kotlinpoet.ClassName
@@ -11,7 +11,6 @@ import com.squareup.kotlinpoet.PropertySpec
import com.squareup.kotlinpoet.TypeName
import com.squareup.kotlinpoet.TypeSpec
import com.squareup.kotlinpoet.TypeVariableName
-import org.gradle.configurationcache.extensions.capitalized
import xyz.block.ftl.Context
import xyz.block.ftl.Ignore
import xyz.block.ftl.Ingress
@@ -21,22 +20,30 @@ import xyz.block.ftl.v1.schema.Schema
import xyz.block.ftl.v1.schema.Type
import xyz.block.ftl.v1.schema.Verb
import java.io.File
+import java.nio.file.Path
+import java.nio.file.attribute.PosixFilePermission
+import kotlin.io.path.createDirectories
+import kotlin.io.path.setPosixFilePermissions
+import kotlin.io.path.writeText
class ModuleGenerator() {
fun run(schema: Schema, outputDirectory: File, module: String) {
+ val fqOutputDir = outputDirectory.absolutePath
+ prepareFtlRoot(fqOutputDir, module)
+ val sourcesDest = File(fqOutputDir, "generated-sources/ftl/ftl")
schema.modules.filter { it.name != module }.forEach {
val file = generateModule(it)
- file.writeTo(outputDirectory)
+ file.writeTo(sourcesDest)
println(
- "Generated module: ${outputDirectory.absolutePath}/ftl/${it.name}/${file.name}.kt"
+ "Generated module: ${fqOutputDir}/${it.name}/${file.name}.kt"
)
}
}
internal fun generateModule(schema: Module): FileSpec {
val namespace = "ftl.${schema.name}"
- val className = schema.name.capitalized()
+ val className = schema.name.replaceFirstChar(Char::titlecase)
val file = FileSpec.builder(namespace, className)
.addFileComment("Code generated by FTL-Plugin, do not edit.")
@@ -136,7 +143,7 @@ class ModuleGenerator() {
type.bool != null -> ClassName("kotlin", "Boolean")
type.time != null -> ClassName("java.time", "OffsetDateTime")
type.array != null -> {
- val element = type.array.element ?: throw IllegalArgumentException(
+ val element = type.array?.element ?: throw IllegalArgumentException(
"Missing element type in kotlin array generator"
)
val elementType = getTypeClass(element)
@@ -147,8 +154,8 @@ class ModuleGenerator() {
type.map != null -> {
val map = ClassName("kotlin.collections", "Map")
val key =
- type.map.key ?: throw IllegalArgumentException("Missing map key in kotlin map generator")
- val value = type.map.value_ ?: throw IllegalArgumentException(
+ type.map?.key ?: throw IllegalArgumentException("Missing map key in kotlin map generator")
+ val value = type.map?.value_ ?: throw IllegalArgumentException(
"Missing map value in kotlin map generator"
)
map.parameterizedBy(getTypeClass(key), getTypeClass(value))
@@ -160,4 +167,31 @@ class ModuleGenerator() {
else -> throw IllegalArgumentException("Unknown type in kotlin generator")
}
}
+
+ private fun prepareFtlRoot(buildDir: String, module: String) {
+ Path.of(buildDir).createDirectories()
+
+ Path.of(buildDir, "ftl.toml").writeText(
+ """
+ module = "${module}"
+ language = "kotlin"
+ deploy = ["main", "classes"]
+ """.trimIndent()
+ )
+
+ val mainFile = Path.of(buildDir, "main")
+ mainFile.writeText(
+ """
+ #!/bin/bash
+ exec java -cp ftl/jars/ftl-runtime.jar:classes xyz.block.ftl.main.MainKt
+ """.trimIndent(),
+ )
+ mainFile.setPosixFilePermissions(
+ setOf(
+ PosixFilePermission.OWNER_EXECUTE,
+ PosixFilePermission.OWNER_READ,
+ PosixFilePermission.OWNER_WRITE
+ )
+ )
+ }
}
diff --git a/kotlin-runtime/ftl-generator/src/main/kotlin/xyz/block/ftl/generator/main.kt b/kotlin-runtime/ftl-generator/src/main/kotlin/xyz/block/ftl/generator/main.kt
new file mode 100644
index 0000000000..f7f5c36146
--- /dev/null
+++ b/kotlin-runtime/ftl-generator/src/main/kotlin/xyz/block/ftl/generator/main.kt
@@ -0,0 +1,23 @@
+package xyz.block.ftl.generator
+
+import com.github.ajalt.clikt.core.CliktCommand
+import com.github.ajalt.clikt.parameters.options.option
+import com.github.ajalt.clikt.parameters.options.required
+import java.io.File
+
+class Main : CliktCommand() {
+ val endpoint by option(help = "FTL endpoint.").required()
+ val dest by option(help = "Destination directory for generated code.").required()
+ val module by option(help = "The FTL module name we're working on.").required()
+
+ override fun run() {
+ val client = FTLClient(endpoint)
+ val schema = client.getSchema()!!
+ val outputDirectory = File(dest)
+ outputDirectory.deleteRecursively()
+ val gen = ModuleGenerator()
+ gen.run(schema, outputDirectory, module)
+ }
+}
+
+fun main(args: Array) = Main().main(args)
diff --git a/kotlin-runtime/ftl-plugin/src/test/kotlin/xyz/block/ftl/gradle/ModuleGeneratorTest.kt b/kotlin-runtime/ftl-generator/src/test/kotlin/xyz/block/ftl/generator/ModuleGeneratorTest.kt
similarity index 98%
rename from kotlin-runtime/ftl-plugin/src/test/kotlin/xyz/block/ftl/gradle/ModuleGeneratorTest.kt
rename to kotlin-runtime/ftl-generator/src/test/kotlin/xyz/block/ftl/generator/ModuleGeneratorTest.kt
index 9565e71606..4277a5c0a5 100644
--- a/kotlin-runtime/ftl-plugin/src/test/kotlin/xyz/block/ftl/gradle/ModuleGeneratorTest.kt
+++ b/kotlin-runtime/ftl-generator/src/test/kotlin/xyz/block/ftl/generator/ModuleGeneratorTest.kt
@@ -1,8 +1,7 @@
-package xyz.block.ftl.gradle
+package xyz.block.ftl.generator
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
-import xyz.block.ftl.v1.PullSchemaResponse
import xyz.block.ftl.v1.schema.Array
import xyz.block.ftl.v1.schema.Bool
import xyz.block.ftl.v1.schema.Data
diff --git a/kotlin-runtime/ftl-plugin/build.gradle.kts b/kotlin-runtime/ftl-plugin/build.gradle.kts
deleted file mode 100644
index 099124e03b..0000000000
--- a/kotlin-runtime/ftl-plugin/build.gradle.kts
+++ /dev/null
@@ -1,58 +0,0 @@
-plugins {
- kotlin("jvm")
- id("java-gradle-plugin")
- id("com.squareup.wire") version "4.7.2"
-}
-
-group = "xyz.block"
-version = "1.0-SNAPSHOT"
-
-gradlePlugin {
- plugins {
- create("ftl") {
- id = "xyz.block.ftl"
- displayName = "FTL"
- implementationClass = "xyz.block.ftl.gradle.FTLPlugin"
- description = "Generate FTL stubs"
- }
- }
-}
-
-dependencies {
- compileOnly(gradleApi())
- implementation(project(":ftl-runtime"))
-
- // Use the Kotlin JUnit 5 integration.
- testImplementation(libs.kotlinTestJunit5)
-
- // Use the JUnit 5 integration.
- testImplementation(libs.junitJupiterEngine)
- testRuntimeOnly(libs.junitPlatformLauncher)
-
- implementation(libs.kotlinGradlePlugin)
- implementation(libs.kotlinPoet)
- implementation(libs.kotlinReflect)
- implementation(libs.kotlinxCoroutinesCore)
- implementation(libs.wireRuntime)
- implementation(libs.wireGrpcClient)
-}
-
-tasks.findByName("wrapper")?.enabled = false
-
-wire {
- kotlin {
- rpcRole = "client"
- rpcCallStyle = "blocking"
- }
- sourcePath {
- srcDir("../../protos")
- }
-}
-
-tasks.named("test") {
- // Use JUnit Platform for unit tests.
- useJUnitPlatform()
- testLogging {
- events("passed", "skipped", "failed")
- }
-}
diff --git a/kotlin-runtime/ftl-plugin/src/main/kotlin/xyz/block/ftl/gradle/FTLDeploy.kt b/kotlin-runtime/ftl-plugin/src/main/kotlin/xyz/block/ftl/gradle/FTLDeploy.kt
deleted file mode 100644
index 6b6e2e931b..0000000000
--- a/kotlin-runtime/ftl-plugin/src/main/kotlin/xyz/block/ftl/gradle/FTLDeploy.kt
+++ /dev/null
@@ -1,11 +0,0 @@
-package xyz.block.ftl.gradle
-
-import org.gradle.api.DefaultTask
-import org.gradle.api.tasks.TaskAction
-
-abstract class FTLDeploy : DefaultTask() {
- @TaskAction
- fun deploy() {
- println("FTL deploy")
- }
-}
diff --git a/kotlin-runtime/ftl-plugin/src/main/kotlin/xyz/block/ftl/gradle/FTLExtension.kt b/kotlin-runtime/ftl-plugin/src/main/kotlin/xyz/block/ftl/gradle/FTLExtension.kt
deleted file mode 100644
index efe5c69108..0000000000
--- a/kotlin-runtime/ftl-plugin/src/main/kotlin/xyz/block/ftl/gradle/FTLExtension.kt
+++ /dev/null
@@ -1,9 +0,0 @@
-package xyz.block.ftl.gradle
-
-import org.gradle.api.Project
-
-open class FTLExtension(project: Project) {
- var endpoint: String? = null
- var module: String = project.rootProject.name
- var outputDirectory: String = "build/generated/source"
-}
diff --git a/kotlin-runtime/ftl-plugin/src/main/kotlin/xyz/block/ftl/gradle/FTLPlugin.kt b/kotlin-runtime/ftl-plugin/src/main/kotlin/xyz/block/ftl/gradle/FTLPlugin.kt
deleted file mode 100644
index 75a454a19a..0000000000
--- a/kotlin-runtime/ftl-plugin/src/main/kotlin/xyz/block/ftl/gradle/FTLPlugin.kt
+++ /dev/null
@@ -1,79 +0,0 @@
-package xyz.block.ftl.gradle
-
-import org.gradle.api.Plugin
-import org.gradle.api.Project
-import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
-
-class FTLPlugin : Plugin {
- private lateinit var extension: FTLExtension
- private lateinit var project: Project
-
- override fun apply(project: Project) {
- project.plugins.apply("org.jetbrains.kotlin.jvm")
- this.extension = project.extensions.create("ftl", FTLExtension::class.java, project)
- this.project = project
-
- project.tasks.register("deploy", FTLDeploy::class.java) {
- it.group = "FTL"
- it.description = "Deploy FTL module"
- }
-
- project.afterEvaluate {
- check(extension.endpoint != null && extension.endpoint?.isNotEmpty() == true) {
- "FTL endpoint must be set"
- }
-
- extension.endpoint?.let {
- val client = FTLClient(it)
- val schema = client.getSchema() ?: throw RuntimeException("Failed to get schema")
- val outputDirectory = project.file(extension.outputDirectory)
- outputDirectory.deleteRecursively()
- outputDirectory.mkdir()
- extension.module.let { module ->
- ModuleGenerator().run(schema, outputDirectory, module)
- }
- }
-
- // Add generated files to sourceSets
- val kotlinExtension = project.extensions.getByType(KotlinJvmProjectExtension::class.java)
- kotlinExtension.sourceSets.findByName("main")?.kotlin?.srcDir(extension.outputDirectory)
- }
-
- project.tasks.getByName("classes").doLast { prepareFtlRoot(project) }
- }
-
- // Gather all the JAR files in the runtime classpath and copy them to
- // the build/ftl directory. These will be part of the deployment.
- private fun prepareFtlRoot(project: Project) {
- val jarFiles = mutableListOf()
- val classes = project.mkdir("build/ftl/jars")
- project.configurations.getByName("runtimeClasspath")
- .exclude(mapOf("group" to "xyz.block"))
- .exclude(mapOf("group" to "org.jetbrains.kotlin"))
- .forEach { file ->
- project.copy {
- jarFiles += file.name
- it.from(file)
- it.into(classes)
- }
- }
-
- val config = project.file("build/ftl.toml")
- config.writeText(
- """
- module = "${extension.module}"
- language = "kotlin"
- deploy = ["main", "classes/kotlin/main", "ftl"]
- """.trimIndent()
- )
-
- val script = project.file("build/main")
- script.writeText(
- """
- #!/bin/bash
- exec java -cp ftl/jars/ftl-runtime.jar:ftl/jars/${jarFiles.joinToString(":ftl/jars/")}:classes/kotlin/main xyz.block.ftl.main.MainKt
- """.trimIndent()
- )
- script.setExecutable(true)
- }
-}
diff --git a/kotlin-runtime/ftl-runtime/build.gradle.kts b/kotlin-runtime/ftl-runtime/build.gradle.kts
deleted file mode 100644
index 53024141ad..0000000000
--- a/kotlin-runtime/ftl-runtime/build.gradle.kts
+++ /dev/null
@@ -1,90 +0,0 @@
-group = "xyz.block"
-version = "0.1.0-SNAPSHOT"
-
-plugins {
- id("com.squareup.wire") version "4.7.2"
- kotlin("jvm")
- // Apply the java-library plugin for API and implementation separation.
- `java-library`
-}
-
-repositories {
- // Use Maven Central for resolving dependencies.
- mavenCentral()
-}
-
-dependencies {
- compileOnly(libs.hotswapAgentCore)
-
- // Use the Kotlin JUnit 5 integration.
- testImplementation(libs.kotlinTestJunit5)
-
- // Use the JUnit 5 integration.
- testImplementation(libs.junitJupiterEngine)
- testImplementation(libs.junitJupiterParams)
- testRuntimeOnly(libs.junitPlatformLauncher)
-
- // These dependencies are used internally, and not exposed to consumers on their own compile classpath.
- implementation(libs.classgraph)
- implementation(libs.logbackClassic)
- implementation(libs.logbackCore)
- implementation(libs.kotlinReflect)
- implementation(libs.kotlinxCoroutinesCore)
- implementation(libs.wireRuntime)
- implementation(libs.wireGrpcServer)
- implementation(libs.wireGrpcClient)
- implementation(libs.grpcNetty)
- implementation(libs.grpcProtobuf)
- implementation(libs.grpcStub)
- implementation(libs.gson)
-}
-
-// Disable gradlew because we use a Hermit-provided gradle.
-tasks.findByName("wrapper")?.enabled = false
-
-tasks.named("test") {
- // Use JUnit Platform for unit tests.
- useJUnitPlatform()
- testLogging {
- events("passed", "skipped", "failed")
- }
-}
-
-wire {
- kotlin {
- rpcRole = "server"
- rpcCallStyle = "blocking"
- grpcServerCompatible = true
- includes = listOf(
- "xyz.block.ftl.v1.VerbService"
- )
- exclusive = false
- }
- kotlin {
- rpcRole = "client"
- rpcCallStyle = "blocking"
- }
- sourcePath {
- srcDir("../../protos")
- }
-}
-
-tasks.jar {
- enabled = true
- isZip64 = true
- duplicatesStrategy = DuplicatesStrategy.EXCLUDE
-
- archiveFileName.set("${project.name}.jar")
-
- manifest {
- attributes["Main-Class"] = "xyz.block.ftl.main.MainKt"
- }
-
- from(sourceSets.main.get().output)
- dependsOn(configurations.compileClasspath)
- from({
- configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) }
- }) {
- exclude("META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA")
- }
-}
diff --git a/kotlin-runtime/ftl-runtime/pom.xml b/kotlin-runtime/ftl-runtime/pom.xml
new file mode 100644
index 0000000000..ff1f8da647
--- /dev/null
+++ b/kotlin-runtime/ftl-runtime/pom.xml
@@ -0,0 +1,106 @@
+
+
+ 4.0.0
+
+
+ xyz.block.ftl
+ ftl
+ 1.0-SNAPSHOT
+ ../../pom.xml
+
+
+ ftl-runtime
+ jar
+
+
+ ${basedir}/../..
+ false
+
+
+
+
+ org.jetbrains.kotlin
+ kotlin-reflect
+ 1.8.22
+
+
+
+ org.jetbrains.kotlinx
+ kotlinx-coroutines-core
+ 1.6.4
+
+
+
+
+ io.github.classgraph
+ classgraph
+ 4.8.157
+
+
+
+
+ com.google.code.gson
+ gson
+ 2.10.1
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+
+
+ package
+
+ single
+
+
+
+ jar-with-dependencies
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ kotlin-maven-plugin
+ org.jetbrains.kotlin
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+
+
+
+
+
+
+ github
+ GitHub Packages
+ https://maven.pkg.github.com/TBD54566975/ftl
+
+
+
+
diff --git a/kotlin-runtime/gradle.properties b/kotlin-runtime/gradle.properties
deleted file mode 100644
index b06073e44b..0000000000
--- a/kotlin-runtime/gradle.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-org.gradle.configureondemand=true
-org.gradle.parallel=true
diff --git a/kotlin-runtime/gradle/libs.versions.toml b/kotlin-runtime/gradle/libs.versions.toml
deleted file mode 100644
index 1719ce5c19..0000000000
--- a/kotlin-runtime/gradle/libs.versions.toml
+++ /dev/null
@@ -1,30 +0,0 @@
-[versions]
-wire = "4.7.2"
-grpc = "1.56.1"
-logback = "1.4.5"
-junit = "5.9.2"
-
-[libraries]
-kotlinTestJunit5 = { module = "org.jetbrains.kotlin:kotlin-test-junit5" }
-junitPlatformLauncher = { module = "org.junit.platform:junit-platform-launcher" }
-junitJupiterEngine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit" }
-junitJupiterParams = { module = "org.junit.jupiter:junit-jupiter-params", version.ref = "junit" }
-
-hotswapAgentCore = { module = "org.hotswapagent:hotswap-agent-core", version = "1.4.1" }
-classgraph = { module = "io.github.classgraph:classgraph", version = "4.8.157" }
-logbackClassic = { module = "ch.qos.logback:logback-classic", version.ref = "logback" }
-logbackCore = { module = "ch.qos.logback:logback-core", version.ref = "logback" }
-kotlinReflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version = "1.8.22" }
-kotlinxCoroutinesCore = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version = "1.6.4" }
-kotlinPoet = { module = "com.squareup:kotlinpoet", version = "1.14.2" }
-gson = { module = "com.google.code.gson:gson", version = "2.10.1" }
-wireRuntime = { module = "com.squareup.wire:wire-runtime", version.ref = "wire" }
-wireGrpcServer = { module = "com.squareup.wire:wire-grpc-server", version.ref = "wire" }
-wireGrpcClient = { module = "com.squareup.wire:wire-grpc-client", version.ref = "wire" }
-grpcNetty = { module = "io.grpc:grpc-netty", version.ref = "grpc" }
-grpcProtobuf = { module = "io.grpc:grpc-protobuf", version.ref = "grpc" }
-grpcStub = { module = "io.grpc:grpc-stub", version.ref = "grpc" }
-kotlinGradlePlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin" }
-
-[plugins]
-wire = { id = "com.squareup.wire", version.ref = "wire" }
diff --git a/kotlin-runtime/settings.gradle.kts b/kotlin-runtime/settings.gradle.kts
deleted file mode 100644
index 77ea0fcd66..0000000000
--- a/kotlin-runtime/settings.gradle.kts
+++ /dev/null
@@ -1,2 +0,0 @@
-rootProject.name = "kotlin-runtime"
-include(":ftl-plugin", ":ftl-runtime")
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000000..5792ef1fae
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,285 @@
+
+
+ 4.0.0
+
+ xyz.block.ftl
+ ftl
+ 1.0-SNAPSHOT
+ pom
+
+
+ kotlin-runtime/ftl-runtime
+ kotlin-runtime/ftl-generator
+
+
+
+ true
+ ${basedir}
+ 11
+ 1.9.0
+ true
+ 4.8.1
+ 1.56.1
+ 1.4.5
+ 5.10.0
+
+
+
+
+
+ org.junit
+ junit-bom
+ ${junit.version}
+ pom
+ import
+
+
+
+
+
+
+ org.jetbrains.kotlin
+ kotlin-stdlib
+ ${kotlin.version}
+
+
+
+
+ ch.qos.logback
+ logback-classic
+ ${logback.version}
+
+
+ ch.qos.logback
+ logback-core
+ ${logback.version}
+
+
+
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
+
+ org.jetbrains.kotlin
+ kotlin-test-junit5
+ ${kotlin.version}
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-params
+ test
+
+
+
+
+ io.grpc
+ grpc-netty
+ ${grpc.version}
+
+
+ io.grpc
+ grpc-protobuf
+ ${grpc.version}
+
+
+ io.grpc
+ grpc-stub
+ ${grpc.version}
+
+
+
+ com.squareup.wire
+ wire-runtime-jvm
+ ${wire.version}
+
+
+ com.squareup.wire
+ wire-grpc-server
+ ${wire.version}
+
+
+ com.squareup.wire
+ wire-grpc-client-jvm
+ ${wire.version}
+
+
+ org.hotswapagent
+ hotswap-agent-core
+ 1.4.1
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.1.2
+
+
+ Test*
+ *Test
+
+
+
+
+ kotlin-maven-plugin
+ org.jetbrains.kotlin
+ ${kotlin.version}
+
+
+ compile
+
+ compile
+
+
+
+ ${project.basedir}/src/main/kotlin
+
+
+
+
+ test-compile
+
+ test-compile
+
+
+
+ ${project.basedir}/src/test/kotlin
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.10.1
+
+
+ ${java.version}
+
+
+
+ default-compile
+ none
+
+
+ default-testCompile
+ none
+
+
+ java-compile
+ compile
+
+ compile
+
+
+
+ java-test-compile
+ test-compile
+
+ testCompile
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+ 3.2.0
+
+
+ initialize
+
+ copy
+
+
+
+
+ com.squareup.wire
+ wire-compiler
+ ${wire.version}
+ jar-with-dependencies
+ wire-compiler.jar
+
+
+
+
+
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ 3.0.0
+
+
+ wire-client
+ initialize
+
+ exec
+
+
+ java
+
+ -jar
+ target/dependency/wire-compiler.jar
+ --proto_path=${rootDir}/protos
+ --kotlin_out=${project.build.directory}/generated-sources/wire
+ --kotlin_rpc_role=client
+
+
+
+
+ wire-server
+ initialize
+
+ exec
+
+
+ java
+
+ -jar
+ target/dependency/wire-compiler.jar
+ --proto_path=${rootDir}/protos
+ --kotlin_out=target/generated-sources/wire
+ --kotlin_rpc_role=server
+ --kotlin_rpc_call_style=blocking
+ --kotlin_grpc_server_compatible
+ --includes=xyz.block.ftl.v1.VerbService
+
+
+
+
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+ 3.2.0
+
+
+ generate-sources
+
+ add-source
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/scripts/ftl-dev b/scripts/ftl-dev
index b8b585d80d..eb3441df5b 100755
--- a/scripts/ftl-dev
+++ b/scripts/ftl-dev
@@ -5,9 +5,7 @@ top="$(git rev-parse --show-toplevel)"
cd "${top}"
prepare_template() (
- mkdir -p build/template/ftl/jars
- (cd "${top}/kotlin-runtime/ftl-runtime" && gradle jar)
- cp "${top}/kotlin-runtime/ftl-runtime/build/libs/ftl-runtime.jar" build/template/ftl/jars
+ make build/template/ftl/jars/ftl-runtime.jar
)
prepare_template
diff --git a/scripts/ftl-run b/scripts/ftl-run
index 285591351d..5b30538c7a 100755
--- a/scripts/ftl-run
+++ b/scripts/ftl-run
@@ -5,9 +5,7 @@ top="$(git rev-parse --show-toplevel)"
cd "${top}"
prepare_template() (
- mkdir -p build/template/ftl/jars
- (cd "${top}/kotlin-runtime/ftl-runtime" && gradle jar)
- cp "${top}/kotlin-runtime/ftl-runtime/build/libs/ftl-runtime.jar" build/template/ftl/jars
+ make build/template/ftl/jars/ftl-runtime.jar
)
build() {
diff --git a/scripts/integration-tests b/scripts/integration-tests
index be0dc0b42e..ae98c6551e 100755
--- a/scripts/integration-tests
+++ b/scripts/integration-tests
@@ -43,18 +43,17 @@ start_cluster() {
prepare_runner() (
info "Preparing runner template directory"
+ mvn -pl :ftl-generator install
mkdir -p build/template/ftl/jars build/runner0 build/runner1
- test -r build/libs/ftl-runtime.jar && return 0
- cd kotlin-runtime/ftl-runtime
- gradle jar
- cp build/libs/ftl-runtime.jar ../../build/template/ftl/jars
+ test -r build/template/ftl/jars/ftl-runtime.jar && return 0
+ make build/template/ftl/jars/ftl-runtime.jar
)
deploy_echo_kotlin() (
info "Deploying echo-kotlin"
cd examples/echo-kotlin
- gradle build
- ftl deploy ./build
+ mvn compile
+ ftl deploy target
)
deploy_time_go() (