Slate Kit comes with a command line tool to serve as a project generator. This is simply a Kotlin executable jar packaged as a Java Application via gradle that can be executed on the command line with bash/batch scripts. The application takes a template comprised of a instructions, along with files/folders that are copied to a new destinated folder representing the app/project to create. The files contain placeholder values that replaced the name of the app aamong other variables. This is a minimal version of nodejs yeoman or python cookie-cutter
slatekit new app -name="Sample1" -package="mycompany.apps"
The Slate Kit project generator is a java app ( packaged as a Java application via gradle ) and is composed of containing 3 things:
|1||Scripts||slatekit and slatekit.bat||For running the commands|
|2||Settings||conf/env.conf||For various settings ( locations )|
|3||Templates||templates/slatekit/app||Templates for each project type|
Download the Slate Kit tools by git cloning the tools git repo to your local machine.
E.g. sample folder could be ~/tools/slatekit
The generator is 1 project in tools and is stored in a sub directory called generator.
Add the path to Slate Kit Generator~/tools/slatekit/generator to your PATH ( e.g. ~/.bash_profile or /etc/paths )
Tip: This allow you to avoid prefixing slatekit with ./ as in ./slatekit and simply using slatekit
Now you just have to configure 2 settings in the ~/tools/slatekit/conf/env.conf file.
Tip: This step will not be needed in a future version
You can generate a new project by running slatekit with the appropriate commands. You can then run the generated app via gradle
To create a new project just cd to the Slate Kit folder and run the commands.
The new project will be created in the SLATE_KIT_HOME/generator/gen folder.
You can then cd into that to build it.
Once the project is built, you can simply run with gradle ( as a quick test ).
These are the features to be added in the future to further enhance/customize the project generation.
|gen.output||Variable||Customize the output directory of generated project||~/myapps/app1|
|sk.version||Variable||Customize the Slate Kit Version||1.0.1|
|kt.version||Variable||Customize the Kotlin Version||1.3.6|
|Templates||Feature||Downloading of templates from Git or remote sources||n/a|
These are all the types of project generators available by default from Slate Kit. These are the most common type of Applications or services corresponding to the architecture components available from Slate Kit.
:> cd ~/tools/slatekit/generator :> slatekit new app -name="MyApp1" -package="company1.apps" # Now build and run via gradle :> cd gen/MyApp1 :> gradle build :> gradle run
Generates a new API project for hosting HTTP/Web APIs. APIs in Slate Kit are considered Universal in the sense that you write them once and they are available as both HTTP/Web APIs ( in the form of RPCs ) and also available on the CLI. Also refer to the APIs component.
:> cd ~/tools/slatekit/generator slatekit new api -name="MyAPI1" -package="company1.apis" # Now build and run via gradle :> cd gen/MyApp1 :> gradle build :> gradle run
:> cd ~/tools/slatekit/generator slatekit new cli -name="MyCLI1" -package="company1.apps" # Now build and run via gradle :> cd gen/MyApp1 :> gradle build :> gradle run
Generates a new background job that can be gracefully started, stopped, paused, resumed. They can also be run in “pages”, or process items from queues. Refer to the Jobs component and example: Example_Jobs.kt.
:> cd ~/tools/slatekit/generator slatekit new job -name="MyJob1" -package="company1.jobs"
For the Job, you can run the different job types by passing -job.name to the arguments for gradle/java. E.g.
cd gen/MyJob1 gradle build # To run the One Time Job sample gradle run --args='-job.name=single' # To run the Paged Job sample gradle run --args='-job.name=paging' # To run the Queue Job sample gradle run --args='-job.name=queued' # To run the Worker Sample gradle run --args='-job.name=worker'
Generates an empty gradle library project with some Slate Kit library references.
:> cd ~/tools/slatekit/generator slatekit new lib -name="MyLib1" -package="company1.libs" # Now build and run via gradle :> cd gen/MyApp1 :> gradle build :> gradle run
:> cd ~/tools/slatekit/generator slatekit new sql -name="MyApp1" -package="company1.apps" # Now build and run via gradle :> cd gen/MyApp1 :> gradle build :> gradle run