*Disclaimer*: It's not really Kotlin related, be l...
# android
l
Disclaimer: It's not really Kotlin related, be lenient. I have a multi module project with some android library modules. I want to reuse the modules in other projects but currently none of them are pushed to git or published to a maven repository. I know it's possible to publish the modules to a maven repository within the main project but I'm wondering what I can do to have each module in git as single project so I can develop each module in isolation. The only solution I'm aware of is to create a new project for every module I want to have as a single project and copy the specific source files over. Is there a shorter way of doing this?
🤷 1
j
git submodules, but it is a hell
1
l
Yes you say it. But submodules also require that your module is already available in git as single project and I'm looking for a way to get a module of a multi module project into git as single project
l
There is a way with Gradle includeBuild() https://publicobject.com/2021/03/11/includebuild/
You publish your modules to your local maven
and then replace them with an includeBuild() like that article says, which will make your module show up in your main project, and you can edit the code and it will automatically build it correctly
l
When I use
includeBuid("../mylib")
I get an error:
Plugin [id: 'com.android.library'] was not found in any of the following sources
Can I even include a module which doesn't have a settings and a project level build.gradle file with
includeBuild
?
From gradle userguide for composite builds:
Each included build is configured and executed in isolation.
So you can't include a module that has no project level files. I'm looking for this, just simpler: https://stackoverflow.com/questions/67452263/how-do-you-extract-gradle-subprojects-into-standalone-libraries
l
@Lilly You have to publish your module to your local maven repository first, and it will use your package has a bundle id
So you publish your module like its a regular library, but its only made in your local maven repository
You can publish to local maven by running
publishToMavenLocal
after adding
maven-publish
has a plugin
Then you add the library has a regular dependency in your main project, and setup includebuild to replace it with a path to the repo
So you can have /Code/main-project /Code/other-module and then other-module is a dependency on main-project, but they are different folders, with different git repos
l
Maybe I miss something but what have I won when I publish it to local maven repo. I get an aar file when I do it.
Then you add the library has a regular dependency in your main project, and setup includebuild to replace it with a path to the repo
Then I have it included 2 times. Also I dont have a github repo, thats what I'm trying to do
I guess I can push the module as it is to github and when I want to change code I can include it via:
Copy code
include ':dccore'
project(":dccore").projectDir = file("../dccore")
Let me ask a simpler question. The screenshot shows my module. You can see, there are no root level files. Is it common to push it to github like it is or should I create a new project and import the module and then push it?
k
You could have independent projects in git and in your android studio and publish your archives of other modules to jitpack maven repo. But to do this you need to have one main module that depends on 1 or more other submodules. With jitpack you can add other submodules as Gradle dependencies in your main module.
l
Thanks but that's not what I'm asking. I just want to push a module to github without creating a new project for this module (standalone/single project) or a fast way to extract a module to a single project