user2693135
user2693135

Reputation: 1316

Gradle Test Fails in CircleCI- Could not find symbols for Lombok Generated Code

I have a Spring Boot application with Gradle. I tried upgrading to Spring Boot 2.1.0.RELEASE. I also had to upgrade Gradel Wrapper in gradle-wrapper.properties like this:

distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip

My code uses Lombok 1.18.2

Locally, my application tests runs correctly. However, CircleCI build fails, like this.

!/bin/bash -eo pipefail

gradle test

Task :compileJava /home/circleci/repo/src/main/java/guru/springframework/spring5webfluxrest/bootstrap/Bootstrap.java:31: error: cannot find symbol categoryRepository.save(Category.builder() ^ symbol: method builder() location: class Category /home/circleci/repo/src/main/java/guru/springframework/spring5webfluxrest/bootstrap/Bootstrap.java:34: error: cannot find symbol categoryRepository.save(Category.builder() ^ symbol: method builder() location: class Category /home/circleci/repo/src/main/java/guru/springframework/spring5webfluxrest/bootstrap/Bootstrap.java:37: error: cannot find symbol categoryRepository.save(Category.builder() ^ symbol: method builder() location: class Category /home/circleci/repo/src/main/java/guru/springframework/spring5webfluxrest/bootstrap/Bootstrap.java:40: error: cannot find symbol categoryRepository.save(Category.builder() ^ symbol: method builder() location: class Category /home/circleci/repo/src/main/java/guru/springframework/spring5webfluxrest/bootstrap/Bootstrap.java:43: error: cannot find symbol categoryRepository.save(Category.builder() ^ symbol: method builder() location: class Category /home/circleci/repo/src/main/java/guru/springframework/spring5webfluxrest/bootstrap/Bootstrap.java:48: error: cannot find symbol vendorRepository.save(Vendor.builder() ^ symbol: method builder() location: class Vendor /home/circleci/repo/src/main/java/guru/springframework/spring5webfluxrest/bootstrap/Bootstrap.java:52: error: cannot find symbol vendorRepository.save(Vendor.builder() ^ symbol: method builder() location: class Vendor /home/circleci/repo/src/main/java/guru/springframework/spring5webfluxrest/bootstrap/Bootstrap.java:56: error: cannot find symbol vendorRepository.save(Vendor.builder() ^ symbol: method builder() location: class Vendor /home/circleci/repo/src/main/java/guru/springframework/spring5webfluxrest/bootstrap/Bootstrap.java:60: error: cannot find symbol vendorRepository.save(Vendor.builder() ^ symbol: method builder() location: class Vendor /home/circleci/repo/src/main/java/guru/springframework/spring5webfluxrest/bootstrap/Bootstrap.java:64: error: cannot find symbol vendorRepository.save(Vendor.builder() ^ symbol: method builder() location: class Vendor 10 errors

Task :compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or -- 
debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s
1 actionable task: 1 executed
Exited with code 1

Please help.

Upvotes: 1

Views: 766

Answers (3)

Ravi
Ravi

Reputation: 1

Use annotationProcessor 'org.projectlombok:lombok' in build.gradle in dependencies. It will work smooth.

Upvotes: 0

Marcos Almeida
Marcos Almeida

Reputation: 69

What worked for me was add "annotationProcessor" to build.gradle dependencies (it was not building locally either).

dependencies {
   compileOnly 'org.projectlombok:lombok'
   annotationProcessor 'org.projectlombok:lombok'
}

Upvotes: 0

Arty
Arty

Reputation: 867

Try change gradle and use ./gradlew under the steps: section in the config.yml as the template below:

version: 2
jobs:
  build:
    docker:
      # specify the version you desire here
      - image: circleci/openjdk:8-jdk

      # Specify service dependencies here if necessary
      # CircleCI maintains a library of pre-built images
      # documented at https://circleci.com/docs/2.0/circleci-images/
      # - image: circleci/postgres:9.4

    working_directory: ~/repo

    environment:
      # Customize the JVM maximum heap limit
      JVM_OPTS: -Xmx3200m
      TERM: dumb

    steps:
      - checkout

      # Download and cache dependencies
      - restore_cache:
          keys:
            - v1-dependencies-{{ checksum "build.gradle" }}
            # fallback to using the latest cache if no exact match is found
            - v1-dependencies-

      - run: ./gradlew dependencies # <-- changed from `gradle dependencies`

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

      # run tests!
      - run: ./gradlew test # <-- changed from `gradle test`

Upvotes: 0

Related Questions