https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
s

Sergey Melyukov

07/13/2020, 1:56 PM
Or maybe I can add some examples of
com.foo.bar
within
com.foo.bar
project to not to create a separate repo with examples?
s

sikri

07/13/2020, 2:11 PM
Repo != artifact You can always make a project with 2 modules - library and sample. You can deploy as an artifact built library module only.
If you want to have it as two separate projects, but with optional local usage (for example, with defined
implementation com.foo:bar:0.1.0
in
build.gradle
but with optional possibility to use local non-artifact instance) I suggest to have a look on gradle’s composite build
s

Sergey Melyukov

07/13/2020, 4:27 PM
First of all, I’ve create a multiplatform project
com.foo.bar
with this structure:
Copy code
src/commonMain
src/jsMain
src/macosMain
A little bit later, I’ve create another multiplatform project for examples of
com.foo.bar
with this structure:
Copy code
examples/src/commonMain/kotlin/example1
examples/src/commonMain/kotlin/example2
examples/src/jsMain/kotlin/example1
examples/src/jsMain/kotlin/example2
examples/src/macosMain/kotlin/example1
examples/src/macosMain/kotlin/example2
How can I import
src/*
from
examples/src/*
?
Copy code
implementation com.foo:bar:0.1.0
In
examples/build.gradle
is not working (
Maybe the better way is
Copy code
src/commonMain/com/foo/bar/*
src/commonMain/com/foo/examples/example/1
src/commonMain/com/foo/examples/example/2
src/jsMain/com/foo/bar/*
src/jsMain/com/foo/examples/example/1
src/jsMain/com/foo/examples/example/2
src/macosMain/com/foo/bar/*
src/macosMain/com/foo/examples/example/1
src/macosMain/com/foo/examples/example/2
?
Seems like I’ve got it. Just add the core as a project-dependency to examples project:
Copy code
commonMain {
    dependencies {
        implementation kotlin('stdlib-common')
        implementation project(':core')
    }
}
🎉 1