Last active
May 11, 2023 04:24
-
-
Save pgreze/a40ba2a410a545773d089271fd6b48e0 to your computer and use it in GitHub Desktop.
Showcase how adding an optional parameter without @jvmoverloads breaks a library API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gradle.deps.conflicts | |
import com.github.pgreze.process.process | |
import kotlinx.coroutines.runBlocking | |
object Library { | |
fun whoami() = runBlocking { | |
process("whoami") | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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