55 lines
1.9 KiB
Groovy
55 lines
1.9 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 {
|
|
targets {
|
|
fromPreset(hostPreset, 'curl') {
|
|
compilations.main.outputKinds 'EXECUTABLE'
|
|
compilations.main.entryPoint 'sample.curl.main'
|
|
}
|
|
}
|
|
|
|
sourceSets {
|
|
curlMain {
|
|
dependencies {
|
|
implementation 'org.jetbrains.kotlin.sample.native:libcurl:1.0'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
MPPTools.createRunTask(project, 'runProgram', kotlin.targets.curl) {
|
|
args 'https://www.jetbrains.com/'
|
|
}
|
|
|
|
// 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"
|
|
)
|
|
}
|
|
}
|