Skip to content

Instantly share code, notes, and snippets.

@pabl0rg
Last active September 4, 2016 18:40
Show Gist options
  • Save pabl0rg/f788a1ed0c3a4f43efdf17aed244b473 to your computer and use it in GitHub Desktop.
Save pabl0rg/f788a1ed0c3a4f43efdf17aed244b473 to your computer and use it in GitHub Desktop.
The official Kobalt website http://beust.com/kobalt/documentation/index.html can be a bit overwhelming. Here's a bare-bones guide.

If you want to run your tests and builds from the command line, this is currently the most straight-forward (only?) way to install Kobalt.

  1. Download kobalt
  • Note: this requires jq to be installed first
LATEST_KOBALT_URL=`curl -s https://api.github.com/repos/cbeust/kobalt/releases/latest | jq -r ".assets[0] | .browser_download_url" `
LATEST_KOBALT_ZIP=`echo "$LATEST_KOBALT_URL" | rev | cut -d / -f 1 | rev`
LATEST_KOBALT=`echo "$LATEST_KOBALT_ZIP" | sed 's/.zip//'`

mkdir -p ~/.kobalt/wrapper/dist/
cd ~/.kobalt/wrapper/dist/
curl -LO $LATEST_KOBALT_URL
unzip -o $LATEST_KOBALT_ZIP
chmod +x $LATEST_KOBALT/bin/kobaltw
export PATH=~/.kobalt/wrapper/dist/$LATEST_KOBALT/bin:$PATH
  1. Go to your project directory

  2. Initialize the Kobalt project

    kobaltw --init kotlin

Congratulations, you now have a build file in kobalt/src/Build.kt It is a kotlin file. You can edit it in any text editor, but if you want code assist from IntelliJ, keep reading

  1. Download dependencies, compile and run tests

./kobaltw test this is how your CI server/runners will run your tests

  1. Ensure you've got the Kobalt Intellij plugin installed (v1.110 or better)

  2. Import into intellj

File -> New -> Project from existing sources -> (your project's path) -> Import project from external model (Kobalt) Select option "use auto-import"

  1. You can now use the refresh/sync icon in the kobalt sidebar tool (shows up on far right, below Maven Projects on my IDE) to get your dependencies configured in IntelliJ.

Notes:

  • You will get this error message when you first import the project b/c Kotlin will not be configured AssertionError: Kotlin library should exists when adding sources root
  • This happens because your source folders have been marked as such but you have not yet configured Kotlin java for the project
  • You can fix the error by using the configure Kotlin dialog that will usually show up under the error message or by going to tools -> Kotlin -> Configure Kotlin in project
@pabl0rg
Copy link
Author

pabl0rg commented Jun 2, 2016

Makes sense! I removed the note.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment