Skip to content

mike-neck/daab-kt

Repository files navigation

daab-kt

This is daab extension for Kotlin. With this plugin you can write daab application with Kotlin.

Getting Started

Add following snippet to your build file(build.gradle).

buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath 'com.lisb.daab:daab-kt:0.1.6'
  }
}

Tasks

This plugin offers following tasks.

daabInit

daabInit initializes an application with command daab init.

daabRun

daabRun converts Kotlin file into JavaScript and then runs the application.

daabStart

daabStart converts Kotlin file into JavaScript and then starts the application in background.

Configuration

To customize this plugin, edit these items.

Table 1. configurable items
Property Value Default Nullable

executable

Path to daab command

/usr/local/bin/daab

No

mainPackage

Package of the application. The value should be a valid package name.

""(empty string)

No

daabAppDir

The application directory relative to the project.

daab

No

appName

The object name to be exported in kotlin file.

app

No

Project Structure

A project should have the normal gradle/maven kotlin project structure.

project-root
├── build.gradle
└── src
    └── main
        └── kotlin
            └── com
                └── example

Given a configuration in build.gradle file…​

daab {
  daabAppDir = 'my-app'
  mainPackage = 'com.example'
  appName = 'myApplication'
}

If you give a value to mainPackage, then the main object to be exported should be written under the package, because Kotlin2Js compiler cannot detect that it is the main object.

The appName will be used as a file name Kotlin compiler will create, and will be loaded as a package object by a js file which gradle daab plugin will generate. So note that the main package object should be named as the same name as the appName value.

Given tha main kotlin script is written like an example below, app.js (daab plugin’s generated script) will load a main entry point myApplication with the same name. If you give appName with another, a daab application won’t run.

package com.example

// will run
val myApplication: (Robot) -> Unit = { robot ->
  robot.hear(RegExp("PING", "i")) { res ->
    res.send("pong")
  }
}

// won't run
val application: (Robot) -> Unit = { robot ->
  roobot.head(RegExp("FOO", "i")) {
    println(it.message.text)
  }
}

For Development of the plugin project and the types project

Create install-local.gradle file at the root directory of this project to install jar files into local maven directory.

apply plugin: 'maven'

To create install-local.gradle file, use generateInstallLocalGradle task at the project root directory.

$ ./gradlew generateInstallLocalGradle

About

daab-kt : daab for Kotlin

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published