Download the zip file then unzip it in a location we'll call KOBALT_HOME
:
cd $KOBALT_HOME unzip kobalt-xxx.zip
Note: Kobalt doesn't need any environment variable to run, the environment variable used above is only here for clarity.
Change to your project directory and call the kobaltw
command with --init
:
cd ~/java/project $KOBALT_HOME/kobaltw --init
This command will do two things:
kobalt/src/Build.kt
file based on what was found in your project.
kobaltw
) and a few additional files in the kobalt/wrapper
directory. From now on, you can just use ./kobaltw
to build and you can ignore $KOBALT_HOME
.
You can now attempt to build your project with Kobalt:
./kobaltw assembleIf your project follows a regular build structure (e.g. Maven's hierarchy), this should compile your file and create a .jar file. If not, you will have to make a few edits to your
Build.kt
.
As of this writing, Kobalt supports Java and Kotlin projects.
Build.kt
for the Wasabi HTTP framework:
import com.beust.kobalt.* import com.beust.kobalt.plugin.packaging.assemble import com.beust.kobalt.plugin.kotlin.* val kotlin_version = "1.0.0-beta-4583" val p = kotlinProject { name = "wasabi" group = "com.example" artifactId = name version = "0.1" // Tell Kobalt to also search here for dependencies val repos = repos("http://oss.sonatype.org/content/repositories/snapshots") dependencies { compile("org.jetbrains.kotlin:kotlin-stdlib:" + kotlin_version, "org.jetbrains.kotlin:kotlin-reflect:" + kotlin_version, "com.fasterxml.jackson.core:jackson-core:2.6.4", "com.fasterxml.jackson.core:jackson-databind:2.6.4", "com.fasterxml.jackson.core:jackson-annotations:2.6.4", "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.6.3", "com.fasterxml.woodstox:woodstox-core:5.0.1", "io.netty:netty-all:4.0.31.Final", "commons-codec:commons-codec:1.6", "commons-logging:commons-logging:1.1.1", "com.netflix.rxjava:rxjava-core:0.20.0-RC4", "org.slf4j:slf4j-api:1.7.5", "org.slf4j:slf4j-simple:1.7.5", "joda-time:joda-time:2.3") } // Test dependencies dependenciesTest { compile("junit:junit:4.9", "org.mockito:mockito-all:1.9.5", "org.apache.httpcomponents:httpcore:4.3.3", "org.apache.httpcomponents:httpclient:4.5.1") } // Tell kobalt to produce a jar assemble { jar { } } }
If you're using Intellij IDEA, make sure you've installed the Kobalt plugin and then go to Kobalt -> Sync Build File
. This will download dependencies in a way that IDEA understand so you no loger get errors.
From this point, you can either learn how to install the Kobalt IDEA plug-in or read Kobalt's documentation.