diff --git a/buildengine/build_kotlin.go b/buildengine/build_kotlin.go
index 66235c60a9..9972db956f 100644
--- a/buildengine/build_kotlin.go
+++ b/buildengine/build_kotlin.go
@@ -40,7 +40,7 @@ func (e externalModuleContext) ExternalModules() []*schema.Module {
func buildKotlin(ctx context.Context, sch *schema.Schema, module Module) error {
logger := log.FromContext(ctx)
- if err := SetPOMProperties(ctx, filepath.Join(module.Dir, "..")); err != nil {
+ if err := SetPOMProperties(ctx, module.Dir); err != nil {
return fmt.Errorf("unable to update ftl.version in %s: %w", module.Dir, err)
}
diff --git a/cmd/ftl/cmd_init.go b/cmd/ftl/cmd_init.go
index 4461d42a3f..57ea6bfc85 100644
--- a/cmd/ftl/cmd_init.go
+++ b/cmd/ftl/cmd_init.go
@@ -11,9 +11,6 @@ import (
"path/filepath"
"strings"
- "github.com/TBD54566975/scaffolder"
- "github.com/beevik/etree"
-
"github.com/TBD54566975/ftl/backend/schema"
"github.com/TBD54566975/ftl/backend/schema/strcase"
"github.com/TBD54566975/ftl/buildengine"
@@ -22,6 +19,7 @@ import (
"github.com/TBD54566975/ftl/internal/exec"
"github.com/TBD54566975/ftl/internal/log"
kotlinruntime "github.com/TBD54566975/ftl/kotlin-runtime"
+ "github.com/TBD54566975/scaffolder"
)
type initCmd struct {
@@ -72,52 +70,16 @@ func (i initKotlinCmd) Run(ctx context.Context, parent *initCmd) error {
return fmt.Errorf("module name %q is invalid", i.Name)
}
- if _, err := os.Stat(filepath.Join(i.Dir, "ftl-module-"+i.Name)); err == nil {
+ moduleDir := filepath.Join(i.Dir, i.Name)
+ if _, err := os.Stat(moduleDir); err == nil {
return fmt.Errorf("module directory %s already exists", filepath.Join(i.Dir, i.Name))
}
- options := []scaffolder.Option{}
-
- // Update root POM if it already exists.
- pomFile := filepath.Join(i.Dir, "pom.xml")
- if _, err := os.Stat(pomFile); err == nil {
- options = append(options, scaffolder.Exclude("^pom.xml$"))
- if err := updatePom(pomFile, i.Name); err != nil {
- return err
- }
- }
-
- if err := scaffold(parent.Hermit, kotlinruntime.Files(), i.Dir, i, options...); err != nil {
+ if err := scaffold(parent.Hermit, kotlinruntime.Files(), i.Dir, i); err != nil {
return err
}
- return buildengine.SetPOMProperties(ctx, i.Dir)
-}
-
-func updatePom(pomFile, name string) error {
- tree := etree.NewDocument()
- err := tree.ReadFromFile(pomFile)
- if err != nil {
- return err
- }
-
- // Add new module entry to root of XML file
- root := tree.Root()
- modules := root.SelectElement("modules")
- if modules == nil {
- modules = root.CreateElement("modules")
- }
- modules.CreateText(" ")
- module := modules.CreateElement("module")
- module.SetText("ftl-module-" + name)
- modules.CreateText("\n ")
-
- // Write updated XML file back to disk
- err = tree.WriteToFile(pomFile)
- if err != nil {
- return err
- }
- return nil
+ return buildengine.SetPOMProperties(ctx, moduleDir)
}
func unzipToTmpDir(reader *zip.Reader) (string, error) {
diff --git a/examples/kotlin/ftl-module-echo/ftl.toml b/examples/kotlin/echo/ftl.toml
similarity index 100%
rename from examples/kotlin/ftl-module-echo/ftl.toml
rename to examples/kotlin/echo/ftl.toml
diff --git a/examples/kotlin/pom.xml b/examples/kotlin/echo/pom.xml
similarity index 86%
rename from examples/kotlin/pom.xml
rename to examples/kotlin/echo/pom.xml
index 7cd8e9adc2..f780cdb19f 100644
--- a/examples/kotlin/pom.xml
+++ b/examples/kotlin/echo/pom.xml
@@ -3,21 +3,14 @@
4.0.0
ftl
- ftl
+ echo
1.0-SNAPSHOT
- pom
-
-
- ftl-module-echo
- ftl-module-time
-
-
1.0-SNAPSHOT
- http://localhost:8892
+ http://127.0.0.1:8892
1.8
- 1.9.0
+ 1.9.22
true
${java.version}
${java.version}
@@ -37,7 +30,7 @@
org.postgresql
postgresql
- 42.7.1
+ 42.7.2
@@ -76,7 +69,7 @@
org.apache.maven.plugins
maven-dependency-plugin
- 3.2.0
+ 3.6.1
@@ -119,7 +112,7 @@
org.codehaus.mojo
build-helper-maven-plugin
- 3.2.0
+ 3.5.0
generate-sources
@@ -137,7 +130,7 @@
com.github.ozsie
detekt-maven-plugin
- 1.23.3.1
+ 1.23.5
true
${generated.classpath}
@@ -169,5 +162,25 @@
+
+
+ kotlin-maven-plugin
+ org.jetbrains.kotlin
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+
+
+
+ com.github.ozsie
+ detekt-maven-plugin
+
+
-
+
\ No newline at end of file
diff --git a/examples/kotlin/ftl-module-echo/src/main/kotlin/ftl/echo/Echo.kt b/examples/kotlin/echo/src/main/kotlin/ftl/echo/Echo.kt
similarity index 100%
rename from examples/kotlin/ftl-module-echo/src/main/kotlin/ftl/echo/Echo.kt
rename to examples/kotlin/echo/src/main/kotlin/ftl/echo/Echo.kt
diff --git a/examples/kotlin/ftl-module-echo/pom.xml b/examples/kotlin/ftl-module-echo/pom.xml
deleted file mode 100644
index d107548c27..0000000000
--- a/examples/kotlin/ftl-module-echo/pom.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
- 4.0.0
- ftl
- ftl-module-echo
- 1.0-SNAPSHOT
-
- ftl
- ftl
- 1.0-SNAPSHOT
-
-
-
- echo
-
-
-
-
-
- kotlin-maven-plugin
- org.jetbrains.kotlin
-
-
- org.apache.maven.plugins
- maven-dependency-plugin
-
-
-
- org.codehaus.mojo
- build-helper-maven-plugin
-
-
-
- com.github.ozsie
- detekt-maven-plugin
-
-
-
-
\ No newline at end of file
diff --git a/examples/kotlin/ftl-module-time/pom.xml b/examples/kotlin/ftl-module-time/pom.xml
deleted file mode 100644
index 05d4e2356d..0000000000
--- a/examples/kotlin/ftl-module-time/pom.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
- 4.0.0
- ftl
- ftl-module-time
- 1.0-SNAPSHOT
-
- ftl
- ftl
- 1.0-SNAPSHOT
-
-
-
- time
-
-
-
-
-
- kotlin-maven-plugin
- org.jetbrains.kotlin
-
-
- org.apache.maven.plugins
- maven-dependency-plugin
-
-
-
- org.codehaus.mojo
- build-helper-maven-plugin
-
-
-
- com.github.ozsie
- detekt-maven-plugin
-
-
-
-
\ No newline at end of file
diff --git a/examples/kotlin/ftl-module-time/ftl.toml b/examples/kotlin/time/ftl.toml
similarity index 100%
rename from examples/kotlin/ftl-module-time/ftl.toml
rename to examples/kotlin/time/ftl.toml
diff --git a/examples/kotlin/time/pom.xml b/examples/kotlin/time/pom.xml
new file mode 100644
index 0000000000..bc621e43d7
--- /dev/null
+++ b/examples/kotlin/time/pom.xml
@@ -0,0 +1,186 @@
+
+
+ 4.0.0
+
+ ftl
+ echo2
+ 1.0-SNAPSHOT
+
+
+ 1.0-SNAPSHOT
+ http://127.0.0.1:8892
+ 1.8
+ 1.9.22
+ true
+ ${java.version}
+ ${java.version}
+
+
+
+
+ org.jetbrains.kotlin
+ kotlin-stdlib
+ ${kotlin.version}
+
+
+ xyz.block
+ ftl-runtime
+ ${ftl.version}
+
+
+ org.postgresql
+ postgresql
+ 42.7.2
+
+
+
+
+
+
+
+ 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.6.1
+
+
+
+ copy-dependencies
+ compile
+
+ copy-dependencies
+
+
+ ${project.build.directory}/dependency
+ runtime
+
+
+
+
+ build-classpath
+ compile
+
+ build-classpath
+
+
+ ${project.build.directory}/classpath.txt
+ dependency
+
+
+
+ build-classpath-property
+ compile
+
+ build-classpath
+
+
+ generated.classpath
+ ${project.build.directory}/dependency
+
+
+
+
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+ 3.5.0
+
+
+ generate-sources
+
+ add-source
+
+
+
+
+
+
+
+
+
+
+ com.github.ozsie
+ detekt-maven-plugin
+ 1.23.5
+
+ true
+ ${generated.classpath}
+ ${java.version}
+ ${java.home}
+ ${project.build.directory}/detekt.yml
+
+
+ ${project.build.directory}/dependency/ftl-runtime-${ftl.version}.jar
+
+
+ ${project.basedir}/src/main/kotlin,${project.build.directory}/generated-sources
+
+
+
+ compile
+
+ check-with-type-resolution
+
+
+
+
+
+ xyz.block
+ ftl-runtime
+ ${ftl.version}
+
+
+
+
+
+
+
+ kotlin-maven-plugin
+ org.jetbrains.kotlin
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+
+
+
+ com.github.ozsie
+ detekt-maven-plugin
+
+
+
+
\ No newline at end of file
diff --git a/examples/kotlin/ftl-module-time/src/main/kotlin/ftl/time/Time.kt b/examples/kotlin/time/src/main/kotlin/ftl/time/Time.kt
similarity index 100%
rename from examples/kotlin/ftl-module-time/src/main/kotlin/ftl/time/Time.kt
rename to examples/kotlin/time/src/main/kotlin/ftl/time/Time.kt
diff --git a/integration/integration_test.go b/integration/integration_test.go
index 4b3ed26140..34df7c85c8 100644
--- a/integration/integration_test.go
+++ b/integration/integration_test.go
@@ -301,19 +301,20 @@ func getRuntimeData(moduleName string, modulesDir string, runtime string) runtim
panic(err)
}
ftlRoot := filepath.Join(cwd, "..")
+ modulesDir = filepath.Join(modulesDir, runtime)
+ os.MkdirAll(modulesDir, os.ModePerm)
t := runtimeData{
testSuffix: strcase.ToUpperCamel(runtime),
moduleName: moduleName,
+ moduleRoot: filepath.Join(modulesDir, moduleName),
}
switch runtime {
case "go":
- t.moduleRoot = filepath.Join(modulesDir, t.moduleName)
t.modulePath = t.moduleRoot
// include replace flag to use local ftl in go.mod
t.initOpts = []string{"init", runtime, modulesDir, t.moduleName, "--replace", fmt.Sprintf("github.com/TBD54566975/ftl=%s", ftlRoot)}
case "kotlin":
- t.moduleRoot = filepath.Join(modulesDir, fmt.Sprintf("ftl-module-%s", t.moduleName))
t.modulePath = filepath.Join(t.moduleRoot, "src/main/kotlin/ftl", t.moduleName)
t.initOpts = []string{"init", runtime, modulesDir, t.moduleName}
default:
diff --git a/kotlin-runtime/scaffolding/ftl-module-{{ .Name | lower }}/pom.xml b/kotlin-runtime/scaffolding/ftl-module-{{ .Name | lower }}/pom.xml
deleted file mode 100644
index 2ca07efa39..0000000000
--- a/kotlin-runtime/scaffolding/ftl-module-{{ .Name | lower }}/pom.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
- 4.0.0
- ftl
- ftl-module-{{ .Name | camel | lower }}
- 1.0-SNAPSHOT
-
- {{ .GroupID }}
- {{ .ArtifactID }}
- 1.0-SNAPSHOT
-
-
-
- {{ .Name | lower }}
-
-
-
-
-
- kotlin-maven-plugin
- org.jetbrains.kotlin
-
-
- org.apache.maven.plugins
- maven-dependency-plugin
-
-
-
- org.codehaus.mojo
- build-helper-maven-plugin
-
-
-
- com.github.ozsie
- detekt-maven-plugin
-
-
-
-
\ No newline at end of file
diff --git a/kotlin-runtime/scaffolding/ftl-module-{{ .Name | lower }}/ftl.toml b/kotlin-runtime/scaffolding/{{ .Name | lower }}/ftl.toml
similarity index 100%
rename from kotlin-runtime/scaffolding/ftl-module-{{ .Name | lower }}/ftl.toml
rename to kotlin-runtime/scaffolding/{{ .Name | lower }}/ftl.toml
diff --git a/kotlin-runtime/scaffolding/pom.xml b/kotlin-runtime/scaffolding/{{ .Name | lower }}/pom.xml
similarity index 88%
rename from kotlin-runtime/scaffolding/pom.xml
rename to kotlin-runtime/scaffolding/{{ .Name | lower }}/pom.xml
index b06a86d9c1..e4ca99c409 100644
--- a/kotlin-runtime/scaffolding/pom.xml
+++ b/kotlin-runtime/scaffolding/{{ .Name | lower }}/pom.xml
@@ -1,19 +1,13 @@
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
{{ .GroupID }}
- {{ .ArtifactID }}
+ {{ .Name | camel | lower }}
1.0-SNAPSHOT
- pom
-
-
- ftl-module-{{ .Name | camel | lower }}
-
-
1.0-SNAPSHOT
http://127.0.0.1:8892
@@ -170,5 +164,25 @@
+
+
+ kotlin-maven-plugin
+ org.jetbrains.kotlin
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+
+
+
+ com.github.ozsie
+ detekt-maven-plugin
+
+
\ No newline at end of file
diff --git a/kotlin-runtime/scaffolding/ftl-module-{{ .Name | lower }}/src/main/kotlin/ftl/{{ .Name | camel | lower }}/{{ .Name | camel }}.kt b/kotlin-runtime/scaffolding/{{ .Name | lower }}/src/main/kotlin/ftl/{{ .Name | camel | lower }}/{{ .Name | camel }}.kt
similarity index 100%
rename from kotlin-runtime/scaffolding/ftl-module-{{ .Name | lower }}/src/main/kotlin/ftl/{{ .Name | camel | lower }}/{{ .Name | camel }}.kt
rename to kotlin-runtime/scaffolding/{{ .Name | lower }}/src/main/kotlin/ftl/{{ .Name | camel | lower }}/{{ .Name | camel }}.kt