New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gradle file example from Getting Started Guide does not work #478
Comments
Which version of gradle are you using? |
I use * Where:
Build file '/home/xetra11/Development/projects/user-service/grpc-lib/build.gradle' line: 13
* What went wrong:
A problem occurred evaluating project ':grpc-lib'.
> Could not find method implementation() for arguments [io.grpc:grpc-protobuf:1.35.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
|
Thanks for your response. I will check it later when I have some more time. |
The plugins {
id 'java'
} I managed to run it using this buildscript {
dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.14'
}
}
plugins {
id 'java-library'
id 'com.google.protobuf' version '0.8.14'
}
repositories {
mavenCentral()
}
dependencies {
compile "io.grpc:grpc-protobuf:1.35.0"
compile "io.grpc:grpc-stub:1.35.0"
}
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:3.14.0"
}
generatedFilesBaseDir = "$projectDir/src/generated"
clean {
delete generatedFilesBaseDir
}
plugins {
grpc {
artifact = "io.grpc:protoc-gen-grpc-java:1.35.0"
}
}
generateProtoTasks {
all()*.plugins {
grpc {}
}
}
} I will adjust the docs to better reflect that. |
Can you please try/review the new configuration as shown in #479? |
@ST-DDT
|
See referenced PR. The jackarta annotations api dependency is missing in J9+. |
@ST-DDT |
No you have to manually add it (You only need it at compile time). implementation 'jakarta.annotation:jakarta.annotation-api:2.0.0' // Java 9+ compatibility I wished grpc would add it directly to their dependencies. EDIT: compileOnly 'jakarta.annotation:jakarta.annotation-api:1.3.5' // Java 9+ compatibility - Do NOT update to 2.0.0 |
@ST-DDT Here is the root project build file: // build.gradle.kts (Kotlin)
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "2.4.1"
id("io.spring.dependency-management") version "1.0.10.RELEASE"
kotlin("jvm") version "1.4.21"
kotlin("plugin.spring") version "1.4.21"
kotlin("plugin.jpa") version "1.4.21"
}
group = "com.myapp"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_15
repositories {
mavenCentral()
}
dependencies {
//implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("jakarta.annotation:jakarta.annotation-api:2.0.0")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "15"
}
}
tasks.withType<Test> {
useJUnitPlatform()
} Here is the // build.gradle (Gradle)
buildscript {
dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.14'
}
}
plugins {
id 'java'
id 'java-library'
id 'com.google.protobuf' version '0.8.14'
}
repositories {
mavenCentral()
}
dependencies {
implementation "io.grpc:grpc-protobuf:1.35.0"
implementation "io.grpc:grpc-stub:1.35.0"
compile "jakarta.annotation:jakarta.annotation-api:2.0.0"
}
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:3.14.0"
}
generatedFilesBaseDir = "$projectDir/src/generated"
clean {
delete generatedFilesBaseDir
}
plugins {
grpc {
artifact = "io.grpc:protoc-gen-grpc-java:1.35.0"
}
}
generateProtoTasks {
all()*.plugins {
grpc {}
}
}
} And finally the settings file // settings.gradle.kts (Kotlin)
rootProject.name = "user-service"
include(":grpc-lib")
|
Sorry for stating the wrong version. You have to use |
@ST-DDT |
Glad I could help. |
The context
The guide gives an example of a gradle build file here: https://yidongnan.github.io/grpc-spring-boot-starter/en/server/getting-started.html
The question
However the resolution of that file files for the first dependency tasks
Stacktraces and logs
The application's environment
The build file:
The text was updated successfully, but these errors were encountered: