I have a library that uses Java 8 classes if they are available and for older JRE versions provides a fallback implementation. It means I have to compile using Java 8 (or higher) but I want to execute the tests with JDK 7 to test the fallback. I can not figure out how to do it in Travis.
The easiest way is to create special Maven profile for Travis in pom.xml
<profile>
<id>travis</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<executable>/usr/lib/jvm/java-8-oracle/bin/javac</executable>
</configuration>
</plugin>
</plugins>
</build>
</profile>
And then activate it in .travis.yml
script: mvn install -P travis
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With