Android Plataforma - Part 5: Simplifying Gradle Init
By Rodrigo Sicarelli 1 min read Updated
In the previous article, we set up our platform with build-logic and registered the greeting task in the main project.
Now let’s clean up the files generated by the gradle init command.
First, we’ll simplify the folder structure by moving src directly into build-logic. This step will make imports easier across our projects down the line.
To get started, head to build-logic > build.gradle.kts. Update it with the new coordinate for the implementation class and set an ID that better fits the project:
// build-logic/build.gradle.kts
plugins {
`kotlin-dsl` // `java-gradle-plugin` is already included
}
gradlePlugin {
val greeting by plugins.creating {
id = "com.rsicarelli.kplatform"
implementationClass = "com.rsicarelli.KPlatformPlugin"
}
}
Next, we’ll streamline our settings.gradle.kts, handing it the job of declaring the repositories:
// build-logic/settings.gradle.kts
rootProject.name = "build-logic"
dependencyResolutionManagement {
repositories {
mavenCentral()
}
}
Finally, we’ll use our new ID in the main project’s build.gradle.kts:
// main build.gradle.kts
plugins {
..
id("com.rsicarelli.kplatform")
}
Done!
Once everything syncs, the greeting task should still be registered in your project.
In the next article, we’ll supercharge our platform with a powerful Gradle feature: Version Catalogs.