however current version of kotlin 1.3. There is no...
# announcements
s
however current version of kotlin 1.3. There is no expectedBy
g
It’s part of old MPP plugin, new MPP don’t have this
Why do you want to split?
s
The same reason we split as a module
g
I mean you can have multiple modules
s
so 🙂 how?
g
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
unfortunately it doesn’t work
g
Maybe you could than show some error message
s
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
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
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
Did you define jvmMain?
g
module != sourceSet
s
before entrypoint define, It works well however, after define entrypoint (jvmMain) it complain like as the above error
g
Modules are much more better abstraction, which provide actual encapuslation, source set is just additionl dir
b
@gildor You are correct, I meant on the high level they can be treated as interchangeable. Although each has differences.
g
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
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
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
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
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
in and out of sourceSets?
s
the depedencies in your project it is not in the
Copy code
kotlin {
  ... 
  sourceSets{
...
g
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
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
Changed to sourceSet syntax still works for me
s
arrrrggghhh 😞 then why mine
g
Which version of Gradle/Mpp plugin do you use?
s
1.3.50 // 5.2.1
g
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
😭 okay I will update it
yes it works now. targets + gradle update works @gildor thank you heaps
g
👍
yeah, most probably it’s a problem with targets, they should match to be used in another module common source set