Fork me on GitHub
  1. What you should know
  2. Adding a Kweb dependency
    1. Gradle
    2. Kobalt
    3. Maven
  3. Logging

What you should know

Kweb is built on Kotlin 1.1, you should have some familiarity with Kotlin and the Java ecosystem on which it’s built.

Adding a Kweb dependency

The Kweb library is distributed via JitPack, it can be added easily to any Kotlin project:

Gradle

For Gradle users, add this to the repositories section of your build.gradle:

  repositories {
    // ...
    maven { url 'https://jitpack.io' }
    maven { url "http://dl.bintray.com/kotlin/kotlin-eap-1.1" }
    maven {url "http://dl.bintray.com/kotlin/ktor"}
    }

Then add this to the dependencies section of your build.gradle:

dependencies {
  // ...
  compile 'com.github.sanity:kweb:MAVEN_VERSION_PLACEHOLDER'
  compile 'org.slf4j:slf4j-simple:1.6.1' // <-- or your favorite SLF4J logger binding 
}

Kobalt

For Kobalt users, add this to your Built.kt file:

  buildScript {
    // ...
    repos(
        "https://jitpack.io", 
        "http://dl.bintray.com/kotlin/kotlin-eap-1.1", 
        "http://dl.bintray.com/kotlin/ktor"
        )
    // ...
  }
  dependencies {
    // ...
    compile("com.github.sanity:kweb:MAVEN_VERSION_PLACEHOLDER")
    compile("org.slf4j:slf4j-simple:1.6.1") // <-- or your favorite SLF4J logger binding 
    // ...
  }

Maven

For Maven users, add this to the repositories section of your pom.xml:

<repositories>
<repository><id>jitpack.io</id><url>https://jitpack.io</url></repository>
<repository><snapshots><enabled>false</enabled></snapshots>
    <id>dl</id><name>bintray</name><url>http://dl.bintray.com/kotlin/kotlin-eap-1.1</url>
</repository>
<repository><id>ktor</id><url>http://dl.bintray.com/kotlin/ktor</url></repository>
</repositories>

Then add this to the dependencies section of your pom.xml:

<dependency>
  <groupId>com.github.sanity</groupId>
  <artifactId>kweb</artifactId>
  <version>MAVEN_VERSION_PLACEHOLDER</version>
</dependency>  

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId> <!-- or your favorite SLF4J logger binding -->
    <version>1.6.1</version>
</dependency>

Logging

Kweb uses SLF4J for logging. This is a “logging facade”, it allows libraries to log to the library user’s preferred logging framework. The instructions above include the “simple” SLF4J logger binding, but you can replace this with a number of others, depending on your needs or preferences, learn more here.

If you see an error like the following:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

…it means that you have not provided an SLF4J logging implementation. This is undesirable because Kweb provides some useful warnings that you won’t see without this.


Next: Your First Kwebsite »»