Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: generate kotlin external modules from FTL tooling #988

Merged

Conversation

worstell
Copy link
Contributor

fixes #970

This implementation diverges from the kotlin-runtime module generator logic in that it omits IngressHttp or Json annotations in external modules. I don't think we need those for the generated external modules.

Will follow with a change to remove the module generator entirely and stop releasing its JAR.

@worstell worstell force-pushed the worstell/20240223-generate-kotlin-external-modules-in-ftl branch 3 times, most recently from e8d0020 to 06dedc8 Compare February 26, 2024 21:10
Copy link
Collaborator

@alecthomas alecthomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one Lizzy!

}, scaffolder.Functions(funcs))
}

var scaffoldFuncs = scaffolder.FuncMap{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions are already defined in a couple of places. Let's factor them into a single location and include them by default in internal.ScaffoldZip.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scaffolder.Functions() is cumulative, so the bespoke functions can still be added in each individual location.

val parameterizedDataRef: ParamTestData<T>,
val withAlias: String,
val unit: Unit,
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

{{- if $imports}}
{{range $import := $imports}}
import {{$import}}
{{- end}}{{end}}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is quite difficult to read. Let's introduce some whitespace here between the different semantic sections. The intent of using {{- and - }}, is to allow the template to have meaningful whitespace while still generating clean output.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated! hopefully clearer chunks now

.removeSuffix("*/")
.lines()
.map { it.trim().removePrefix("*").trim() }
.filter { it.isNotEmpty() }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want to remove empty lines in the comments do we?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah the thinking here was to filter out the lines that become empty after removing the javadoc start/end markers /** and */- but good point, we don't want to lose intentional line spacing. I've updated to only filter out the lines that contain start/end markers with nothing else

@worstell worstell force-pushed the worstell/20240223-generate-kotlin-external-modules-in-ftl branch from 8cfe6b8 to c575fab Compare February 27, 2024 00:42
@worstell worstell force-pushed the worstell/20240223-generate-kotlin-external-modules-in-ftl branch from c7501aa to b8280e0 Compare February 27, 2024 00:49
@worstell worstell merged commit 7dc97b5 into main Feb 27, 2024
@worstell worstell deleted the worstell/20240223-generate-kotlin-external-modules-in-ftl branch February 27, 2024 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move codegen from Maven into the ftl tooling.
2 participants