ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Github Actions Build 에러
    트러블슈팅 2024. 3. 15. 09:08

    원인

    • Github으로 CI를 진행하는 과정에서 빌드가 되지 않는 문제.
    • 아래와 같은 오류가 발생.
    import org.hh99.tmomi.global.exception.GlobalException;
                                          ^
    > Task :tmomi-consumer:compileJava FAILED
    /home/runner/work/tmomi-project/tmomi-project/tmomi-consumer/src/main/java/org/hh99/tmomi_consumer/global/util/ReservationQueue.java:7: error: package org.hh99.tmomi.global.exception.message does not exist
    import org.hh99.tmomi.global.exception.message.ExceptionCode;
    
    Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
    
    You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
    
    For more on this, please refer to <https://docs.gradle.org/8.4/userguide/command_line_interface.html#sec:command_line_warnings> in the Gradle documentation.
    5 actionable tasks: 2 executed, 3 up-to-date
                                                  ^
    /home/runner/work/tmomi-project/tmomi-project/tmomi-consumer/src/main/java/org/hh99/tmomi_consumer/reservation/service/EmitterService.java:8: error: package org.hh99.tmomi.domain.reservation does not exist
    import org.hh99.tmomi.domain.reservation.Status;
                                            ^
    /home/runner/work/tmomi-project/tmomi-project/tmomi-consumer/src/main/java/org/hh99/tmomi_consumer/reservation/service/EmitterService.java:9: error: package org.hh99.tmomi.domain.reservation.document does not exist
    import org.hh99.tmomi.domain.reservation.document.ElasticSearchReservation;
                                                     ^
    /home/runner/work/tmomi-project/tmomi-project/tmomi-consumer/src/main/java/org/hh99/tmomi_consumer/reservation/service/EmitterService.java:10: error: package org.hh99.tmomi.domain.reservation.respository does not exist
    import org.hh99.tmomi.domain.reservation.respository.ElasticSearchReservationRepository;
                                                        ^
    /home/runner/work/tmomi-project/tmomi-project/tmomi-consumer/src/main/java/org/hh99/tmomi_consumer/reservation/service/EmitterService.java:26: error: cannot find symbol
    	private final ElasticSearchReservationRepository elasticSearchReservationRepository;
    	              ^
      symbol:   class ElasticSearchReservationRepository
      location: class EmitterService
    /home/runner/work/tmomi-project/tmomi-project/tmomi-consumer/src/main/java/org/hh99/tmomi_consumer/reservation/service/EmitterService.java:23: error: cannot find symbol
    @RequiredArgsConstructor
    ^
      symbol:   class ElasticSearchReservationRepository
      location: class EmitterService
    /home/runner/work/tmomi-project/tmomi-project/tmomi-consumer/src/main/java/org/hh99/tmomi_consumer/global/exception/GlobalExceptionHandler.java:3: error: package org.hh99.tmomi.global.exception does not exist
    import org.hh99.tmomi.global.exception.GlobalException;
                                          ^
    /home/runner/work/tmomi-project/tmomi-project/tmomi-consumer/src/main/java/org/hh99/tmomi_consumer/global/exception/GlobalExceptionHandler.java:4: error: package org.hh99.tmomi.global.exception.message.dto does not exist
    import org.hh99.tmomi.global.exception.message.dto.ExceptionCodeDto;
                                                      ^
    /home/runner/work/tmomi-project/tmomi-project/tmomi-consumer/src/main/java/org/hh99/tmomi_consumer/global/exception/GlobalExceptionHandler.java:12: error: cannot find symbol
    	public ResponseEntity handleGlobalException(GlobalException ex) {
    	                                                              ^
      symbol:   class GlobalException
      location: class GlobalExceptionHandler
    /home/runner/work/tmomi-project/tmomi-project/tmomi-consumer/src/main/java/org/hh99/tmomi_consumer/global/exception/GlobalExceptionHandler.java:12: error: cannot find symbol
    	public ResponseEntity handleGlobalException(GlobalException ex) {
    	                      ^
      symbol:   class ExceptionCodeDto
      location: class GlobalExceptionHandler
    /home/runner/work/tmomi-project/tmomi-project/tmomi-consumer/src/main/java/org/hh99/tmomi_consumer/reservation/controller/v1/NotificationApiController.java:3: error: package org.hh99.tmomi.global.exception does not exist
    import org.hh99.tmomi.global.exception.GlobalException;
                                          ^
    /home/runner/work/tmomi-project/tmomi-project/tmomi-consumer/src/main/java/org/hh99/tmomi_consumer/reservation/controller/v1/NotificationApiController.java:4: error: package org.hh99.tmomi.global.exception.message does not exist
    import org.hh99.tmomi.global.exception.message.ExceptionCode;
                                                  ^
    /home/runner/work/tmomi-project/tmomi-project/tmomi-consumer/src/main/java/org/hh99/tmomi_consumer/global/exception/GlobalExceptionHandler.java:11: error: cannot find symbol
    	@ExceptionHandler(GlobalException.class)
    	                  ^
      symbol:   class GlobalException
      location: class GlobalExceptionHandler
    /home/runner/work/tmomi-project/tmomi-project/tmomi-consumer/src/main/java/org/hh99/tmomi_consumer/global/config/SecurityConfig.java:10: error: package org.hh99.tmomi.global.config does not exist
    @Import({org.hh99.tmomi.global.config.SecurityConfig.class, org.hh99.tmomi.global.jwt.JwtTokenProvider.class})
                                         ^
    /home/runner/work/tmomi-project/tmomi-project/tmomi-consumer/src/main/java/org/hh99/tmomi_consumer/global/config/SecurityConfig.java:10: error: package org.hh99.tmomi.global.jwt does not exist
    @Import({org.hh99.tmomi.global.config.SecurityConfig.class, org.hh99.tmomi.global.jwt.JwtTokenProvider.class})
                                                                                         ^
    16 errors
    
    FAILURE: Build failed with an exception.
    

    분석

    • tmomi-project 안에는 tmomi-web, tmomi-producer, tmomi-consumer 세 개의 서브 모듈이 존재.
    • tmomi-consumer는 tmomi-web을 의존하고 있어, 빌드 될때 위의 이미지처럼 찾지 못하는 것으로 분석.
    • 우선 Gradle multi module에서 jar enabled false 설정 되어 있음
      • 이렇게 설정 되면 원래는 빌드 될때 .jar 파일과 plain.jar가 생성되는데, false일 경우 plain.jar가 생성되지 않음.
      • 생성되지 않으면, tmomi-consumer는 tmomi-web을 의존할 수 가 없는것으로 분석.
      jar {
      	enable = false
      }
      

    해결

    echo "artifact=$(ls ./tmomi-web/build/libs | grep -v 'plain')" >> $GITHUB_ENV
    
    • grep -v ‘plain’ 을 이용해 $GITHUB_ENV 환경 변수의 값에 tmomi-web-0.0.1-snapshot-plain.jar 가 포함되지 않도록 수정해서 해결.
Designed by Tistory.