Kengo's blog

Technical articles about original projects, JVM, Static Analysis and TypeScript.

build matrix for Maven project on Travis CI

Travis CI supports build matrix, it let you to build your project in several environment. For instance, I build my project in 6 environments:

  • OpenJDK 1.6, SLF4J 1.6.6
  • OpenJDK 1.7, SLF4J 1.6.6
  • OracleJDK 1.7, SLF4J 1.6.6
  • OpenJDK 1.6, SLF4J 1.7.2
  • OpenJDK 1.7, SLF4J 1.7.2
  • OracleJDK 1.7, SLF4J 1.7.2

To switch JDK, you can use parameter in .travis.yml.

Using Maven profile is good way to switch build environment. You can use script parameter to set profile. Here is an example to set profile.

language: java
  - oraclejdk7
    - SLF4J_VERSION=1.7.2
    - SLF4J_VERSION=1.6.6

script: "mvn clean install -P build-with-${SLF4J_VERSION}"