version: 2.1
jobs:
  build:

    docker:
      - image: circleci/openjdk:8-jdk

    steps:

      - restore_cache:
          keys:
            - source-v1-{{ .Branch }}-{{ .Revision }}
            - source-v1-{{ .Branch }}-
            - source-v1-
      - checkout
      - save_cache:
          key: source-v1-{{ .Branch }}-{{ .Revision }}
          paths:
            - ".git"

      - restore_cache:
          keys:
            # when lock file changes, use increasingly general patterns to restore cache
            - gradle-v1-{{ .Branch }}-{{ checksum "build.gradle" }}
            - gradle-v1-{{ .Branch }}-
            - gradle-v1-

      - run: ./gradlew build javadoc
      - run: ./gradlew requireJavadoc

      - save_cache:
          paths:
            - ~/.gradle
          key: gradle-v1-{{ .Branch }}-{{ checksum "build.gradle" }}

workflows:
  version: 2
  build:
    jobs:
      - build

version: 2.1

workflows:
  version: 2
  build:
    jobs:
      - build:
          context:
            - build-env-vars
            - docker-hub-credentials

jobs:
  build:

    docker:
      - image: circleci/openjdk:8-jdk
        auth:
          username: $DOCKERHUB_USERNAME
          password: $DOCKERHUB_PASSWORD

    steps:
      - restore_cache:
          keys:
            - source-v1-{{ .Branch }}-{{ .Revision }}
            - source-v1-{{ .Branch }}-
            - source-v1-
      - checkout
      - save_cache:
          key: source-v1-{{ .Branch }}-{{ .Revision }}
          paths:
            - ".git"

      - restore_cache:
          keys:
            # when lock file changes, use increasingly general patterns to restore cache
            - gradle-v1-{{ .Branch }}-{{ checksum "build.gradle" }}
            - gradle-v1-{{ .Branch }}-
            - gradle-v1-

      - run: ./gradlew build javadoc
      - run: ./gradlew requireJavadoc

      - save_cache:
          paths:
            - ~/.gradle
          key: gradle-v1-{{ .Branch }}-{{ checksum "build.gradle" }}

Use Docker Hub credentials from a CircleCI context
Use Docker Hub credentials from a CircleCI context

