Roman Konstantynovskyi
10/29/2020, 1:54 PMA -> S1 -> S2 -> L
In my starter (S1) I can use all classes from the library (L). But if I add my starter (S1) as a dependency to my application (A) then I can't use classes from the library and from the second starter (S2), because they aren't in compileClasspath
.
In my starter (S1) I'm adding second starter as implementation
. And also I use this configuration for adding my starter to application.
I've read that to expose dependency I should use ``java-library`` plugin for gradle and use api
configuration in my starter (S1), but this didn't help me 😞
And if I add S2 to my S1 using deprecated compile
configuration all works well. 🤔
build.gradle.kts (starter S1)
plugins {
// other plugins
`java-library`
}
dependencies {
// other dependencies
api("some:starter:1.0.0") // starter S2
}
build.gradle.kts (application A)
dependencies {
// other dependencies
implementation("own:starter:1.0.0") // starter S1
}
spand
10/29/2020, 2:03 PMapi
is present in the standard kotlin pluginspand
10/29/2020, 2:03 PMjava-library
Roman Konstantynovskyi
10/29/2020, 2:04 PMVampire
10/29/2020, 2:29 PMapi
otherwise it should be implementation
.
"in the API" means super-classes, type parameters, parameter types and return types of the public api of S1.
If L is in S1 only used for implementing logic or in private or package-private stuff, it should be implementation
.
If it is in api
, it will also be in the compile classpath of downstream project, in your case A
.
If it is in implementation
, it will not be in the compile classpath of A
just by depending on S1
.
If you use L
directly in A
yourself, you should add an explicit dependency on L
instead of depending on the transitive dependency of S1
.