Native: fix curl sample test

Don't publish libcurl to a local Maven repo, but consume it directly
as a project dependency.

Publishing appears to be fragile here, and the intention of the test
does not involve checking Gradle anyway.
This commit is contained in:
Svyatoslav Scherbina
2023-02-16 18:00:09 +01:00
committed by Space Team
parent dd7a1a8c1c
commit 72f9cdf49b
2 changed files with 1 additions and 63 deletions
@@ -2,12 +2,6 @@ plugins {
kotlin("multiplatform")
}
val localRepo = rootProject.file("build/.m2-local")
repositories {
maven("file://$localRepo")
}
//val mingwPath = File(System.getenv("MINGW64_DIR") ?: "C:/msys64/mingw64")
val mingwPath = File("C:/msys64/mingw64") // use only preinstalled verions from this path, otherwise fail with linkage errors
@@ -41,38 +35,8 @@ kotlin {
sourceSets {
val curlMain by getting {
dependencies {
implementation("org.jetbrains.kotlin.sample.native:libcurl:1.0")
implementation(project(":libcurl"))
}
}
}
// The code below is needed to make all compile tasks depend on publication of
// "libcurl" library. So that to the time of compilation the library will already be
// in Maven repo and will be successfully resolved as a dependency of this project.
targets.all {
compilations.all {
compileKotlinTask.dependsOn(":libcurl:publish")
}
}
tasks.withType<org.jetbrains.kotlin.gradle.plugin.mpp.MetadataDependencyTransformationTask> {
dependsOn(":libcurl:publish")
}
}
// The following snippet is needed to give instructions for IDEA user who just imported project
// and sees "Could not resolve..." message in IDEA console.
gradle.buildFinished {
val configurationName = kotlin.targets["curl"].compilations["main"].compileDependencyConfigurationName
val configuration = project.configurations[configurationName]
if (configuration.isCanBeResolved && configuration.state == Configuration.State.RESOLVED_WITH_FAILURES) {
println(
"""
|
|IMPORTANT:
|The message about unresolved "libcurl" dependency likely means that "libcurl" has not been built and published to local Maven repo yet.
|Please run "publish" task for "libcurl" sub-project and re-import Kotlin/Native samples in IDEA.
""".trimMargin()
)
}
}
@@ -1,21 +1,5 @@
plugins {
kotlin("multiplatform")
`maven-publish`
}
group = "org.jetbrains.kotlin.sample.native"
version = "1.0"
val localRepo = rootProject.file("build/.m2-local")
publishing {
repositories {
maven("file://$localRepo")
}
}
val cleanLocalRepo by tasks.creating(Delete::class) {
delete(localRepo)
}
val mingwPath = File(System.getenv("MINGW64_DIR") ?: "C:/msys64/mingw64")
@@ -43,16 +27,6 @@ kotlin {
}
}
}
mavenPublication {
pom {
withXml {
val root = asNode()
root.appendNode("name", "libcurl interop library")
root.appendNode("description", "A library providing interoperability with host libcurl")
}
}
}
}
// Enable experimental stdlib API used by the sample.