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

ShootingStar

09/05/2019, 8:17 AM
however current version of kotlin 1.3. There is no expectedBy
g

gildor

09/05/2019, 8:20 AM
It’s part of old MPP plugin, new MPP don’t have this
Why do you want to split?
s

ShootingStar

09/05/2019, 8:21 AM
The same reason we split as a module
g

gildor

09/05/2019, 8:22 AM
I mean you can have multiple modules
s

ShootingStar

09/05/2019, 8:22 AM
so 🙂 how?
g

gildor

09/05/2019, 8:22 AM
I probably misunderstood you, I thought tthat you talking about spliting module to multiple platfroms
so just create multiple modules and use usual Gradle dependencies API:
dependencies { implementatation(project(“:some-other-module”)) }
s

ShootingStar

09/05/2019, 8:23 AM
unfortunately it doesn’t work
g

gildor

09/05/2019, 8:24 AM
Maybe you could than show some error message
s

ShootingStar

09/05/2019, 8:24 AM
I will wait a sec mate 🙂
Copy code
Could not determine the dependencies of task ':app0:compileKotlinJvm'.
> Could not resolve all task dependencies for configuration ':app0:jvmCompileClasspath'.
   > Could not resolve project :ein.
     Required by:
         project :app0
      > Unable to find a matching variant of project :ein:
          - Variant 'metadataApiElements':
              - Required org.gradle.usage 'java-api' and found incompatible value 'kotlin-api'.
              - Found org.jetbrains.kotlin.localToProject 'public' but wasn't required.
              - Required org.jetbrains.kotlin.platform.type 'jvm' and found incompatible value 'common'.
          - Variant 'metadataCompile':
              - Required org.gradle.usage 'java-api' but no value provided.
              - Found org.jetbrains.kotlin.localToProject 'local to :ein' but wasn't required.
              - Required org.jetbrains.kotlin.platform.type 'jvm' and found incompatible value 'common'.
          - Variant 'metadataCompileOnly':
              - Required org.gradle.usage 'java-api' but no value provided.
              - Found org.jetbrains.kotlin.localToProject 'local to :ein' but wasn't required.
              - Required org.jetbrains.kotlin.platform.type 'jvm' and found incompatible value 'common'.
          - Variant 'metadataDefault':
              - Required org.gradle.usage 'java-api' but no value provided.
              - Found org.jetbrains.kotlin.localToProject 'local to :ein' but wasn't required.
              - Required org.jetbrains.kotlin.platform.type 'jvm' and found incompatible value 'common'.
I add depedency like this
Copy code
sourceSets {
        commonMain {
            dependencies {
                api project(':ein')
                implementation kotlin('stdlib-common')
            }
        }
 ...
of course i tried
implementation
too
it gave me the same error
b

Big Chungus

09/05/2019, 8:32 AM
In new mpp modules are replaced by source sets. Create a new source set from preset and make other source sets depend on it
g

gildor

09/05/2019, 8:32 AM
It justt works for me with Gradle 5.6.1 and Kotlin 1.3.50
In new mpp modules are replaced by source sets
It’s incorrect
s

ShootingStar

09/05/2019, 8:32 AM
Did you define jvmMain?
g

gildor

09/05/2019, 8:32 AM
module != sourceSet
s

ShootingStar

09/05/2019, 8:33 AM
before entrypoint define, It works well however, after define entrypoint (jvmMain) it complain like as the above error
g

gildor

09/05/2019, 8:33 AM
Modules are much more better abstraction, which provide actual encapuslation, source set is just additionl dir
b

Big Chungus

09/05/2019, 8:33 AM
@gildor You are correct, I meant on the high level they can be treated as interchangeable. Although each has differences.
g

gildor

09/05/2019, 8:34 AM
Oh which level?
For example Gradle compiles different modules in parallerl, but you cannot do this for different source sets of the same platform
you can have dependency on module, you cannot depend on single source set, so they are not interchangable at all
b

Big Chungus

09/05/2019, 8:35 AM
On the level where you're only worried about the dependency/code management.
So having the code in separate sourceSet or module and having another sourceSet or module depend on it achieves the same
g

gildor

09/05/2019, 8:35 AM
exactly, in terms of dependency/code management it’s completely different story
you cannot have dependency from one source set of one module to another source set of another module
save for modules. Source set is just an additional root dir with sources of the same moduke
@ShootingStar Yes, it still works for me with JVM target
s

ShootingStar

09/05/2019, 8:39 AM
hmm…what did I wrong then
could you provide a repo?
probably you have this error because you add this module as dependency to JVM target, instead of common
s

ShootingStar

09/05/2019, 8:42 AM
I can’t say thank you enough 🙂
I will have a look
@gildor Definitely yours working but I have few questions.
- what is difference depedencies between in and out of sourceSets?
g

gildor

09/05/2019, 8:54 AM
in and out of sourceSets?
s

ShootingStar

09/05/2019, 8:54 AM
the depedencies in your project it is not in the
Copy code
kotlin {
  ... 
  sourceSets{
...
g

gildor

09/05/2019, 8:55 AM
should be no difference
I prefer Gradle convention for dependencies declaration than custom DSL of Kotlin MPP plugin
but those configurations are provided by Kotlin MPP plugin, nothing custom, so it should work in the same way
s

ShootingStar

09/05/2019, 8:56 AM
The only difference your code and mine is mine is inside ’kotlin->sorucesets->commonmain->depedencies
but anyway 🙂 your code is definitely working one so I will follow your style
g

gildor

09/05/2019, 8:58 AM
Changed to sourceSet syntax still works for me
s

ShootingStar

09/05/2019, 8:59 AM
arrrrggghhh 😞 then why mine
g

gildor

09/05/2019, 9:00 AM
Which version of Gradle/Mpp plugin do you use?
s

ShootingStar

09/05/2019, 9:01 AM
1.3.50 // 5.2.1
g

gildor

09/05/2019, 9:01 AM
5.2.1 is a way too old Gradle
5.2.1 doesn’t support Gradle Metadata 1.0, so it also may be a problem
s

ShootingStar

09/05/2019, 9:01 AM
😭 okay I will update it
yes it works now. targets + gradle update works @gildor thank you heaps
g

gildor

09/05/2019, 9:25 AM
👍
yeah, most probably it’s a problem with targets, they should match to be used in another module common source set