Is it possible to declare git repository as dependency in android gradle?

后端 未结 5 448
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-30 19:27

I want to use master version of my lib from mavencentral.

Is it possible to declare git repository as dependency in android gradle?

5条回答
  •  执笔经年
    2020-11-30 19:29

    Or you can register a repository as a submodule like this

    $ git submodule add my_sub_project_git_url my-sub-project
    

    Then include the project in your settings.gradle file which should look like this

    include ':my-app', ':my-sub-project'
    

    Finally, compile the project as a dependency in your application build.gradle file like this

    dependencies {
      compile project(':my-sub-project')
    }
    

    Then, when cloning your project, you will only have to add the option --recursive to make git automatically clone the root repository, and all its submodules.

    git clone --recursive my_sub_project_git_url
    

    I hope it helps.

提交回复
热议问题