This repository has been archived by the owner on May 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
Creator: After adding a new Runtime
Tako Schotanus edited this page Aug 14, 2019
·
3 revisions
At the end of the HOWTO Create a Runtime Generator page we stated "That's all!". But actually that isn't entirely true.
Where the Launcher Creator's code generating functionality is concerned that's indeed all that needs to be done, but the Launcher also has Capabilities and a UI. Both of them need to know about new Runtime Generators.
So what more do we need to do?
-
Update Runtime Enumeration - Update the
runtime
section in the META-INF/catalog/enums.yaml to add an entry for your new runtime. It should look something like this:
- id: springboot
name: Spring Boot
description: Create stand-alone, production-grade Spring based Applications that
you can "just run".
metadata:
categories:
- backend
language: java
website: https://spring.io/projects/spring-boot
# HERE
- id: example
name: Example Runtime
description: A very interesting story about our runtime
metadata:
categories:
- backend
language: java
website: https://example-runtime.org
- Add Version Enumeration - In the same file also add a new section for any versions your Runtime supports (there should be at least one):
runtime.version.quarkus:
- id: community
name: Community
runtime.version.springboot:
- id: community
name: Community
# HERE
runtime.version.example:
- id: community
name: Community
-
Update Capabilities - This section is a bit tricky because Capabilities depend on a bunch of parts, having just a Runtime Generator is not enough. Each Capability normally delegates the creation of code to highly specialized Generators. For example, a REST Capability1 would delegate the creation of the code for Node.js to a Generator named
rest-nodejs
2. It would be that Generator which would then call the Node.js Runtime Generator. And so it would go for all Capabilities. So you first need to make sure you create those specialized Generators before you can continue.
Done already? ... Wow, that's quick.
So now there's two things left to do:
- Update the
props.runtime.values
in theinfo.yaml
files of all the Capabilities where you added support for your new runtime. An example where we add support for ourexample
Runtime would be:
props:
- id: runtime
name: Runtime
description: The runtime to use
required: true
shared: true
type: object
props:
- id: name
name: Runtime Name
description: The name of the runtime to use
required: true
shared: true
type: enum
values:
- dotnet
- nodejs
- springboot
- example
- Update the code in the Capabilities that deal with runtimes. Look for
runtimeByType()
. Although if you followed the naming used by other Generators you might not have to do anything because the Capabilities try to be clever:
// Returns the corresponding runtime generator depending on the given runtime type
private fun runtimeByType(rt: Runtime): GeneratorConstructor {
return GeneratorInfo.valueOf("rest-${rt.name}").klazz
}
(Meaning it dynamically looks for a Generator with a name that consists of the word rest-
and the name of the runtime)
After this you really should be done. Phew!
- [1]: REST Capability - You can see the current implementation of the Rest Capability and how it delegates its work to specialized Generators
- [2]: Node.js REST Generator The specialized Generator for REST using Node.js. See how it is based on the Node.js Runtime Generator.