As a prod solution, option 2 was preferred, because it would allow us to connect individual functions without depending on other unnecessary ones
buildSrc
plugins {
`maven-publish`
}
afterEvaluate {
publishing {
publications {
register<MavenPublication>("release") {
from(components.findByName("release"))
groupId = project.hierarchy.concatGroup()
artifactId = project.name
version = libs.versions.versionName.get()
}
}
repositories {
maven("...") {
credentials {
username = getLocalProperty("MAVEN_USERNAME")
password = getLocalProperty("MAVEN_PASSWORD")
}
}
}
}
}
And some utils in buildSrc
val Project.hierarchy get(): List<Project> =
generateSequence(this, Project::getParent).toList().reversed()
fun List<Project>.concatGroup(): String {
return dropLast(1).joinToString(".") { it.name }
}
Thus, we get the name of the dependencies in the repository the same as the name of the modules tree of your project
And don't forget to connect your maven repository to the gradle project
Then you can connect this plugin to the modules you want to put into the repository (or another plugin as in my case)
plugins {
id("com.android.library")
kotlin("android")
/* ... */
id("publishing-plugin")
}
After that, you can call the publishAndroidReleasePublicationToMavenRepository
or publishReleasePublicationToMavenRepository
task, depending on the configuration of your project (KMP
or Android
).
After that, all modules to which the plugin has been applied will be uploaded to the specified maven repository.
your-app-feature = { group = "YourProject.features.feature", name = "feature", version.ref = "your-proj-version" }
After a year from the previously found solution.
I Found an article on a Russian resource on this topic using a more modern version of the fat-aar solution - Grease
It may be worth considering switching to such a solution