미운 오리 새끼의 우아한 개발자되기

[CodeBuild] Execution failed for task ':compileQuerydsl'.> error: invalid source release: 17 본문

Errors!!!/Spring & Spring Boot Error

[CodeBuild] Execution failed for task ':compileQuerydsl'.> error: invalid source release: 17

Serina_Heo 2022. 11. 14. 10:13

 

version: 0.2

env:
  variables:
    SPRING_PROFILE: "dev"

phases:
  pre_build:
    commands:
      - echo Logging in to Amazon ECR...
      - aws --version
      - aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin <aws ecr 주소>
      - REPOSITORY_URI=<aws ecr 주소>
      - COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
      - IMAGE_TAG=${COMMIT_HASH:=dev}
  build:
    commands:
      - chmod +x ./gradlew
      - echo SPRING_PROFILES_ACTIVE => ${SPRING_PROFILE}
      - echo make jar...
      - ./gradlew assemble
      - echo Build started on `date`
      - echo Building the Docker image...
      - docker build -f Dockerfile -t $REPOSITORY_URI:dev . --build-arg JAR_FILE=build/libs/saladist-0.0.1-SNAPSHOT.jar
      - docker tag $REPOSITORY_URI:dev $REPOSITORY_URI:$IMAGE_TAG
  post_build:
    commands:
      - echo Build completed on `date`
      - echo Pushing the Docker images...
      - docker push $REPOSITORY_URI:dev
      - docker push $REPOSITORY_URI:$IMAGE_TAG
cache:
  paths:
    - 'root/.gradle/**/*'
plugins {
	id 'org.springframework.boot' version '2.7.4'
	id 'io.spring.dependency-management' version '1.0.14.RELEASE'
	id 'java'
	id 'com.ewerk.gradle.plugins.querydsl' version '1.0.10'
}

group = 'kr.co.hist'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'

repositories {
	mavenCentral()
}

dependencyManagement {
	imports {
		mavenBom('com.amazonaws:aws-xray-recorder-sdk-bom:2.8.0')
	}
}

dependencies {
	// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind
	implementation 'com.fasterxml.jackson.core:jackson-databind:2.14.0-rc2'
	// https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-core
	implementation 'com.amazonaws:aws-java-sdk-core:1.12.329'
	// https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-cognitoidentity
	implementation 'com.amazonaws:aws-java-sdk-cognitoidentity:1.12.328'
	// https://mvnrepository.com/artifact/software.amazon.awssdk/cognitoidentityprovider
	implementation 'software.amazon.awssdk:cognitoidentityprovider:2.18.4'
	// https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk
	implementation 'com.amazonaws:aws-java-sdk:1.12.329'

	// https://mvnrepository.com/artifact/org.postgresql/postgresql
	implementation 'org.postgresql:postgresql:42.5.0'
	implementation 'org.springframework.boot:spring-boot-starter-data-jpa:2.7.4'
	implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
	implementation 'org.springframework.boot:spring-boot-starter-web'
	// https://mvnrepository.com/artifact/org.springdoc/springdoc-openapi-ui
	implementation 'org.springdoc:springdoc-openapi-ui:1.6.12'

	// queryDsl
	// https://mvnrepository.com/artifact/com.querydsl/querydsl-apt
	annotationProcessor 'com.querydsl:querydsl-apt:5.0.0'
	// https://mvnrepository.com/artifact/com.querydsl/querydsl-jpa
	implementation 'com.querydsl:querydsl-jpa:5.0.0'

	compileOnly 'org.projectlombok:lombok'
	annotationProcessor 'org.projectlombok:lombok'
	testImplementation 'org.springframework.boot:spring-boot-starter-test'
	testImplementation 'org.springframework.batch:spring-batch-test'
	testImplementation 'org.springframework.security:spring-security-test'
}

test {
	// useJUnitPlatform()
}

/* 10-5. querydsl 에서 사용할 경로 지정*/
def querydslDir = 'src/main/generated'

/* 10-6. JPA 사용 여부와 사용할 경로를 지정*/
querydsl {
	jpa = true
	querydslSourcesDir = querydslDir
}

/* 10-7. build 시 사용할 SourceSet 추가 */
sourceSets {
	main.java.srcDir querydslDir
}

/* 10-8. querydsl 이 compileClasspath 를 상속하도록 설정 */
configurations {
	compileOnly {
		extendsFrom annotationProcessor
	}
	querydsl.extendsFrom compileClasspath
}

/* 10-9. querydsl 컴파일시 사용할 옵션 설정 */

compileQuerydsl {
	options.annotationProcessorPath = configurations.querydsl
}
[Container] 2022/11/14 00:30:07 going inside waitForAgent
2 [Container] 2022/11/14 00:30:07 Waiting for agent ping
3 [Container] 2022/11/14 00:30:08 Waiting for DOWNLOAD_SOURCE
4 [Container] 2022/11/14 00:30:12 Phase is DOWNLOAD_SOURCE
5 [Container] 2022/11/14 00:30:12 finished waitForAgent
6 [Container] 2022/11/14 00:30:12 inside CopySrc
7 [Container] 2022/11/14 00:30:12 CODEBUILD_SRC_DIR=/codebuild/output/src658849370/src/git-codecommit.ap-northeast-2.amazonaws.com/v1/repos/saladist-dev-api
8 [Container] 2022/11/14 00:30:12 finished CopySrc
9 [Container] 2022/11/14 00:30:12 YAML location is /codebuild/output/src658849370/src/git-codecommit.ap-northeast-2.amazonaws.com/v1/repos/saladist-dev-api/buildspec.yml
10 [Container] 2022/11/14 00:30:12 Not setting HTTP client timeout for source type codecommit
11 [Container] 2022/11/14 00:30:12 Processing environment variables
12 [Container] 2022/11/14 00:30:12 No runtime version selected in buildspec.
13 [Container] 2022/11/14 00:30:15 Moving to directory /codebuild/output/src658849370/src/git-codecommit.ap-northeast-2.amazonaws.com/v1/repos/saladist-dev-api
14 [Container] 2022/11/14 00:30:15 Configuring ssm agent with target id: codebuild:5bf74ea3-cacb-41ef-bfc0-7d4a0b0c0153
15 [Container] 2022/11/14 00:30:15 Successfully updated ssm agent configuration
16 [Container] 2022/11/14 00:30:15 Registering with agent
17 [Container] 2022/11/14 00:30:15 Phases found in YAML: 3
18 [Container] 2022/11/14 00:30:15 PRE_BUILD: 6 commands
19 [Container] 2022/11/14 00:30:15 BUILD: 12 commands
20 [Container] 2022/11/14 00:30:15 POST_BUILD: 1 commands
21 [Container] 2022/11/14 00:30:15 Phase complete: DOWNLOAD_SOURCE State: SUCCEEDED
22 [Container] 2022/11/14 00:30:15 Phase context status code: Message:
23 [Container] 2022/11/14 00:30:15 Entering execCommands
24 [Container] 2022/11/14 00:30:15 Entering phase INSTALL
25 [Container] 2022/11/14 00:30:15 Phase complete: INSTALL State: SUCCEEDED
26 [Container] 2022/11/14 00:30:15 Phase context status code: Message:
27 [Container] 2022/11/14 00:30:15 Entering phase PRE_BUILD
28 [Container] 2022/11/14 00:30:15 Running command echo Logging in to Amazon ECR...
29 Logging in to Amazon ECR...
30  
31 [Container] 2022/11/14 00:30:15 Running command aws --version
32 aws-cli/1.25.1 Python/3.8.10 Linux/4.14.281-212.502.amzn2.x86_64 exec-env/AWS_ECS_EC2 botocore/1.27.1
33  
34 [Container] 2022/11/14 00:30:16 Running command aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin 

35 WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
36 Configure a credential helper to remove this warning. See
37 https://docs.docker.com/engine/reference/commandline/login/#credentials-store
38  
39 Login Succeeded
40  
41 [Container] 2022/11/14 00:30:16 Running command REPOSITORY_URI
42  
43 [Container] 2022/11/14 00:30:16 Running command COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
44  
45 [Container] 2022/11/14 00:30:16 Running command IMAGE_TAG=${COMMIT_HASH:=dev}
46  
47 [Container] 2022/11/14 00:30:16 Phase complete: PRE_BUILD State: SUCCEEDED
48 [Container] 2022/11/14 00:30:16 Phase context status code: Message:
49 [Container] 2022/11/14 00:30:16 Entering phase BUILD
50 [Container] 2022/11/14 00:30:16 Running command chmod +x ./gradlew
51  
52 [Container] 2022/11/14 00:30:16 Running command echo spring profile => ${SPRING_PROFILE}
53  
54 [Container] 2022/11/14 00:30:16 Running command echo make jar...
55 make jar...
56  
57 [Container] 2022/11/14 00:30:16 Running command ./gradlew clean
58 Downloading https://services.gradle.org/distributions/gradle-7.5-bin.zip
59 ...........10%............20%...........30%............40%...........50%............60%...........70%............80%...........90%............100%
60  
61 Welcome to Gradle 7.5!
62  
63 Here are the highlights of this release:
64 - Support for Java 18
65 - Support for building with Groovy 4
66 - Much more responsive continuous builds
67 - Improved diagnostics for dependency resolution
68  
69 For more details see https://docs.gradle.org/7.5/release-notes.html
70  
71 Starting a Gradle Daemon (subsequent builds will be faster)
72 > Task :cleanQuerydslSourcesDir
73 > Task :clean UP-TO-DATE
74  
75 Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
76  
77 You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
78  
79 See https://docs.gradle.org/7.5/userguide/command_line_interface.html#sec:command_line_warnings
80  
81 BUILD SUCCESSFUL in 19s
82 2 actionable tasks: 1 executed, 1 up-to-date
83  
84 [Container] 2022/11/14 00:30:36 Running command ./gradlew build
85 > Task :initQuerydslSourcesDir
86 > Task :compileQuerydsl
87 > Task :compileQuerydsl FAILED
88  
89 FAILURE: Build failed with an exception.
90  
91 * What went wrong:
92 Execution failed for task ':compileQuerydsl'.
93 > error: invalid source release: 17
94  
95 * Try:
96 > Run with --stacktrace option to get the stack trace.
97 > Run with --info or --debug option to get more log output.
98 > Run with --scan to get full insights.
99  
100 * Get more help at https://help.gradle.org
101  
102 Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
103  
104 You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
105  
106 See https://docs.gradle.org/7.5/userguide/command_line_interface.html#sec:command_line_warnings
107  
108 BUILD FAILED in 2m 56s
109 2 actionable tasks: 2 executed
110  
111 [Container] 2022/11/14 00:33:33 Command did not exit successfully ./gradlew build exit status 1
112 [Container] 2022/11/14 00:33:33 Phase complete: BUILD State: FAILED
113 [Container] 2022/11/14 00:33:33 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: ./gradlew build. Reason: exit status 1
114 [Container] 2022/11/14 00:33:33 Entering phase POST_BUILD
115 [Container] 2022/11/14 00:33:33 Running command echo Build completed on `date`...
116 Build completed on Mon Nov 14 00:33:33 UTC 2022...
117  
118 [Container] 2022/11/14 00:33:33 Phase complete: POST_BUILD State: SUCCEEDED
119 [Container] 2022/11/14 00:33:33 Phase context status code: Message:

jdk17 을 쓰고 있어서 sourceCompatibility = '17' 라고 명시되어있는데 CodeBuild에서 에러가 난다. 

이유는 잘 모르겠는데... 아마 codeBuild에서 아직 jdk17을 support 하지 않는게 아닐까 하는 추측을 해본다. (아시는 분이 계시면 댓글로 알려주세요..)

// sourceCompatibility = '17' 

이렇게 주석처리를 하고 rebuild 를 하니까 success 했다.