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

Cannot configure krotoPlus protoc task via Kotlin gradle script, fallsback to asciipb file #120

Open
Strum355 opened this issue Apr 6, 2021 · 0 comments

Comments

@Strum355
Copy link

Strum355 commented Apr 6, 2021

Kroto Plus version: 0.6.1
com.google.protobuf version: 0.8.15


When trying to adapt the example krotoPlusConfig.gradle to Kotlin Gradle script, I havent been successful. My only success has been with the config defined in a json file (and presumably will also work for asciipb etc).

For the first code snippet, I get the following exception:

Execution failed for task ':semanticdb-kotlin:generateProto'.
> protoc: stdout: . stderr: Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
  Caused by: java.lang.IllegalStateException: Config file does not exist. '/home/noah/Sourcegraph/lsif-kotlin/semanticdb-kotlin/build/kroto/config/main.asciipb'
        at com.github.marcoferrer.krotoplus.generators.GeneratorContextKt.getConfigFile(GeneratorContext.kt:74)
        at com.github.marcoferrer.krotoplus.generators.GeneratorContextKt.getCompilerConfig(GeneratorContext.kt:53)
        at com.github.marcoferrer.krotoplus.generators.GeneratorContext.<init>(GeneratorContext.kt:36)
        at com.github.marcoferrer.krotoplus.generators.GeneratorKt.initializeContext(Generator.kt:86)
        at com.github.marcoferrer.krotoplus.generators.GeneratorKt.initializeContext$default(Generator.kt:75)
        at com.github.marcoferrer.krotoplus.KrotoPlusProtoCMain.main(KrotoPlusProtoCMain.kt:32)
        ... 8 more
  --kroto_out: protoc-gen-kroto: Plugin failed with status code 1.
// ...

krotoPlus {
    config {
        register("main") {
            builder.protoBuilders {
                useDslMarkers = true
                unwrapBuilders = true
            }
        }
    }
}

protobuf {
    protoc { artifact = "com.google.protobuf:protoc:3.15.7" }

    generatedFilesBaseDir = sourceSets.main.get().kotlin.sourceDirectories.asPath.split(":")[0].removeSuffix("main/kotlin")

    plugins {
        id("kroto") { artifact = "com.github.marcoferrer.krotoplus:protoc-gen-kroto-plus:0.6.1" }
    }

    generateProtoTasks {
        val krotoConfig = file("${projectDir}/krotoconfig.json")
        all().forEach { task ->
            task.inputs.files(krotoConfig)

            task.plugins {
                id("kroto") {
                    outputSubDir = "java"
                    option(krotoPlus.config["main"].asOption())
					//option("ConfigPath=${krotoConfig}")
                }
            }
        }
    }
}

With the following diff, I get com.github.marcoferrer.krotoplus.config.CompilerConfig$Builder cannot be cast to com.github.marcoferrer.krotoplus.gradle.compiler.CompilerConfigWrapper:

34c34
<         register("main") {
---
>         id("main") {
@Strum355 Strum355 changed the title Cannot configure via Kotlin gradle script, fallsback to asciipb file Cannot configure krotoPlus protoc task via Kotlin gradle script, fallsback to asciipb file Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant