Skip to content

Developer Guide

Peter Thomas edited this page Dec 8, 2019 · 51 revisions

Prerequisites:

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.

Docker Images

The karate-chrome Docker container can be built locally by running the build.sh in the karate-docker/karate-chrome folder. Of course you need Docker installed and running.

If you are interested, the release process is documented here and can give you some insights into the structure: readme.txt

Once you build the container and if you have made changes, you can (optionally) "tag" it locally if you need to test any code or config that points to the ptrthomas/karate-chrome image:

docker tag karate-chrome ptrthomas/karate-chrome:latest