Wessim
(Wessim)
September 14, 2023, 5:35pm
1
I have a library that uses Wire to generate Kotlin files from protobuf, under the build/generated/wire directory.
Here’s the code for publishing the generated files to Maven :
publishing {
publications {
register<MavenPublication>("...") {
groupId = ""
artifactId = ""
version = "n.p.m"
from(components["java"])
}
}
repositories {
maven {
url = uri("....")
credentials(...) {
accessKey = ...
secretKey = ....
}
}
}
}
and here’s the gradle task I’m running on my ci/cd lane :
gradle(task: "clean project:build project:publish...PublicationToMavenRepository")
My issue is the following, when I run ./gradlew publishToMavenLocal
, everything works fine, my generated files are included inside my JAR.
But when I run the lane on my CI/CD I have “NO-SOURCE” in front of the tasks compileKotlin
and generateMainProtos
(from Wire)
Whereas running the same lane locally (by providing hardcoded keys) works fine and I don’t have the NO-SOURCE anymore.
Is there something I’m missing ? Thank you in advance for your feedbacks !
Vampire
(Björn Kautler)
September 14, 2023, 10:36pm
2
Hard to say without seeing your build.
Do you maybe locally not build from clean state, so old stale files are used instead of freshly generated ones?
Wessim
(Wessim)
September 15, 2023, 6:58am
3
Thank you for you answer !
I made sure to build from a clean state (deleted gradle cache, refreshed dependencies, even cloned the whole project again) but I keep getting the same result.
Here’s my build gradle file :
plugins {
id("java-library")
id("kotlin")
id("maven-publish")
id("com.squareup.wire") version "4.8.0"
}
wire {
kotlin {
rpcRole = "server"
rpcCallStyle = "suspending"
grpcServerCompatible = true
}
sourcePath {
srcDirs(
"../protos"
)
}
}
dependencies {
implementation("com.squareup.wire:wire-grpc-server:4.8.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0")
api("io.grpc:grpc-protobuf:1.21.0")
api("io.grpc:grpc-kotlin-stub:1.3.0")
}
// added just for debugging
sourceSets.all {
java.srcDir("../build/generated/source/wire")
kotlin.srcDir("../build/generated/source/wire")
java.setSrcDirs(java.srcDirs.drop(1))
kotlin.setSrcDirs(kotlin.srcDirs.drop(1))
println("printing kotlin srcDirs ${kotlin.srcDirs}")
println("printing java srcDirs ${java.srcDirs}")
}
publishing {
publications {
register<MavenPublication>("grpcJava") {
groupId = "com.application"
artifactId = "grpc"
version = "0.1.0"
from(components["java"])
}
}
repositories {
maven {
url = uri("...")
credentials(AwsCredentials::class) {
accessKey = ""
secretKey = ""
}
}
}
}```
Wessim
(Wessim)
September 15, 2023, 11:54am
4
Actually I resolved the issue, it turns out my CI simply failed to checkout my submodule, so there was nothing to do with gradle. Thank you for you time !
1 Like