https://kotlinlang.org logo
a

aleksey.tomin

08/13/2020, 6:14 AM
I try to migrate my MP multi-module project to 1.4-RC The root module has no code. On
./gradlew tasks
see error
Please initialize at least one Kotlin target in 'my-project (:)'.
What I need to do? On 1.3.72 all OK. --info and --debug doesn’t help me. macOS, KMP contains OSX/minGW/android code gradle 6.4, 6.5.1 or 6.6, jdk - 1.8 or 11 - result the same PS: Solved - just add into root
build.gradle.kts
Copy code
kotlin {
    jvm()
}
Thanks for @msink
g

gildor

08/13/2020, 6:47 AM
Looks that you apply kotlin mpp plugin in your root project, but didn’t configure any targets there
m

msink

08/13/2020, 7:10 AM
I had same error - in my project
samples
directory does'nt contain any code, all code is in subdirectories. So as workaround just added dummy
Copy code
kotlin {
    jvm()
}
block in
samples/build.gradle.kts
.
g

gildor

08/13/2020, 7:16 AM
but why this module even applies kotlin mpp plugin if it doesn’t have sources. If it just a root project which doesn’t build anything itself it usually shouldn’t apply any plugins
☝🏻 2
a

aleksey.tomin

08/13/2020, 8:15 AM
@msink thank you, it works!
g

gildor

08/14/2020, 3:40 PM
Yep, as I thought, you are applying mpp plugin to root module, even tho you don't have any code there or config, do not apply it to avoid warning (which correctly warns you that it's misconfigured)
m

msink

08/14/2020, 4:26 PM
Or apply it in root module like this:
kotlin("multiplatform") version "1.4.0-rc" apply false
But my situation in
kotlin-libui
is a little different: in root
build.gradle.kts
I have
kotlin("multiplatform") version Kotlin.version apply false
,
in `settings.gradle.kts`:
Copy code
include(":libui")
include(":samples:controlgallery")
include(":samples:datetime")
include(":samples:drawtext")
include(":samples:form")
include(":samples:hello")
include(":samples:hello-ktx")
include(":samples:histogram")
include(":samples:logo")
include(":samples:table")
include(":samples:timer")
(
:samples
itself even not included)
And without that worksround - error
Please initialize at least one Kotlin target in 'samples (:samples)'
g

gildor

08/15/2020, 3:42 AM
@msink but you do apply multiplatform in
samples
, which is not used there, but used by subprojects. I understand why you are doing this, to make Gradle generate accessors so you could apply configuration in subprojects One way to do that is do not apply plugin to project itself, and instead use dynamic syntax to access extension
m

msink

08/15/2020, 8:23 AM
Thanks 😁
👌 1
n

nrobi

11/04/2020, 8:49 AM
I have the same issue when updating to AS
4.2.0-alpha15
, but I’m not applying the kotlin mpp plugin in the root
build.gradle.kts
@gildor am I missing something? 🤔
g

gildor

11/04/2020, 8:52 AM
maybe you have some other code in another module which applies it
nobody prevent other module call allprojects{} from any other module
you can try to add observer for plugins and crash if plugin is applied to root module
👍 1
Also, you may have the same problem with any other module, not only root
n

nrobi

11/04/2020, 9:19 AM
It seems that updating gradle from
6.7-rc-4
to
6.7
solves the issue
3 Views