Skip to content
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

java version "10.0.2" 2018-07-17 javax.annotation #4725

Closed
a75c6 opened this issue Aug 2, 2018 · 7 comments · Fixed by #5074
Closed

java version "10.0.2" 2018-07-17 javax.annotation #4725

a75c6 opened this issue Aug 2, 2018 · 7 comments · Fixed by #5074
Assignees
Milestone

Comments

@a75c6
Copy link

a75c6 commented Aug 2, 2018

gRPC version 1.14.0

Error has been referenced before:

#3633

When using java version "10.0.2" 2018-07-17 and building Kotlin example, receive the same error:

:compileJava FAILED
/examples/example-kotlin/build/generated/source/proto/main/grpc/io/grpc/examples/helloworld/GreeterGrpc.java:23: error: cannot find symbol
@javax.annotation.Generated(
                 ^
  symbol:   class Generated
  location: package javax.annotation

Have added the following dependency to resolve:
compile group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2'

Is that the recommended solution?

Here is the previous build.gradle currently in the example:

https://github.com/grpc/grpc-java/blob/master/examples/example-kotlin/build.gradle

Here is an updated build.gradle that runs without the error:

/*
 * This file was generated by the Gradle 'init' task.
 *
 * This is a general purpose Gradle build.
 * Learn how to create Gradle builds at https://guides.gradle.org/creating-new-gradle-builds/
 */
buildscript {
    ext.kotlin_version = '1.2.60'

    repositories {
        mavenCentral()
        mavenLocal()
    }
    dependencies {
        classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.6'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

plugins {
    id 'com.gradle.build-scan' version '1.15.1' 
}

apply plugin: 'kotlin'
apply plugin: 'com.google.protobuf'

// Generate IntelliJ IDEA's .idea & .iml project files
// Starting with 0.8.4 of protobuf-gradle-plugin, *.proto and the gen output files are added
// to IntelliJ as sources. It is no longer necessary to add them manually to the idea {} block
// to jump to definitions from Java and Kotlin files.
// For best results, install the Protobuf and Kotlin plugins for IntelliJ.
apply plugin: 'idea'

// Provide convenience executables for trying out the examples.
apply plugin: 'application'

buildScan {
    termsOfServiceUrl = 'https://gradle.com/terms-of-service'
    termsOfServiceAgree = 'yes'
}

repositories {
    mavenCentral()
    mavenLocal()
}

// IMPORTANT: You probably want the non-SNAPSHOT version of gRPC. Make sure you
// are looking at a tagged version of the example and not "master"!

// Feel free to delete the comment at the next line. It is just for safely
// updating the version in our release process.
def grpcVersion = '1.14.0' // CURRENT_GRPC_VERSION

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    compile "com.google.api.grpc:proto-google-common-protos:1.12.0"
    compile group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2'
    compile "io.grpc:grpc-netty:${grpcVersion}"
    compile "io.grpc:grpc-protobuf:${grpcVersion}"
    compile "io.grpc:grpc-stub:${grpcVersion}"

    testCompile "io.grpc:grpc-testing:${grpcVersion}" // gRCP testing utilities
    testCompile "junit:junit:4.12"
    testCompile "org.mockito:mockito-core:1.9.5"
}

protobuf {
    protoc { artifact = 'com.google.protobuf:protoc:3.6.1' }
    plugins {
        grpc { artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}" }
    }
    generateProtoTasks {
        all()*.plugins { grpc {} }
    }
}

startScripts.enabled = false

task helloWorldServer(type: CreateStartScripts) {
    mainClassName = 'io.grpc.examples.helloworld.HelloWorldServer'
    applicationName = 'hello-world-server'
    outputDir = new File(project.buildDir, 'tmp')
    classpath = jar.outputs.files + project.configurations.runtime
}

task helloWorldClient(type: CreateStartScripts) {
    mainClassName = 'io.grpc.examples.helloworld.HelloWorldClient'
    applicationName = 'hello-world-client'
    outputDir = new File(project.buildDir, 'tmp')
    classpath = jar.outputs.files + project.configurations.runtime
}

applicationDistribution.into('bin') {
    from(helloWorldServer)
    from(helloWorldClient)
    fileMode = 0755
}
@dapengzhang0
Copy link
Member

I think the Kotlin build.gradle file is missing
compileOnly "javax.annotation:javax.annotation-api:1.2"
which had to be added in https://github.com/grpc/grpc-java/blob/master/examples/build.gradle to fix #3633

@dapengzhang0
Copy link
Member

@namsoila thanks for pointing out the issue!

@dapengzhang0 dapengzhang0 added this to the 1.15 milestone Aug 2, 2018
@a75c6
Copy link
Author

a75c6 commented Aug 2, 2018

Thanks!

@a75c6 a75c6 closed this as completed Aug 2, 2018
@dapengzhang0
Copy link
Member

We still need a fix to kotlin build.gradle in examples directory though.

@dapengzhang0 dapengzhang0 reopened this Aug 2, 2018
@a75c6
Copy link
Author

a75c6 commented Aug 3, 2018

Sounds good. Version 1.3.2 is available. Is there a specific reason for 1.2?

// https://mvnrepository.com/artifact/javax.annotation/javax.annotation-api
compile group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2'

@dapengzhang0
Copy link
Member

dapengzhang0 commented Aug 3, 2018

The reason seemed to be that version 1.3.2 doesn't support Java 7. Once grpc stops supporting Java 7, we can bump it to 1.3.2. For your own project with JDK 10, no problem to use 1.3.2

@a75c6
Copy link
Author

a75c6 commented Aug 5, 2018

Thanks.

@zhangkun83 zhangkun83 modified the milestones: 1.15, 1.16 Aug 28, 2018
@ejona86 ejona86 modified the milestones: 1.16, 1.17 Oct 11, 2018
dapengzhang0 added a commit that referenced this issue Nov 20, 2018
- add CI for kotlin non-android
- bump kotlin version to fix kotlin compiler issue on jdk11
- add javax.annotation dep to fix kotlin build on jdk 9 & 11

Fixes #4725
@dapengzhang0 dapengzhang0 modified the milestones: 1.17, 1.18 Nov 20, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Feb 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants