-
Notifications
You must be signed in to change notification settings - Fork 133
Getting started
Sergey Mashkov edited this page Jul 2, 2015
·
19 revisions
kotlinx.html is a library for building HTML pages for the Kotlin language. You can use it on both server and client side. Also it provides way to build HTML pages to a stream and to a DOM tree.
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
To get it working with maven you need to add custom repository
<repository>
<id>bintray-kotlinx</id>
<name>bintray</name>
<url>http://dl.bintray.com/kotlinx/kotlinx</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 {
maven {
url "http://dl.bintray.com/kotlinx/kotlinx"
}
}
dependencies {
// 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}"
}