CircleCI中的Gradle测试失败-找不到Lombok生成代码的符号

时间:2019-01-27 03:21:13

标签: spring-boot lombok circleci

我有一个Gradle的Spring Boot应用程序。我试图升级到Spring Boot 2.1.0.RELEASE。我还必须像这样在gradle-wrapper.properties中升级Gradel Wrapper:

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

我的代码使用Lombok 1.18.2

在本地,我的应用程序测试正常运行。但是,像这样的CircleCI构建失败。

!/ bin / bash -eo pipefail

等级测试

  

任务:compileJava   /home/circleci/repo/src/main/java/guru/springframework/spring5webfluxrest/bootstrap/Bootstrap.java:31:错误:找不到符号               categoryRepository.save(Category.builder()                                               ^     符号:方法builder()     地点:班级类别   /home/circleci/repo/src/main/java/guru/springframework/spring5webfluxrest/bootstrap/Bootstrap.java:34:错误:找不到符号               categoryRepository.save(Category.builder()                                               ^     符号:方法builder()     地点:班级类别   /home/circleci/repo/src/main/java/guru/springframework/spring5webfluxrest/bootstrap/Bootstrap.java:37:错误:找不到符号               categoryRepository.save(Category.builder()                                               ^     符号:方法builder()     地点:班级类别   /home/circleci/repo/src/main/java/guru/springframework/spring5webfluxrest/bootstrap/Bootstrap.java:40:错误:找不到符号               categoryRepository.save(Category.builder()                                               ^     符号:方法builder()     地点:班级类别   /home/circleci/repo/src/main/java/guru/springframework/spring5webfluxrest/bootstrap/Bootstrap.java:43:错误:找不到符号               categoryRepository.save(Category.builder()                                               ^     符号:方法builder()     地点:班级类别   /home/circleci/repo/src/main/java/guru/springframework/spring5webfluxrest/bootstrap/Bootstrap.java:48:错误:找不到符号               vendorRepository.save(Vendor.builder()                                           ^     符号:方法builder()     位置:供应商类   /home/circleci/repo/src/main/java/guru/springframework/spring5webfluxrest/bootstrap/Bootstrap.java:52:错误:找不到符号               vendorRepository.save(Vendor.builder()                                           ^     符号:方法builder()     位置:供应商类   /home/circleci/repo/src/main/java/guru/springframework/spring5webfluxrest/bootstrap/Bootstrap.java:56:错误:找不到符号               vendorRepository.save(Vendor.builder()                                           ^     符号:方法builder()     位置:供应商类   /home/circleci/repo/src/main/java/guru/springframework/spring5webfluxrest/bootstrap/Bootstrap.java:60:错误:找不到符号               vendorRepository.save(Vendor.builder()                                           ^     符号:方法builder()     位置:供应商类   /home/circleci/repo/src/main/java/guru/springframework/spring5webfluxrest/bootstrap/Bootstrap.java:64:错误:找不到符号               vendorRepository.save(Vendor.builder()                                           ^     符号:方法builder()     位置:供应商类   10个错误

     

任务:compileJava失败

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

请帮助。

2 个答案:

答案 0 :(得分:0)

尝试更改gradle,并使用./gradlewsteps:部分下的config.yml作为以下模板:

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`

答案 1 :(得分:0)

对我有用的是在build.gradle依赖项中添加“ annotationProcessor”(它也不是在本地构建的。)

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