androidgradlemaven-publish

How to share an app with a dependency from maven local


I need to share a source code for a project that depends on libraries in maven local. I am the only one maintaining the project so maven local is enough. Now I have to share my source code so the people can just run gradle buildRelease and it will go. But how do I share the maven local dependencies?

in the gradle I have

...
    implementation("us.my.project:that-project:1.5.0") {

that obviously works only on my machine. So I deleted that line and added the .aar manualy

...
    implementation files('libs/that-project-1.5.0.aar')
...

but now that doesnt add the dependencies contained in that-project.

I have a pom.xml but I can't find a way how to import that..?

I can't import that-project as a module and somehow package it with it because I would have to do so for another 7 modules across 5 different projects and that's just crazy for a one time export.

So is there any way to include all the dependencies in one zip file?

NOTE: that-project has a dependency on another-project which also lives on maven local (there is about 5 projects)


Solution

  • One solution is copying the ~/.m2/repositories folder into your app/libs folder. Then in your gradle define the directory as your maven repo.

    repositories {
        maven {
            url uri("${rootProject.projectDir}/app/libs/repository")
        }
    }
    

    After you defined your repository you can access your artifacts the same way you have been accessing them before:

    implementation("us.my.project:that-project:1.5.0")
    

    This approach makes it easy to zip your folder and send the full source code including your local maven dependencies.