Skip to content

Developer Guide

Peter Thomas edited this page Sep 26, 2019 · 51 revisions

Prerequisites:

  • Git
  • JDK 8 (even OpenJDK is fine)
  • Eclipse or any Java IDE that supports Maven
    • for example in IntelliJ and NetBeans, you can directly open a directory with a pom.xml file in it as a "project", and things will just work
  • Maven - optional, but recommended - especially to build the JAR-s / binaries

Git Clone:

git clone https://github.com/intuit/karate.git

Build

If you just want to build the binaries to test locally, and you have trouble installing (or want to avoid installing) Java and Maven, see Docker.

  • change to the karate folder created when you cloned the project from GitHub
  • make sure you switch to the right branch. most likely you want to do this:
    • git checkout develop
  • to build the maven artifacts locally:
    • mvn clean install -P pre-release
      • unit tests should never fail and if they do, please do consider debugging and letting us know the fix. but if you get stuck, you can add a -DskipTests at the end of the above command to proceed
    • this will locally "install" the karate-apache, karate-junit5 and other Maven output artifacts, and then you can refer to them in a Java project
    • just make sure you update the version of the Karate dependencies (typically karate-apache and karate-junit5) in the pom.xml (or build.gradle) that you are testing to match what was just "built"

Build Standalone JAR and ZIP

  • After you ran the above command, change to the karate/karate-netty folder
  • mvn install -P fatjar
  • you will get the JAR in karate/karate-netty/target/karate-<version>.jar
  • you will also get the ZIP in karate/karate-netty/target/karate-<version>.zip

Gradle

To develop Karate you need to use Maven. If you are trying to build the karate-demo project and run into issues, please read this.

Docker

The "foolproof" way to build Karate using OpenJDK 8 and Docker goes like this. The best part is you only need Docker to be installed !

Note that the -v "$HOME/.m2":/root/.m2 re-uses your local Maven JAR download "cache" (which saves time), but you can omit it if needed for a true "from scratch" experience. But you most likely should use it, because it makes sure the Java libraries (JAR files) are "installed" locally so that you can refer to them in your maven pom.xml.

docker run -it --rm -v "$(pwd)":/src -w /src -v "$HOME/.m2":/root/.m2 maven:3-jdk-8 mvn clean install -P pre-release

And to build the stand-alone JAR:

docker run -it --rm -v "$(pwd)":/src -w /src/karate-netty -v "$HOME/.m2":/root/.m2 maven:3-jdk-8 mvn install -P fatjar

Like mentioned above, if unit-tests fail (they ideally should not, and if you see some that do, please help us fix it !) you can add a -DskipTests to the above commands. This command has been tested to work even up to jdk-12.