Annotation processor issues after upgrading to Java 17 + Spring Boot 3

227 views
Skip to first unread message

Michael Baroody

unread,
Jun 29, 2023, 8:10:58 AM6/29/23
to Querydsl
Hello. For the life of me, I can't figure out how to generate the Q classes after making the upgrade to Java 17 and Spring Boot 3. Here is my build.gradle: 

plugins {
id 'java'
id 'idea'
id "com.google.cloud.tools.jib" version "3.3.1"
id "io.spring.dependency-management" version "1.1.0"
id "org.springframework.boot" version "3.1.1"
id "com.diffplug.gradle.spotless" version "4.3.0"
}

ext {
set('mapstructVersion', '1.5.5.Final')
set('awssdkVersion', '2.17.82')
set('springCloudVersion', "2022.0.3")
set('queryDslVersion', '5.0.0')
set('lombokVersion', '1.18.28')
}

repositories {
mavenCentral()
}

dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

idea {
module {
sourceDirs += file("${project.buildDir}/generated/")
generatedSourceDirs += file("${project.buildDir}/generated/")
}
}

spotless {
java {
googleJavaFormat()
}
}

dependencies {

annotationProcessor "org.projectlombok:lombok:${lombokVersion}"
annotationProcessor "org.mapstruct:mapstruct-processor:${mapstructVersion}"
annotationProcessor "jakarta.persistence:jakarta.persistence-api:3.1.0"
annotationProcessor("com.querydsl:querydsl-apt:${queryDslVersion}:jakarta")

compileOnly "org.projectlombok:lombok:${lombokVersion}"
compileOnly 'com.fasterxml.jackson.core:jackson-annotations'

implementation "com.querydsl:querydsl-core:${queryDslVersion}"
implementation "com.querydsl:querydsl-jpa:${queryDslVersion}:jakarta"
implementation "jakarta.persistence:jakarta.persistence-api"

implementation "com.squareup.okhttp3:okhttp:4.9.1"
implementation 'io.kubernetes:client-java:10.0.0'

implementation 'org.springdoc:springdoc-openapi-ui:1.6.6'
implementation 'org.eclipse.persistence:org.eclipse.persistence.jpa:2.7.7'
implementation 'org.flywaydb:flyway-core'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation ('org.springframework.boot:spring-boot-starter-data-jpa') {
exclude group: 'org.hibernate', module: 'hibernate-entitymanager'
exclude group: 'org.hibernate', module: 'hibernate-core'
}
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.postgresql:postgresql:42.2.27'
implementation 'com.vladmihalcea:hibernate-types-52:2.2.2'
implementation "org.mapstruct:mapstruct:${mapstructVersion}"
implementation "org.mapstruct.extensions.spring:mapstruct-spring-annotations:${mapstructSpringExtensionsVersion}"
implementation 'com.networknt:json-schema-validator:1.0.48'
implementation "software.amazon.awssdk:s3:${awssdkVersion}"
implementation "software.amazon.awssdk:sts:${awssdkVersion}"
implementation 'com.amazonaws:aws-java-sdk-s3'
implementation platform('com.amazonaws:aws-java-sdk-bom:1.11.1000')

runtimeOnly 'org.springframework.boot:spring-boot-devtools'

testImplementation ('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
testImplementation 'org.mockito:mockito-core:3.4.6'
testImplementation 'org.junit.platform:junit-platform-runner:1.6.2' // For compatibility with JUnit4
testImplementation 'org.mockito:mockito-junit-jupiter:3.4.6'
testImplementation 'org.springframework.cloud:spring-cloud-stream-test-support'
testImplementation "org.testcontainers:testcontainers:1.15.3"
testImplementation "org.testcontainers:postgresql:1.15.3"
testImplementation "org.testcontainers:junit-jupiter:1.15.3"
testImplementation "com.squareup.okhttp3:mockwebserver:4.9.1"
testImplementation "io.projectreactor:reactor-test:3.3.15.RELEASE"
}

compileJava {
options.compilerArgs << '-Amapstruct.unmappedTargetPolicy=IGNORE'
}

group = 'com.mycompany.services'
version = tagName
description = 'my-service'

test {
useJUnitPlatform()
}

jib {
from {
image = "gcr.io/distroless/java:17"
}
to {
image = "company-repo"
def gitCommit = "${project.gitCommit}".toString()
tags = [gitCommit, "latest"]
}
container {
creationTime = "USE_CURRENT_TIMESTAMP"
}
extraDirectories {
paths {
path {
from = 'src/test/resources'
into = '/defaultconfig'
}
}
}
}

tasks.withType(JavaCompile) {
doFirst {
println "AnnotationProcessorPath for $name is \n\n${options.getAnnotationProcessorPath().getFiles().join("\n")}"
}
}

This results in this compilation error: 

 error: cannot find symbol                                                                                                                    
  private static final QDevice devices = QDevice.device;              
                       ^                                                                                                                      
  symbol:   class QDevice                                              
  location: class ServiceService             
                                                                                         

I can confirm that the Q classes are not generated. 

Can anyone see anything obviously wrong with this configuration? Do you know how I can debug? 
Reply all
Reply to author
Forward
0 new messages