-
Notifications
You must be signed in to change notification settings - Fork 133
Getting started
Sergey Mashkov edited this page Aug 29, 2016
·
19 revisions
There are three bundles available:
- zip with two JVM jars
- jar with JavaScripts and meta-data (required for Kotlin compiler)
- webjar with JavaScripts (without meta-data)
you can grab them from the releases tab and include it in your project. Use first for server-side and second for client-side
For JVM you better to import
import kotlinx.html.*
import kotlinx.html.dom.*
For JS target
import kotlinx.html.*
import kotlinx.html.dom.*
import kotlinx.html.js.*
To get it working with maven you need to add JCenter repository
<repository>
<id>jcenter</id>
<name>jcenter</name>
<url>https://jcenter.bintray.com</url>
</repository>
For server-side development you can add the following dependency:
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx.html.jvm</artifactId>
<version>${kotlinx.html.version}</version>
</dependency>
For client-side (JavaScript) you need this one:
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx.html.js</artifactId>
<version>${kotlinx.html.version}</version>
</dependency>
If you are building web application with war plugin you can use overlays to pack JavaScripts from webjar like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<dependentWarExcludes>META-INF/*,META-INF/**/*,*meta.js,**/*class</dependentWarExcludes>
<webXml>src/main/resources/web.xml</webXml>
<webResources>
<resource>
<directory>src/main/webapp</directory>
</resource>
</webResources>
<overlays>
<overlay>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-js-library</artifactId>
<type>jar</type>
<includes>
<include>kotlin.js</include>
</includes>
<targetPath>js/</targetPath>
</overlay>
<overlay>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx.html.assembly</artifactId>
<classifier>webjar</classifier>
<type>jar</type>
<targetPath>js/</targetPath>
</overlay>
</overlays>
</configuration>
</plugin>
You have to add the repository and dependencies
repositories {
jcenter()
}
dependencies {
//Fill this in with the version of kotlinx in use in your project
def kotlinx_html_version = "your_version_here"
// include for server side
compile "org.jetbrains.kotlinx:kotlinx.html.jvm:${kotlinx_html_version}"
// include for client-side
compileClient "org.jetbrains.kotlinx:kotlinx.html.js:${kotlinx_html_version}"
}