What magic decides when `api()` and `implementatio...
# gradle
m
What magic decides when
api()
and
implementation()
etc. in
dependencies {}
resolve and when not?
Copy code
Line 9: 	api(project(":fluid-stdlib"))
           ^ Unresolved reference: api
When I add the plugin
kotlin-dsl
manually to the project (it's a subproject) then it works. When I add
kotlin-dsl
to the root project then it doesn't work in the subproject. When I add it to both, I get:
Copy code
Error resolving plugin [id: 'org.gradle.kotlin.kotlin-dsl', version: '1.1.3']
> Plugin request for plugin already on the classpath must not include a version
I guess it's because I don't add the Kotlin/Java plugins using
plugins {}
.
Alright, so adding
java-library
also does the trick.
Is there a way for the parent project to define plugins for subprojects so that no
plugins {}
is needed in them?
Finally…
Copy code
subprojects {
	apply<JavaLibraryPlugin>()
}
Simple solution, tricky to figure out 😮
j
@Marc Knaup It's scoped to where you apply the plugin that adds those configurations.
n
apparently plugins {
kotlin-dsl
} does a bit more than whats visible.. so you need to change it to
plugins { id("org.gradle.kotlin.kotlin-dsl") }
so it does not override the version
i think gradle should only error when a subproject requests a verion that differs fro mthe one already applied.. the current behaviour makes some things really hard to deal with.. like having a sample project both as subproject and as standalone