Open milkcoke opened 1 year ago
I applied OpenRewrite library
But it doesn't resolve this problem. Still io-grpc generate javax.annotation.x
.
plugins {
id("org.openrewrite.rewrite") version("5.34.0")
}
rewrite {
activeRecipe("org.openrewrite.java.migrate.jakarta.JavaxAnnotationMigrationToJakartaAnnotation")
}
repositories {
mavenCentral()
}
dependencies {
rewrite("org.openrewrite.recipe:rewrite-migrate-java:1.16.0")
}
OpenRewrite can't enforce for third party libary to use another annotation.
Configure annotation processors supported by IntelliJ
buildscript {
ext {
protobufVersion = '3.21.12'
protobufPluginVersion = '1.52.1'
grpcVersion = '1.52.1'
}
}
plugins {
id 'java'
id 'org.springframework.boot' version '3.0.2'
id 'io.spring.dependency-management' version '1.1.0'
// The Protobuf plugin provides protobuf compilation to your project
id 'com.google.protobuf' version '0.9.2'
id 'org.openrewrite.rewrite' version '5.34.0'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '18'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'jakarta.annotation:jakarta.annotation-api:2.1.1'
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'net.devh:grpc-spring-boot-starter:2.14.0.RELEASE'
implementation "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
implementation "io.grpc:grpc-protobuf:${grpcVersion}"
// stub is a client-side component in gRPC that provides a simple wy to make remote procedure calls to a server.
implementation "io.grpc:grpc-stub:${grpcVersion}"
implementation "io.grpc:grpc-netty:${grpcVersion}"
implementation "com.google.protobuf:protobuf-java:${protobufVersion}"
implementation 'com.fasterxml.jackson.core:jackson-core:2.14.2'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.14.2'
rewrite "org.openrewrite.recipe:rewrite-migrate-java:1.16.0"
compileOnly 'org.projectlombok:lombok'
compileOnly 'jakarta.annotation:jakarta.annotation-api:2.1.1'
annotationProcessor 'org.projectlombok:lombok'
// jakarta annotation processor.
annotationProcessor 'jakarta.annotation:jakarta.annotation-api:2.1.1'
testImplementation 'org.projectlombok:lombok:1.18.22'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
tasks.named('test') {
useJUnitPlatform()
}
// sourceSets is a configuration that sources of project (target, generated)
sourceSets {
main {
java {
srcDirs 'build/generated/source/proto/main/grpc'
srcDirs 'build/generated/source/proto/main/java'
}
}
}
rewrite {
activeRecipe(
"org.openrewrite.java.migrate.jakarta.JavaxAnnotationMigrationToJakartaAnnotation",
)
}
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:${protobufVersion}"
}
// Deprecated!
// generatedFilesBaseDir = "$projectDir/src/generated"
clean {
delete generatedFilesBaseDir
}
plugins {
grpc {
artifact = "io.grpc:protoc-gen-grpc-java:${protobufPluginVersion}"
}
}
generateProtoTasks {
all()*.plugins {
grpc {option 'jakarta.annotation=true'}
}
}
}
Still doesn't work.
SpringBoot 3.x version makes use of Jakarta EE 9 APIs (jakarta.) instead of EE 8 (javax.) \ However, io.grpc still uses javax.* So there's error when building as shwon below.
Problem
error: cannot find symbol Task : compileJava FAILED
BankServiceGrpc.java