google / protobuf-gradle-plugin

Protobuf Plugin for Gradle
Other
1.77k stars 274 forks source link

is already defined #762

Open ezamelczyk opened 1 month ago

ezamelczyk commented 1 month ago

I have hundreds of proto files which are defined in a way that they contain the exact same names for classes but each file has a different java_outer_classname but the protoc compiler does not take it into account at all and refuses to compile.

Is there a way to enable this behavior? There's no way for me to change the definition of proto files as I am not the owner.

my build.gradle.kts:

import com.google.protobuf.gradle.*

plugins {
    alias(libs.plugins.kotlin.jvm)
    alias(libs.plugins.google.protobuf)
}

dependencies {
    implementation("com.google.protobuf:protobuf-lite:3.0.0")
}

protobuf {
    protoc {
        artifact = "com.google.protobuf:protoc:4.28.2"
    }
    generateProtoTasks {
        all().forEach {
            it.builtins {
                getByName("java") {
                    option("lite")
                }
            }
        }
    }
}

sourceSets {
    main {
        proto {
            srcDir("src/main/resources")
        }
        java {
            srcDir("src/main/java")
        }
    }
}
ejona86 commented 1 month ago

This sounds like a question for github.com/protocolbuffers/protobuf/ .

In general, I'd expect not, because the java_outer_classname is java-specific and beside-the-point. If those different messages are all in the same package, then they are clearly conflicting with each other.