Java 9 Maven build with CircleCI

When writing the source code for the book Exploring Java 9, I feel that I need to have the continuous integration (CI) builds for the source code. The source code is a Maven project running with Java 9. Java 9 is not supported natively on most CI servers. However, with the help of Docker, we can easily run CI builds using Java 9.

I use CircleCI to build the source code. The code below is the circle.yml of CircleCI. Here I use the docker image maven:3.5.0-jdk-9 to run the Maven builds. ([[ ! -d $JAVA_HOME/conf ]] && ln -s $JAVA_HOME/lib $JAVA_HOME/conf) is used to workaround the issue with error java.lang.SecurityException: Can't read cryptographic policy directory: unlimited when starting the JVM.

Update: The Maven Docker image has been upgraded to use JDK 9 build 178, which fixed the issue. So it’s no longer required to use the workaround.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
version: 2
jobs:
build:
working_directory: ~/circleci-feature9
docker:
- image: maven:3.5.0-jdk-9
steps:
- checkout
- restore_cache:
key: circleci-feature9-{{ checksum "pom.xml" }}
- run: mvn test
- save_cache:
paths:
- ~/.m2
key: circleci-feature9-{{ checksum "pom.xml" }}
- store_test_results:
path: target/surefire-reports

See the actual circle.yml file used for the source code.

Comments