Use Docker Executor based on the Java Version used in the repository

In my current project I want to use the docker executor based on the version of JAVA being used in our repository.

  1. This is the approach I have in my mind.

    • In job → steps → we will call the command, determine-java-version → which will check which java version we’re using → and based on that we will select the executor either jdk13 or jdk17.
    • But, this approach is not recommended by kapa.ai and other LLM models, as we can’t modify the executor.
  2. One of my senior have gave one approach that, we can create lists of repositories using the Java Version, and based on that we can decided which docker-executor to use.

Which ideal approach am I suppose to follow?

Here’s the first few lines of code:

version: 2.1
orbs:
  docker-buildx: devarsh/docker-buildx-orb@0.1.1
executors:
  docker-executor:
    docker:
      - image: circleci/openjdk:13.0-buster-node-browsers-legacy