58 lines
2.1 KiB
Groovy
58 lines
2.1 KiB
Groovy
plugins {
|
|
id 'kotlin-multiplatform'
|
|
}
|
|
|
|
def localRepo = rootProject.file('build/.m2-local')
|
|
|
|
repositories {
|
|
maven { url = "file://$localRepo" }
|
|
}
|
|
|
|
// Determine host preset.
|
|
def hostPreset = MPPTools.defaultHostPreset(project, [kotlin.presets.macosX64, kotlin.presets.linuxX64, kotlin.presets.mingwX64])
|
|
|
|
kotlin {
|
|
targetFromPreset(hostPreset, 'curl') {
|
|
binaries {
|
|
executable() {
|
|
entryPoint = 'sample.curl.main'
|
|
if (presets.mingwX64 == hostPreset) {
|
|
// Add lib path to `libcurl` and its dependencies:
|
|
linkerOpts += ["-L${MPPTools.mingwPath()}/lib".toString()]
|
|
runTask?.environment('PATH': "${MPPTools.mingwPath()}/bin".toString())
|
|
}
|
|
runTask?.args('https://www.jetbrains.com/')
|
|
}
|
|
}
|
|
}
|
|
|
|
sourceSets {
|
|
curlMain {
|
|
dependencies {
|
|
implementation 'org.jetbrains.kotlin.sample.native:libcurl:1.0'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// The code snippet 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.
|
|
tasks.withType(AbstractCompile) {
|
|
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 {
|
|
String configurationName = kotlin.targets.curl.compilations.main.compileDependencyConfigurationName
|
|
Configuration configuration = project.configurations.getByName(configurationName)
|
|
if (configuration.canBeResolved && configuration.state == Configuration.State.RESOLVED_WITH_FAILURES) {
|
|
println(
|
|
"\nIMPORTANT:\n" +
|
|
"\tThe message about unresolved \"libcurl\" dependency likely means that \"libcurl\" has not been built and published to local Maven repo yet.\n" +
|
|
"\tPlease run \"publish\" task for \"libcurl\" sub-project and re-import Kotlin/Native samples in IDEA.\n"
|
|
)
|
|
}
|
|
}
|