Do I need to provide any further information? Or s...
# gradle
r
Do I need to provide any further information? Or should I add a bounty? I've been trying forever, but maybe it just won't work
d
where did you put your protocolbuff file?
r
Everywhere 😛 /src/res/proto, /src/commonMain/, /src/commonMain/com/testproject/
d
we put it into
src/main/proto
.
(ie:
<our module>/src/main/proto
)
and to be seen by intelliJ as source folder:
Copy code
sourceSets {
    getByName("main").java.srcDirs(
        "src/main/proto",
        file("${protobuf.protobuf.generatedFilesBaseDir}/main/java")
    )
}
👍 1
🎉 1
r
Awesome, I will try when I get home \o/
It gives me an error 😞
Copy code
Line 115:         getByName("commonMain").java.srcDirs(
                                            ^ Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: 
                                                public val <T> KClass<???>.java: Class<???> defined in kotlin.jvm
                                                public val Project.java: JavaPluginConvention defined in org.gradle.kotlin.dsl
                                                public val PluginDependenciesSpec.java: PluginDependencySpec defined in org.gradle.kotlin.dsl
Pointing to
.java
`.proto`does refer to ProtobufSourceDirectorySet. But can't get it to work either:
Copy code
sourceSets.apply {
getByName("commonMain").proto.srcDirs(
            "src/main/proto",
            file("${protobuf.protobuf.generatedFilesBaseDir}/main/java")
Copy code
Line 115:         getByName("commonMain").proto.srcDirs(
                                            ^ Function invocation 'proto(...)' expected

  Line 115:         getByName("commonMain").proto.srcDirs(
                                            ^ Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: 
                                                public fun SourceSet.proto(action: ProtobufSourceDirectorySet.() -> Unit): Unit defined in com.google.protobuf.gradle
I feel like this is the function i need to use, from the extension, but I jus tdont know how:
Copy code
fun SourceSet.proto(action: ProtobufSourceDirectorySet.() -> Unit) {
    (this as? ExtensionAware)
        ?.extensions
        ?.getByType(ProtobufSourceDirectorySet::class.java)
        ?.apply(action)
}
I tried the examples, I used sourceSets without
apply
, all no luck (https://github.com/googleapis/gapic-generator-kotlin/blob/58ce58c725ae8ab63fd3834a28866a9fdf73df68/example-api-cloud-clients/build.gradle.kts) It really seems to have to do with the project being multiplatform/no java?
d
The code is just to add the folder as source director in IntelliJ. Maybe you can try without. Just put your protobuf file into SRC/main/protobuf
you can see some of the helpers I added to improve the use of protobuf with Kotlin DSL as well
👍 1