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.
- 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
-
Go to your project directory
-
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
- Download dependencies, compile and run tests
./kobaltw test
this is how your CI server/runners will run your tests
-
Ensure you've got the Kobalt Intellij plugin installed (v1.110 or better)
-
Import into intellj
File -> New -> Project from existing sources -> (your project's path) -> Import project from external model (Kobalt) Select option "use auto-import"
- 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
Note: I removed the
idea
template from Kobalt, so you can no longer do./kobaltw --init idea
. Like you say, the best way to do this now is to just import the project directly from IDEA.