Skip to content

Getting started

Sergey Mashkov edited this page Nov 7, 2017 · 19 revisions

Gettings started with kotlinx.html

Maven

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>

Gradle

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
	compile "org.jetbrains.kotlinx:kotlinx-html-js:${kotlinx_html_version}"

        // note: most likely you don't need to include them both
}

NPM

npm install kotlinx-html

see https://www.npmjs.com/package/kotlinx-html

Bintray

You can always download jars directly from bintray:

bintray

see Downloads section or discover artifacts in "Files" tab.