https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
gradle
  • n

    napperley

    11/20/2019, 6:13 AM
    Is it possible with MPP via Gradle Kotlin DSL to define multiple run tasks for a Kotlin Native binary that specify command line arguments?
    t
    • 2
    • 1
  • g

    Gabriel Desilets

    11/20/2019, 2:06 PM
    Hi guys ! i've got a question about the java/kotlin/scala world.. I come from PHP symfony, ruby with rails and Elixir with phoenix where the ecosysteme of these lang and framework are quite different in my opinion(don't hate me) and now i work for a company that use java8 with ant/maven and on my free time i've start a rest api with Kotlin + maven because i don't really know anything else yet in java for dependecies management, but everything i look up packages or specific kotlin deps all i see is gradle, gradle plugins, trying my hand to port some in maven to no succes and i was wondering what's the main difference between these 2. Why gradle is so much present with kotlin and is the default vs maven, i want to learn and build my sideproject with the best practices because i think my company will benefit from kotlin for mobile and web instead of java8 + old springboot. My general feeling is that anything related to the JVM is bloated and i'm having a hardtime wrapping my head around everything. PS if i've written my post in the wrong channel tell me i'll correct the problem
    e
    r
    +3
    • 6
    • 12
  • d

    Dariusz Kuc

    11/20/2019, 4:55 PM
    hello! I haven't used gradle much so was wondering whether this would be possible to do in gradle? https://kotlinlang.slack.com/archives/C0B8PUJGZ/p1574116822011100 i.e. ensure that sources are compiled when plugin is invoked (but only invoke compile if needed)
    o
    • 2
    • 3
  • e

    eekboom

    11/21/2019, 10:15 AM
    In my settings.gradle.kts, I can do this to check if a property (in ~/gradle.properties) has been set, right?
    val artifactoryUsername : String? by settings
    if(artifactoryUsername == null) {
       ...
    How can I do the same in groovy dsl? (Sorry, not all builds converted to kotlin, yet)
    j
    c
    • 3
    • 4
  • a

    alexfacciorusso

    11/21/2019, 10:57 AM
    Hi guys! How can I, using the gradle kts script, retrieve properties stored in a properties file in a particular folder with a particular name?
    m
    • 2
    • 1
  • s

    simtel12

    11/21/2019, 8:23 PM
    Hi everyone! The kotlin-android plugin seems to be allowing things to compile that shouldn't be able to. Basically, if a generated source file is using an annotation from another module then
    kotlin-android
    makes it so that module is not a required dependency. Does anyone know if this is a known bug?
    • 1
    • 1
  • l

    Lex Luthor

    11/22/2019, 12:28 AM
    After upgrading to Kotlin
    1.3.60
    from
    1.3.41
    we started getting this error in the logs:
    Internal compiler error. See log for more details
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':my-module:compileKotlin'.Open stacktrace
    Caused by: org.gradle.api.GradleException: Internal compiler error. See log for more detailsClose stacktrace
    at org.jetbrains.kotlin.gradle.tasks.TasksUtilsKt.throwGradleExceptionIfError(tasksUtils.kt:15)
    at org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.run(GradleKotlinCompilerWork.kt:122)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.runCompilerAsync(GradleKotlinCompilerRunner.kt:148)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.runCompilerAsync(GradleKotlinCompilerRunner.kt:143)
    at org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner.runJvmCompilerAsync(GradleKotlinCompilerRunner.kt:83)
    at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompilerAsync$kotlin_gradle_plugin(Tasks.kt:429)
    at org.jetbrains.kotlin.gradle.tasks.KotlinCompile.callCompilerAsync$kotlin_gradle_plugin(Tasks.kt:339)
    at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.executeImpl(Tasks.kt:296)
    at org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile.execute(Tasks.kt:268)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:103)
    We have also tried Kotlin
    1.3.50
    with the same result. On the console we see the following stacktrace:
    :my-module:compileKotlin FAILED	
    e: java.lang.NoSuchMethodError: kotlin.script.experimental.util.PropertiesCollection$Companion.key$default(Lkotlin/script/experimental/util/PropertiesCollection$Companion;Ljava/lang/Object;ZILjava/lang/Object;)Lkotlin/script/experimental/util/PropertiesCollection$PropertyKeyDelegate;	
    	at org.jetbrains.kotlin.scripting.definitions.ScriptCompilationConfigurationFromDefinitionKt.<clinit>(ScriptCompilationConfigurationFromDefinition.kt:86)	
    	at org.jetbrains.kotlin.scripting.compiler.plugin.ScriptingCompilerConfigurationExtension$updateConfiguration$hostConfiguration$1.invoke(ScriptingCompilerConfigurationExtension.kt:47)	
    	at org.jetbrains.kotlin.scripting.compiler.plugin.ScriptingCompilerConfigurationExtension$updateConfiguration$hostConfiguration$1.invoke(ScriptingCompilerConfigurationExtension.kt:28)	
    	at kotlin.script.experimental.host.ScriptingHostConfiguration.<init>(hostConfiguration.kt:20)	
    	at kotlin.script.experimental.host.ScriptingHostConfiguration.<init>(hostConfiguration.kt:25)	
    	at org.jetbrains.kotlin.scripting.compiler.plugin.ScriptingCompilerConfigurationExtension.updateConfiguration(ScriptingCompilerConfigurationExtension.kt:46)	
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:187)	
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:113)	
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createForProduction(KotlinCoreEnvironment.kt:420)	
    	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.createCoreEnvironment(K2JVMCompiler.kt:263)
    I've googled this extensively but have come up empty. Has anyone here encountered this error?
    d
    • 2
    • 3
  • u

    ubu

    11/22/2019, 5:36 AM
    Hi there. I need to add a dependency as a .aar file. I can do that by importing this file, but then I have this big file in my project and issues with remote git repositories. But that's not really what I want. So the question is: how to add a dependency to that .aar file being located outside the project folder? In the same way that Android SDK is located elsewhere. Any help will be very appreciated!
    o
    t
    • 3
    • 10
  • f

    Feri Nagy

    11/22/2019, 4:06 PM
    Hi, is there a way to
    p
    m
    +2
    • 5
    • 5
  • v

    Vincent Williams

    11/24/2019, 4:49 AM
    Is there a way to have a common dependency declared in the root gradle file that all the modules in the project can use? For example: All modules make use of the KotlinStdLib so it would be nice to not have to redeclare it in all modules. Im using the kotlin dsl
    o
    g
    • 3
    • 8
  • e

    eekboom

    11/25/2019, 11:22 AM
    When converting a JavaExec task from groovy to Kotlin I had to add an explicit
    get()
    , because
    main
    references a
    NamedDomainObjectProvider<SourceSet>
    and not an actual SourceSet:
    task foo(type: JavaExec) {
    	classpath sourceSets.main.runtimeClasspath
    has become
    tasks.create<JavaExec>("foo") {
    	classpath = sourceSets.main.get().runtimeClasspath
    Couple of questions about that: • Have I now changed the behavior from lazy to eager configuration? • How does groovy do this magic (i.e. why can I use runtimeClassPath on a Provider)? • Is there any cleaner way to do this?
    o
    • 2
    • 3
  • e

    eekboom

    11/25/2019, 11:24 AM
    (btw I hate Slack’s new wysiwyg editor)
    💯 1
    c
    • 2
    • 2
  • d

    Dariusz Kuc

    11/26/2019, 2:45 PM
    hello! what is the proper way to share constants (e.g. some common dependency version) between gradle modules, e.g. given
    project
    | build.gradle.kts
    |- childA
      | build.gradle.kts
    |- childB
      | build.gradle.kts
    how can i define some values in root build file so i can reference them from child modules build files? If I define them as
    val
    it works fine in single file but cannot be accessed outside. Guess I'm looking for :kotlin: equivalent of
    ext
    block from Groovy
    m
    • 2
    • 6
  • d

    Dariusz Kuc

    11/26/2019, 8:00 PM
    hello! by any chance anyone here got a working example of custom jacoco task (in kts) that aggregates all individual module results into single report? All the examples I found are for Groovy and I'm having trouble rewriting it in Kotlin
    • 1
    • 2
  • i

    iammini5

    12/02/2019, 12:51 AM
    Hello, I have a problem. Is there a way from root project to check whether every sub project has one gradle plugin declared ?
    d
    g
    • 3
    • 7
  • d

    Dariusz Kuc

    12/02/2019, 5:59 AM
    ❓ hello! I'm looking into creating custom gradle plugin and would like to apply it to an example project in the multi module project, e.g.
    project
    | build.gradle.kts
    | library
      | build.gradle.kts
    | custom-plugin
      | build.gradle.kts
    | example
      | build.gradle.kts <-- use both library classath dependency and apply custom-plugin to the build
    It appears that it is not possible? Above setup is pretty easy to do in Maven project but getting some trouble with Gradle. My attempt for example build script
    buildscript {
        dependencies {
            // cannot use project(path = :custom-plugin) here -> Cannot use project dependencies in a script classpath definition
            classpath("com.sample:custom-plugin:1.0.0-SNAPSHOT") // this searches for the released jar
        }
    }
    
    apply(plugin = "com.sample.custom")
    
    dependencies {
        implementation(project(path = ":library"))
    }
    Any suggestions?
    o
    • 2
    • 14
  • d

    Davide Giuseppe Farella

    12/02/2019, 7:50 AM
    Hello, I’ve published a lib on jCenter where I have some utilities for Gradle ( kotlin ) https://github.com/4face-studi0/EasyGradle There I have the following code: `val PluginDependenciesSpec.
    kotlin-android
    get() = kotlin("android")` and this is shown correctly in my
    build.gradle
    plugins {
        `kotlin-android`
    }
    But when I try to sync I got the following error: `Unresolved reference: `kotlin-android``
    o
    • 2
    • 7
  • i

    iammini5

    12/03/2019, 6:53 AM
    Is there any way for other projects to use the gradle plugin which is implemented inside the same root project?
    e
    c
    • 3
    • 11
  • g

    gmariotti

    12/05/2019, 9:14 AM
    hi, is it possible to write extensions for
    settings.gradle.kts
    ? Or is there any other best practice to avoid having duplicate code for using artifactory as a gradle plugin repository?
    g
    • 2
    • 7
  • u

    ursus

    12/06/2019, 9:49 PM
    In Android, what is the difference between
    testDebugUnitTest
    and
    testReleaseUnitTest
    ? Afaik you cannot run unit tests on a proguared release etc.?
    t
    • 2
    • 10
  • u

    ursus

    12/07/2019, 12:45 AM
    (what Im trying to do is run only certain tests via that task)
    g
    • 2
    • 13
  • s

    spierce7

    12/09/2019, 7:41 PM
    If I have a Kotlin gradle script file that I want to apply to a project
    ./gradle/deps.gradle.kts
    , do I have a way of statically accessing the file’s classes it defines externally in another kotlin file where I do something like this:
    plugins {
      `kotlin-dsl`
    }
    
    buildscript {
      apply {
        file(File(project.rootDir, "gradle/deps.gradle.kts"))
      }
    
      dependencies {
        classpath(Plugins.kotlin) // Unresolved reference error
      }
    }
    o
    g
    • 3
    • 39
  • s

    spierce7

    12/09/2019, 8:26 PM
    I just upgrade to Gradle 6.0.1 - and the first thing I noticed is that my
    settings.gradle
    is complaining that it can’t find a class from the
    buildSrc
    . Is this a change, or is this a potential bug?
    o
    • 2
    • 2
  • t

    tapchicoma

    12/09/2019, 9:11 PM
    Curious if enabling new type inference will improve build speed. Do anyone measured/noticed that?
    g
    e
    • 3
    • 7
  • n

    Nikky

    12/10/2019, 8:08 AM
    trying to import a gradle project (kts, multiple modules) and gradle throws this weird message only when i try to sync with idea:
    <http://java.io|java.io>.IOException: The filename, directory name, or volume label syntax is incorrect
    > The filename, directory name, or volume label syntax is incorrect
    i think this is somehow because windows.. but any more is speculation...
    s
    • 2
    • 3
  • e

    eekboom

    12/10/2019, 12:31 PM
    After converting a build.gradle to Kotlin, I get “Unresolved reference: compile”. How do you set common dependencies from the parent project?
    t
    e
    • 3
    • 23
  • p

    PHondogo

    12/10/2019, 6:22 PM
    Hello! I have gradle multimodule project. Each module is a kotlin multiplaform
    plugins {
        kotlin("multiplatform")
    }
    how can i set properties like jvmTarget to all submodules?
    m
    j
    g
    • 4
    • 6
  • c

    Czar

    12/14/2019, 3:26 PM
    is gradle associated ("friendly") source set support here yet with kotlin 1.3.61 and gradle 6.0.1? (e.g. to be able to use
    internal
    stuff in a custom
    integrationTests
    source-set in gradle) Also is this still the correct way to do this? Seems very ugly, and not user-friendly at all.
    val compileKotlin by tasks
    val compileIntegTestKotlin by tasks
    KotlinCompile::class.java.getMethod("setFriendTaskName\$kotlin_gradle_plugin", String::class.java).run {
        invoke(compileIntegTestKotlin, compileKotlin.name)
    }
    r
    • 2
    • 1
  • g

    gaetan

    12/17/2019, 9:43 AM
    I try to debug a gradle script. Having breakpoints on the main build file work normally. But when I use
    subprojects {
        apply from: rootProject.file('gradle/publish-bintray.gradle')
    }
    the execution doesn’t stop on my breakpoint inside my linked gradle file. Is there a way of having breakpoints on this file?
    d
    • 2
    • 2
  • s

    sean

    12/17/2019, 8:25 PM
    Is there a guide on building a linux x64 native lib via kts? I want this to be inherited by another external project. My searching has not been helping much. I'm getting the following error. I've tried spinning up a source set nativeMain, but getting that doesn't exist. - Required org.jetbrains.kotlin.platform.type 'native' and found incompatible value 'common'.
    n
    • 2
    • 35
Powered by Linen
Title
s

sean

12/17/2019, 8:25 PM
Is there a guide on building a linux x64 native lib via kts? I want this to be inherited by another external project. My searching has not been helping much. I'm getting the following error. I've tried spinning up a source set nativeMain, but getting that doesn't exist. - Required org.jetbrains.kotlin.platform.type 'native' and found incompatible value 'common'.
n

napperley

12/17/2019, 9:06 PM
Have a look at the Building Multiplatform Projects with Gradle article (covers Gradle Kotlin DSL - https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html ). Although the article isn't Linux specific it should point you in the right direction. I recommend reading through the Setting up Targets section ( https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#setting-up-targets ).
Here is a build file which shows how to publish a Kotlin Native library which targets linuxX64: https://gitlab.com/gui-vista/guivista-core/blob/master/build.gradle.kts
The linuxX64 target is the easiest Kotlin Native target to get started with. Reasonably straightforward to setup a Linux program/library quickly.
s

sean

12/17/2019, 9:17 PM
Thanks for the links I have a linux Target
linuxX64 {
        val main by compilations.getting
        binaries {}
        compilations.getByName("main") {
            cinterops.create("zfLog") {
                defFile = File("$projectDir/src/linuxX64Main/nativeInterop/cinterop/zLog.def")
                includeDirs("$projectDir/src/linuxX64Main/nativeInterop/zLog")
            }
        }
    }
Then a source set
val linuxX64Main by getting {
            dependsOn(commonMain)
        }
But I'm still getting The Kotlin source set linux was configured but not added to any Kotlin compilation
n

napperley

12/17/2019, 9:18 PM
The linuxX64 block automatically includes the dependency on the Common module.
s

sean

12/17/2019, 9:20 PM
That's what I was thinking. I'm getting the two errors. * source set configured but not added * was expecting native but found common
n

napperley

12/17/2019, 9:21 PM
Is the linuxX64 source set called native?
If that is the case then change
linuxX64 {
to
linuxX64("native")
.
s

sean

12/17/2019, 9:23 PM
I've been bouncing it around based on different kts samles I've seen. But initially it was
named("linuxX64Main")
named("linuxX64")
, then the by getting
This should be pretty straight forward. I have a single cinterop and no other dependencies. Just trying to output the linux x64 lib
Link to t he full gradle file https://gitlab.com/AnimusDesign/kotlin-logging/blob/dev/linux_x64_native/build.gradle.kts
n

napperley

12/17/2019, 9:41 PM
This block ( https://gitlab.com/AnimusDesign/kotlin-logging/blob/dev/linux_x64_native/build.gradle.kts#L125 ) is redundant since the linuxX64 block automatically includes a dependency on common. Apart from that there doesn't seem to be any other issues with the build file.
s

sean

12/17/2019, 9:42 PM
I did that as a last resort. I have this working in .gradle. But can't get it working in kts.
n

napperley

12/17/2019, 9:44 PM
Have you tried only including the minimum amount of build logic required to publish a library for the linuxX64 target?
s

sean

12/17/2019, 9:44 PM
like just linux x64 target + c interop?
:yes: 1
n

napperley

12/17/2019, 9:45 PM
In a new Git branch have a top level build.gradle.kts file that only includes the linuxX64 target, and the required C interop.
s

sean

12/17/2019, 9:50 PM
Just tried commenting out js/jvm target and source set. Wiping local m2 repo, and cleaning. Same error. Same error source set linux was configured but not added to compilation
n

napperley

12/17/2019, 9:52 PM
Try moving the sourceSets block above the linuxX64 block.
s

sean

12/17/2019, 9:53 PM
source set above linuxX64 target ressult in
KotlinSourceSet with name 'linuxX64Main' not found.
New KTS, commented to bare linux build https://gitlab.com/AnimusDesign/kotlin-logging/blob/dev/linux_only/build.gradle.kts#L125
It seems to be the cinterop. Knocking back everything to just a base hello world function works and builds
👍 1
n

napperley

12/17/2019, 10:03 PM
In that case can you gradually add cinterop for each C library, is that possible?
What does ``named("linuxX64Main") {}`` do?
s

sean

12/17/2019, 10:05 PM
I'm trying to add linux support to an existing lib, so I hadn't heard of it before. From the docs it gets a source set, and creates if not present
I only have on c lib, and I thought it was a pretty small build. But yeah I need to go through the cinterop docs. I thought I had followed the kts. But it builds and works fine. Like I can do a run application from that same block and it's fine. But it's not getting packaged up into a library
Well it is the klib files are in the ~/.m2/repository directory, and matches what's expected. But back to the initial errors I posted
n

napperley

12/18/2019, 12:30 AM
File structure of a Kotlin Native library in the local Maven repository.
Does your published library have a similar structure to the one above? ☝️
s

sean

12/18/2019, 12:34 AM
Thanks again for the help
😒imple_smile: 1
I cast the cinterop to a static lib. That fixed the issue. But now I have a hacky build sh script. I need to look at how to have gradle automatically kick off that static lib building
n

napperley

12/18/2019, 12:39 AM
Did you check the library path (on linux this can be manipulated via the LD_LIBRARY_PATH environment variable) for all dynamic C libraries that are used in the library?
s

sean

12/18/2019, 12:44 AM
Well this isn't a standard library that will be on most systems. I used the LD_PATH for another project. But this includes a small c file that needs to be compiled in conjuction. I'm working more from a container/backend native lib/app. So those will either need to be via a custom container image or statically included.
n

napperley

12/18/2019, 10:53 PM
Are you referring to Docker for the container part? Have a issue when running a Kotlin Native program via Docker (in Debian) that the C library isn't found/loaded, yet if the program is running via Linux (eg on bare metal through Linux Mint) the C library is found/loaded. Seems that Docker handles C libraries differently compared to how they are handled on Linux.
s

sean

12/19/2019, 12:20 AM
It depends on the which libc is being used. I'm just starting with native. But encountered a similar problem with nodejs target. When trying to compile the js part. The downloaded nodejs could not be launched. I had to build a custom container image to build it. I will delve into this more once I build tests into my ci/cd pipeline
🆗 1
Also while I thought this was related to the static lib. I found out you need to specifiy a nativeMain source set. If being pulled into a multi platform / common project. It worked on another linuxX64 project but not multi platform
val nativeMain by sourceSets.creating {
        dependencies {
            api("org.jetbrains.kotlin:kotlin-stdlib-common")
        }

    }
    val linuxX64 by sourceSets.creating {
        dependsOn(nativeMain)
    }
    targets.withType(KotlinNativeTarget::class.java) {
        compilations["main"].defaultSourceSet.dependsOn(nativeMain)
        when (hostPresetName) {
            "macosX64" -> TODO()
            "linuxX64" -> compilations["main"].defaultSourceSet.dependsOn(linuxX64)
            "mingwX64" -> TODO()
            else -> error("Unsupported host platform")
        }
    }
View count: 8