Upgrading from Java 8 to Java 11

We are performing an upgrade of Java version from 1.8 to 11 across our micro experiences. To continue your work post upgrade, follow the steps mentioned below.

What is changed

Java version on the workspaces is upgraded from Java8 to Java 11, as a consequence, following changes are made

  • Gradle version updated from 5.2.1 to 6.6.1 (check the images in the sections below)

  • The versions of Code quality plugins like Jacoco and Spotbugs are incompatible with java 11, and thus these plugins are upgraded to latest. This also results in few syntax changes like below.

  • Spotbugs syntax was using `spotbugs task earlier

  spotbugs {
        toolVersion = "3.1.12"
        sourceSets = [sourceSets.main]
    }

    tasks.withType(com.github.spotbugs.SpotBugsTask) {
        reports {
            html.enabled true
            xml.enabled false
        }
    }
  • Now it uses spotbugsMain and spotbugsTest tasks. The respective changes are made
spotbugsMain {
        reports {
            xml.enabled = false
            html.enabled = true
        }
  }
spotbugsTest.enabled = false
  • Plugin declaration for spotBugs is moved to top section for plugins.
    image

  • Similarly, Jacoco version is updated to latest
    image

  • Disabled checkstyle for Tests directory.
    image

  • Gradle Plugin configurations are now inside settings.gradle instead of main build.gradle

  • Along with the same, some redundent gradle configurations are removed, and gradle file is now cleaner. The grey area in the image below is now removed from build.gradle as it was redundent.*

How to pull the change?

  • First, ensure that you are running on java 11, by running below command
    java -version
    javac -version

Make sure that all the unsaved code is backed up

Note: Pull the code for your current module however copy the below 3 files from 1st module stubs.

  • Go to the appropriate location, and copy the contents of below files into your code.

    1. build.gradle (Both build.gradle files)
    2. settings.gradle
    3. gradle/wrapper/gradle-wrapper.properties - change version of gradle to 6.6.1 as shown in the image below
  • If you have made any changes in the build.gradle, especially for module5 in Qmoney, make sure that you redo the changes.

For All the users post Qmoney 4 has to make this change in
PortfolioManagerFactoryTest.java, Please change the getPortfolioManager test to

  • Post that,
    run command
    ./gradlew build test
    to make sure that your code compiles and executes the tests.

  • If the build is successful, then you are done.
    Now, push the code

    git add .
    git commit -m "upgrade to java 11"
    git push