-
-
Save lordcodes/64147f4c72ede78db43868f8a6120cfa to your computer and use it in GitHub Desktop.
dependencies { | |
implementation(enforcedPlatform(project(":dependency-constraints"))) | |
implementation("org.jetbrains.kotlin:kotlin-stdlib") | |
implementation("androidx.lifecycle:lifecycle-livedata-ktx") | |
implementation("io.coil-kt:coil") | |
} |
plugins { | |
id("java-platform") | |
id("maven-publish") | |
} | |
javaPlatform { | |
allowDependencies() | |
} | |
dependencies { | |
api(enforcedPlatform("org.jetbrains.kotlin:kotlin-bom:1.4.20")) | |
constraints { | |
api("androidx.lifecycle:lifecycle-livedata-ktx:2.3.0-beta01") | |
api("io.coil-kt:coil:1.0.0") | |
} | |
} | |
publishing { | |
publications { | |
create<MavenPublication>("getBusyPlatform") { | |
from(components["javaPlatform"]) | |
} | |
} | |
} |
include("dependency-constraints") |
Thanks a lot for the insights :)
it disables regular dependency declarations as that is usually a bug
Doesn't this allow it back?
javaPlatform {
allowDependencies()
}
This or BOMs themselves in general do not bring any jar?
So this: api(enforcedPlatform("org.jetbrains.kotlin:kotlin-bom:1.4.20"))
does add zero dependencies? :)
When it comes to an article I think my idea or name would be - "Avoid dependency hell with a power of BOM and Gradle constraints" or something like that :D
Exactly I added 'allowDependencies()' in order to allow the platform to specify real dependencies so that I could specify the BOMs for other frameworks.
Also, yes adding a platform for the kotlin-bom simply brings in constraints on the versions. So that you can simply specify Kotlin dependencies throughout your project without the version, then update the Kotlin version only on the BOM.
Haha amazing. Thanks!
It essentially brings in what is in the platform module (depnedency-constraints/build.gradle.kts).
When you apply the java platform plugin by default it disables regular dependency declarations as that is usually a bug and only allows constraints.
However, I also enable dependencies in order to also add the 'kotlin-bom' as a dependency so that by using my platform as enforcedPlatform it will also apply other BOMs as well.
However, yes the dependency declarations inside 'constraints' are simply dependency constraints which mention a version.
If you use platform(...) then it just uses the version as a suggestion, so you can leave it out.
If you use enforcedPlatform(...) then it actually enforces the version and also enforces it for any transitive dependencies.
I might consider an article on this, if I can work out how to word it well.