Skip to content

Instantly share code, notes, and snippets.

@pgreze
Last active May 11, 2023 04:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pgreze/a40ba2a410a545773d089271fd6b48e0 to your computer and use it in GitHub Desktop.
Save pgreze/a40ba2a410a545773d089271fd6b48e0 to your computer and use it in GitHub Desktop.
Showcase how adding an optional parameter without @jvmoverloads breaks a library API
package gradle.deps.conflicts
import com.github.pgreze.process.process
import kotlinx.coroutines.runBlocking
fun main() {
runBlocking {
// Notice it's missing the Charset argument introduced in kotlin-process 1.4,
// and it's only appearing when running the app:
//
// Exception in thread "main" java.lang.NoSuchMethodError:
// 'java.lang.Object com.github.pgreze.process.ProcessKt.process$default
// (java.lang.String[], com.github.pgreze.process.InputSource, com.github.pgreze.process.Redirect,
// com.github.pgreze.process.Redirect, java.util.Map, java.io.File, boolean, kotlin.jvm.functions.Function2,
// kotlin.coroutines.Continuation, int, java.lang.Object)'
Library.whoami()
process("echo", "Hello world", charset = Charsets.UTF_8)
}
}
plugins {
id("org.jetbrains.kotlin.jvm") version "1.5.31"
`java-library`
}
allprojects {
repositories { mavenCentral() }
}
subprojects {
apply(plugin = "org.jetbrains.kotlin.jvm")
apply(plugin = "org.gradle.java-library")
dependencies {
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
}
}
project(":app") {
dependencies {
implementation(project(":lib"))
implementation("com.github.pgreze:kotlin-process:1.4")
}
}
project(":lib") {
dependencies {
implementation("com.github.pgreze:kotlin-process:1.3.1")
}
}
package gradle.deps.conflicts
import com.github.pgreze.process.process
import kotlinx.coroutines.runBlocking
object Library {
fun whoami() = runBlocking {
process("whoami")
}
}
rootProject.name = "gradle-deps-conflicts"
include("app", "lib")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment