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 kotlinVersion = "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:" + kotlinVersion, "org.jetbrains.kotlin:kotlin-reflect:" + kotlinVersion, "io.netty:netty-all:4.0.31.Final", "commons-codec:commons-codec:1.6", "commons-logging:commons-logging:1.1.1", "joda-time:joda-time:2.3") } // Test dependencies dependenciesTest { compile("junit:junit:4.9", "org.mockito:mockito-all:1.9.5", "org.apache.httpcomponents:httpclient:4.5.1") } // Tell kobalt to produce a fat jar and also the artifacts required for Maven assemble { jar { fatJar=true name = "wasabi-fat-" + version + ".jar" } mavenJars{ } } }
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 longer get errors.
From this point, you can either learn how to install the Kobalt IDEA plug-in or read Kobalt's documentation.