diff --git a/Bitfile b/Bitfile index e7b6f09ee6..40e94ad605 100644 --- a/Bitfile +++ b/Bitfile @@ -54,7 +54,7 @@ NODE_MODULES_IN = console/client/package{,-lock}.json %{RELEASE}/ftl-runner: %{RELEASE} %{GO_SOURCES} cmd/ftl-runner/**/*.go build: go build -o %{OUT} -tags release -ldflags "-X main.version=%{VERSION} -X main.timestamp=$(date +%s)" ./cmd/ftl-runner -%{RELEASE}/ftl: %{RELEASE} %{GO_SOURCES} cmd/ftl/**/*.go go-runtime/scaffolding.zip +%{RELEASE}/ftl: %{RELEASE} %{GO_SOURCES} cmd/ftl/**/*.go {go,kotlin}-runtime/scaffolding.zip build: go build -o %{OUT} -tags release -ldflags "-X main.version=%{VERSION} -X main.timestamp=$(date +%s)" ./cmd/ftl %{RELEASE}/ftl-initdb: %{RELEASE} %{GO_SOURCES} cmd/ftl-initdb/**/*.go @@ -62,10 +62,14 @@ NODE_MODULES_IN = console/client/package{,-lock}.json # Release builds include zipped scaffolding becaused raw go:embed doesn't # preserve permissions or symlinks. Irritating. -go-runtime/scaffolding.zip: go-runtime/scaffolding/* +go-runtime/scaffolding.zip: go-runtime/scaffolding/**/* cd go-runtime/scaffolding build: zip -q --symlinks -r ../scaffolding.zip . +kotlin-runtime/scaffolding.zip: kotlin-runtime/scaffolding/**/* + cd kotlin-runtime/scaffolding + build: zip -q --symlinks -r ../scaffolding.zip . + %{SCHEMA_OUT}: %{SCHEMA_IN} build: ftl-schema > %{OUT} diff --git a/Makefile b/Makefile index 55aeeb116e..bf377b6ae6 100644 --- a/Makefile +++ b/Makefile @@ -58,6 +58,7 @@ build/release/%: console/client/dist/index.html build/release/ftl: cd go-runtime/scaffolding && zip -q --symlinks -r ../scaffolding.zip . + cd kotlin-runtime/scaffolding && zip -q --symlinks -r ../scaffolding.zip . go build -o $@ -tags release -ldflags "-X main.version=$(VERSION) -X main.timestamp=$(shell date +%s)" ./cmd/ftl $(KT_MVN_OUT): $(KT_RUNTIME_IN) diff --git a/cmd/ftl/cmd_init.go b/cmd/ftl/cmd_init.go index 4c0ed6a094..e7f03634c4 100644 --- a/cmd/ftl/cmd_init.go +++ b/cmd/ftl/cmd_init.go @@ -11,6 +11,7 @@ import ( "github.com/TBD54566975/ftl/backend/common/log" goruntime "github.com/TBD54566975/ftl/go-runtime" "github.com/TBD54566975/ftl/internal" + kotlinruntime "github.com/TBD54566975/ftl/kotlin-runtime" ) type initCmd struct { @@ -21,8 +22,8 @@ type initCmd struct { type initGoCmd struct { Dir string `arg:"" default:"." type:"dir" help:"Directory to initialize the module in."` - Name string `help:"Name of the FTL module (defaults to name of directory)."` - GoModule string `required:"" help:"Go module path."` + Name string `short:"n" help:"Name of the FTL module (defaults to name of directory)."` + GoModule string `short:"G" required:"" help:"Go module import path."` } func (i initGoCmd) Run(ctx context.Context, parent *initCmd) error { @@ -44,9 +45,21 @@ func (i initGoCmd) Run(ctx context.Context, parent *initCmd) error { } type initKotlinCmd struct { - Dir string `arg:"" default:"." help:"Directory to initialize the module in."` + Dir string `arg:"" default:"." help:"Directory to initialize the module in."` + Name string `short:"n" help:"Name of the FTL module (defaults to name of directory)."` } -func (i *initKotlinCmd) Run() error { - panic("??") +func (i *initKotlinCmd) Run(parent *initCmd) error { + if i.Name == "" { + i.Name = filepath.Base(i.Dir) + } + if err := internal.Scaffold(kotlinruntime.Files, i.Dir, i); err != nil { + return errors.WithStack(err) + } + if !parent.Hermit { + if err := os.RemoveAll(filepath.Join(i.Dir, "bin")); err != nil { + return errors.WithStack(err) + } + } + return nil } diff --git a/internal/scaffolder.go b/internal/scaffolder.go index 93efb594d0..486d5d60f7 100644 --- a/internal/scaffolder.go +++ b/internal/scaffolder.go @@ -24,9 +24,9 @@ func Scaffold(source *zip.Reader, destination string, ctx any) error { if err != nil { return errors.WithStack(err) } - return errors.WithStack(filepath.WalkDir(destination, func(path string, d fs.DirEntry, err error) error { + return errors.WithStack(walkDir(destination, func(path string, d fs.DirEntry) error { if err != nil { - return err + return errors.WithStack(err) } info, err := d.Info() if err != nil { @@ -34,12 +34,15 @@ func Scaffold(source *zip.Reader, destination string, ctx any) error { } // Evaluate path name templates. - newName, err := evaluate(path, ctx) + dir := filepath.Dir(path) + base := filepath.Base(path) + newName, err := evaluate(base, ctx) if err != nil { return errors.Wrapf(err, "%s", path) } // Rename if necessary. - if newName != path { + if newName != base { + newName = filepath.Join(dir, newName) err = os.Rename(path, newName) if err != nil { return errors.Wrap(err, "failed to rename file") @@ -68,6 +71,26 @@ func Scaffold(source *zip.Reader, destination string, ctx any) error { })) } +func walkDir(dir string, fn func(path string, d fs.DirEntry) error) error { + entries, err := os.ReadDir(dir) + if err != nil { + return errors.WithStack(err) + } + for _, entry := range entries { + if entry.IsDir() { + err = walkDir(filepath.Join(dir, entry.Name()), fn) + if err != nil { + return errors.WithStack(err) + } + } + err = fn(filepath.Join(dir, entry.Name()), entry) + if err != nil { + return errors.WithStack(err) + } + } + return nil +} + func evaluate(tmpl string, ctx any) (string, error) { t, err := template.New("scaffolding").Funcs( template.FuncMap{ diff --git a/kotlin-runtime/devel.go b/kotlin-runtime/devel.go new file mode 100644 index 0000000000..b35d498cb1 --- /dev/null +++ b/kotlin-runtime/devel.go @@ -0,0 +1,47 @@ +//go:build !release + +package kotlinruntime + +import ( + "archive/zip" + "os" + "os/exec" + "path/filepath" + "strings" + + "github.com/TBD54566975/ftl/internal" +) + +// Files is the FTL Kotlin runtime scaffolding files. +var Files = func() *zip.Reader { + cmd := exec.Command("git", "rev-parse", "--show-toplevel") + out, err := cmd.CombinedOutput() + if err != nil { + panic(err) + } + dir := filepath.Join(strings.TrimSpace(string(out)), "kotlin-runtime", "scaffolding") + w, err := os.CreateTemp("", "") + if err != nil { + panic(err) + } + defer os.Remove(w.Name()) // This is okay because the zip.Reader will keep it open. + if err != nil { + panic(err) + } + + err = internal.ZipDir(dir, w.Name()) + if err != nil { + panic(err) + } + + info, err := w.Stat() + if err != nil { + panic(err) + } + _, _ = w.Seek(0, 0) + zr, err := zip.NewReader(w, info.Size()) + if err != nil { + panic(err) + } + return zr +}() diff --git a/kotlin-runtime/release.go b/kotlin-runtime/release.go new file mode 100644 index 0000000000..ffdf9e3416 --- /dev/null +++ b/kotlin-runtime/release.go @@ -0,0 +1,24 @@ +//go:build release + +package goruntime + +import ( + "archive/zip" + "bytes" + _ "embed" +) + +//go:embed scaffolding.zip +var archive []byte + +// Files is the FTL Kotlin runtime scaffolding files. +// +// scaffolding.zip can be generated by running `bit kotlin-runtime/scaffolding.zip` +// or indirectly via `bit build/release/ftl`. +var Files = func() *zip.Reader { + zr, err := zip.NewReader(bytes.NewReader(archive), int64(len(archive))) + if err != nil { + panic(err) + } + return zr +}() diff --git a/kotlin-runtime/scaffolding/bin/.maven-3.8.6.pkg b/kotlin-runtime/scaffolding/bin/.maven-3.8.6.pkg new file mode 120000 index 0000000000..383f4511d4 --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/.maven-3.8.6.pkg @@ -0,0 +1 @@ +hermit \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/bin/.openjdk-17.0.8_7.pkg b/kotlin-runtime/scaffolding/bin/.openjdk-17.0.8_7.pkg new file mode 120000 index 0000000000..383f4511d4 --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/.openjdk-17.0.8_7.pkg @@ -0,0 +1 @@ +hermit \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/bin/README.hermit.md b/kotlin-runtime/scaffolding/bin/README.hermit.md new file mode 100644 index 0000000000..e889550ba4 --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/README.hermit.md @@ -0,0 +1,7 @@ +# Hermit environment + +This is a [Hermit](https://github.com/cashapp/hermit) bin directory. + +The symlinks in this directory are managed by Hermit and will automatically +download and install Hermit itself as well as packages. These packages are +local to this environment. diff --git a/kotlin-runtime/scaffolding/bin/activate-hermit b/kotlin-runtime/scaffolding/bin/activate-hermit new file mode 100755 index 0000000000..fe28214d33 --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/activate-hermit @@ -0,0 +1,21 @@ +#!/bin/bash +# This file must be used with "source bin/activate-hermit" from bash or zsh. +# You cannot run it directly +# +# THIS FILE IS GENERATED; DO NOT MODIFY + +if [ "${BASH_SOURCE-}" = "$0" ]; then + echo "You must source this script: \$ source $0" >&2 + exit 33 +fi + +BIN_DIR="$(dirname "${BASH_SOURCE[0]:-${(%):-%x}}")" +if "${BIN_DIR}/hermit" noop > /dev/null; then + eval "$("${BIN_DIR}/hermit" activate "${BIN_DIR}/..")" + + if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ]; then + hash -r 2>/dev/null + fi + + echo "Hermit environment $("${HERMIT_ENV}"/bin/hermit env HERMIT_ENV) activated" +fi diff --git a/kotlin-runtime/scaffolding/bin/hermit b/kotlin-runtime/scaffolding/bin/hermit new file mode 100755 index 0000000000..7fef769248 --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/hermit @@ -0,0 +1,43 @@ +#!/bin/bash +# +# THIS FILE IS GENERATED; DO NOT MODIFY + +set -eo pipefail + +export HERMIT_USER_HOME=~ + +if [ -z "${HERMIT_STATE_DIR}" ]; then + case "$(uname -s)" in + Darwin) + export HERMIT_STATE_DIR="${HERMIT_USER_HOME}/Library/Caches/hermit" + ;; + Linux) + export HERMIT_STATE_DIR="${XDG_CACHE_HOME:-${HERMIT_USER_HOME}/.cache}/hermit" + ;; + esac +fi + +export HERMIT_DIST_URL="${HERMIT_DIST_URL:-https://github.com/cashapp/hermit/releases/download/stable}" +HERMIT_CHANNEL="$(basename "${HERMIT_DIST_URL}")" +export HERMIT_CHANNEL +export HERMIT_EXE=${HERMIT_EXE:-${HERMIT_STATE_DIR}/pkg/hermit@${HERMIT_CHANNEL}/hermit} + +if [ ! -x "${HERMIT_EXE}" ]; then + echo "Bootstrapping ${HERMIT_EXE} from ${HERMIT_DIST_URL}" 1>&2 + INSTALL_SCRIPT="$(mktemp)" + # This value must match that of the install script + INSTALL_SCRIPT_SHA256="180e997dd837f839a3072a5e2f558619b6d12555cd5452d3ab19d87720704e38" + if [ "${INSTALL_SCRIPT_SHA256}" = "BYPASS" ]; then + curl -fsSL "${HERMIT_DIST_URL}/install.sh" -o "${INSTALL_SCRIPT}" + else + # Install script is versioned by its sha256sum value + curl -fsSL "${HERMIT_DIST_URL}/install-${INSTALL_SCRIPT_SHA256}.sh" -o "${INSTALL_SCRIPT}" + # Verify install script's sha256sum + openssl dgst -sha256 "${INSTALL_SCRIPT}" | \ + awk -v EXPECTED="$INSTALL_SCRIPT_SHA256" \ + '$2!=EXPECTED {print "Install script sha256 " $2 " does not match " EXPECTED; exit 1}' + fi + /bin/bash "${INSTALL_SCRIPT}" 1>&2 +fi + +exec "${HERMIT_EXE}" --level=fatal exec "$0" -- "$@" diff --git a/kotlin-runtime/scaffolding/bin/hermit.hcl b/kotlin-runtime/scaffolding/bin/hermit.hcl new file mode 100644 index 0000000000..e69de29bb2 diff --git a/kotlin-runtime/scaffolding/bin/jar b/kotlin-runtime/scaffolding/bin/jar new file mode 120000 index 0000000000..7d19c5ad1d --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/jar @@ -0,0 +1 @@ +.openjdk-17.0.8_7.pkg \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/bin/jarsigner b/kotlin-runtime/scaffolding/bin/jarsigner new file mode 120000 index 0000000000..7d19c5ad1d --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/jarsigner @@ -0,0 +1 @@ +.openjdk-17.0.8_7.pkg \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/bin/java b/kotlin-runtime/scaffolding/bin/java new file mode 120000 index 0000000000..7d19c5ad1d --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/java @@ -0,0 +1 @@ +.openjdk-17.0.8_7.pkg \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/bin/javac b/kotlin-runtime/scaffolding/bin/javac new file mode 120000 index 0000000000..7d19c5ad1d --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/javac @@ -0,0 +1 @@ +.openjdk-17.0.8_7.pkg \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/bin/javadoc b/kotlin-runtime/scaffolding/bin/javadoc new file mode 120000 index 0000000000..7d19c5ad1d --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/javadoc @@ -0,0 +1 @@ +.openjdk-17.0.8_7.pkg \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/bin/javap b/kotlin-runtime/scaffolding/bin/javap new file mode 120000 index 0000000000..7d19c5ad1d --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/javap @@ -0,0 +1 @@ +.openjdk-17.0.8_7.pkg \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/bin/jcmd b/kotlin-runtime/scaffolding/bin/jcmd new file mode 120000 index 0000000000..7d19c5ad1d --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/jcmd @@ -0,0 +1 @@ +.openjdk-17.0.8_7.pkg \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/bin/jconsole b/kotlin-runtime/scaffolding/bin/jconsole new file mode 120000 index 0000000000..7d19c5ad1d --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/jconsole @@ -0,0 +1 @@ +.openjdk-17.0.8_7.pkg \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/bin/jdb b/kotlin-runtime/scaffolding/bin/jdb new file mode 120000 index 0000000000..7d19c5ad1d --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/jdb @@ -0,0 +1 @@ +.openjdk-17.0.8_7.pkg \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/bin/jdeprscan b/kotlin-runtime/scaffolding/bin/jdeprscan new file mode 120000 index 0000000000..7d19c5ad1d --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/jdeprscan @@ -0,0 +1 @@ +.openjdk-17.0.8_7.pkg \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/bin/jdeps b/kotlin-runtime/scaffolding/bin/jdeps new file mode 120000 index 0000000000..7d19c5ad1d --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/jdeps @@ -0,0 +1 @@ +.openjdk-17.0.8_7.pkg \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/bin/jfr b/kotlin-runtime/scaffolding/bin/jfr new file mode 120000 index 0000000000..7d19c5ad1d --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/jfr @@ -0,0 +1 @@ +.openjdk-17.0.8_7.pkg \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/bin/jhsdb b/kotlin-runtime/scaffolding/bin/jhsdb new file mode 120000 index 0000000000..7d19c5ad1d --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/jhsdb @@ -0,0 +1 @@ +.openjdk-17.0.8_7.pkg \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/bin/jimage b/kotlin-runtime/scaffolding/bin/jimage new file mode 120000 index 0000000000..7d19c5ad1d --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/jimage @@ -0,0 +1 @@ +.openjdk-17.0.8_7.pkg \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/bin/jinfo b/kotlin-runtime/scaffolding/bin/jinfo new file mode 120000 index 0000000000..7d19c5ad1d --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/jinfo @@ -0,0 +1 @@ +.openjdk-17.0.8_7.pkg \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/bin/jlink b/kotlin-runtime/scaffolding/bin/jlink new file mode 120000 index 0000000000..7d19c5ad1d --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/jlink @@ -0,0 +1 @@ +.openjdk-17.0.8_7.pkg \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/bin/jmap b/kotlin-runtime/scaffolding/bin/jmap new file mode 120000 index 0000000000..7d19c5ad1d --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/jmap @@ -0,0 +1 @@ +.openjdk-17.0.8_7.pkg \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/bin/jmod b/kotlin-runtime/scaffolding/bin/jmod new file mode 120000 index 0000000000..7d19c5ad1d --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/jmod @@ -0,0 +1 @@ +.openjdk-17.0.8_7.pkg \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/bin/jpackage b/kotlin-runtime/scaffolding/bin/jpackage new file mode 120000 index 0000000000..7d19c5ad1d --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/jpackage @@ -0,0 +1 @@ +.openjdk-17.0.8_7.pkg \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/bin/jps b/kotlin-runtime/scaffolding/bin/jps new file mode 120000 index 0000000000..7d19c5ad1d --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/jps @@ -0,0 +1 @@ +.openjdk-17.0.8_7.pkg \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/bin/jrunscript b/kotlin-runtime/scaffolding/bin/jrunscript new file mode 120000 index 0000000000..7d19c5ad1d --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/jrunscript @@ -0,0 +1 @@ +.openjdk-17.0.8_7.pkg \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/bin/jshell b/kotlin-runtime/scaffolding/bin/jshell new file mode 120000 index 0000000000..7d19c5ad1d --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/jshell @@ -0,0 +1 @@ +.openjdk-17.0.8_7.pkg \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/bin/jstack b/kotlin-runtime/scaffolding/bin/jstack new file mode 120000 index 0000000000..7d19c5ad1d --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/jstack @@ -0,0 +1 @@ +.openjdk-17.0.8_7.pkg \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/bin/jstat b/kotlin-runtime/scaffolding/bin/jstat new file mode 120000 index 0000000000..7d19c5ad1d --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/jstat @@ -0,0 +1 @@ +.openjdk-17.0.8_7.pkg \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/bin/jstatd b/kotlin-runtime/scaffolding/bin/jstatd new file mode 120000 index 0000000000..7d19c5ad1d --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/jstatd @@ -0,0 +1 @@ +.openjdk-17.0.8_7.pkg \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/bin/keytool b/kotlin-runtime/scaffolding/bin/keytool new file mode 120000 index 0000000000..7d19c5ad1d --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/keytool @@ -0,0 +1 @@ +.openjdk-17.0.8_7.pkg \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/bin/mvn b/kotlin-runtime/scaffolding/bin/mvn new file mode 120000 index 0000000000..e51d3a75c9 --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/mvn @@ -0,0 +1 @@ +.maven-3.8.6.pkg \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/bin/rmiregistry b/kotlin-runtime/scaffolding/bin/rmiregistry new file mode 120000 index 0000000000..7d19c5ad1d --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/rmiregistry @@ -0,0 +1 @@ +.openjdk-17.0.8_7.pkg \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/bin/serialver b/kotlin-runtime/scaffolding/bin/serialver new file mode 120000 index 0000000000..7d19c5ad1d --- /dev/null +++ b/kotlin-runtime/scaffolding/bin/serialver @@ -0,0 +1 @@ +.openjdk-17.0.8_7.pkg \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/ftl.toml b/kotlin-runtime/scaffolding/ftl.toml new file mode 100644 index 0000000000..95a2f1044a --- /dev/null +++ b/kotlin-runtime/scaffolding/ftl.toml @@ -0,0 +1,8 @@ +module = "{{ .Name | lower }}" +language = "kotlin" +deploy = [ + "target/main", + "target/classes", + "target/dependency", + "target/classpath.txt", +] diff --git a/kotlin-runtime/scaffolding/pom.xml b/kotlin-runtime/scaffolding/pom.xml new file mode 100644 index 0000000000..b71e002b53 --- /dev/null +++ b/kotlin-runtime/scaffolding/pom.xml @@ -0,0 +1,161 @@ + + + 4.0.0 + ftl + ftl-module-{{ .Name | lower }} + 1.0-SNAPSHOT + + + 1.0-SNAPSHOT + 11 + 1.9.0 + true + + + + + org.jetbrains.kotlin + kotlin-stdlib + ${kotlin.version} + + + xyz.block + ftl-runtime + ${ftl.version} + + + xyz.block + 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-generator + ${ftl.version} + jar-with-dependencies + ftl-generator.jar + + + + + + + copy-dependencies + compile + + copy-dependencies + + + ${project.build.directory}/dependency + runtime + + + + + build-classpath + compile + + build-classpath + + + ${project.build.directory}/classpath.txt + dependency + + + + + + + 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 + --module-client-suffix=ModuleClient + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 3.2.0 + + + generate-sources + + add-source + + + + ${project.build.directory}/generated-sources/ftl + + + + + + + + \ No newline at end of file diff --git a/kotlin-runtime/scaffolding/src/main/kotlin/ftl/{{ .Name | lower }}/{{ .Name | camel }}.kt b/kotlin-runtime/scaffolding/src/main/kotlin/ftl/{{ .Name | lower }}/{{ .Name | camel }}.kt new file mode 100644 index 0000000000..15604c4d50 --- /dev/null +++ b/kotlin-runtime/scaffolding/src/main/kotlin/ftl/{{ .Name | lower }}/{{ .Name | camel }}.kt @@ -0,0 +1,17 @@ +package ftl.{{ .Name | lower }} + +import xyz.block.ftl.Context +import xyz.block.ftl.Ingress +import xyz.block.ftl.Method +import xyz.block.ftl.Verb + +data class {{ .Name | camel }}Request(val name: String) +data class {{ .Name | camel }}Response(val message: String) + +class {{ .Name | camel }} { + @Verb + fun {{ .Name | lower }}(context: Context, req: {{ .Name | camel }}Request): {{ .Name | camel }}Response { + return {{ .Name | camel }}Response(message = "Hello, ${req.name}!") + } +} +