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 java
This command will do two things:
kobalt/src/Build.kt
suitable for a brand new Java 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.
The build file generated by default might need some editing before you can build your project, so take a look at it and adjust whatever is necessary (e.g. package name, version, etc...)
Here is the Build.kt
for the JCommander project:
import com.beust.kobalt.* import com.beust.kobalt.plugin.java.* import com.beust.kobalt.plugin.packaging.* import com.beust.kobalt.plugin.publish.* val jcommander = project { name = "jcommander" group = "com.beust" artifactId = name version = "1.54" dependenciesTest { compile("org.testng:testng:6.9.9") } assemble { mavenJars { } } jcenter { publish = true } }
If you're using Intellij IDEA, make sure you've installed the Kobalt plugin and then go to Kobalt -> Sync Build File
. Once the build file is synchronized, the errors should disappear
and you can now use all the regular functions of IDEA on Build.kt
just like any other Kotlin
files (auto completion, jump to symbol, etc...).
From this point, you can either learn how to install the Kobalt IDEA plug-in or read Kobalt's documentation.