【问题标题】:Private source library with public sample app gradle setup具有公共示例应用程序 gradle 设置的私有源库
【发布时间】:2015-07-03 17:45:31
【问题描述】:

我们正在开发 android 库,源未打开。但是,为了方便客户,它分布在 Maven 存储库中。

我们还为这个库提供了打开源的示例应用程序。

我们正在尝试进行设置以实现示例应用程序与库同时开发。因此可以方便地在需要时进行调试和动态修改代码。

所以我们为应用程序和库创建了两个 git 存储库。但是将它们合并的最佳方法是什么。我们看到了下一个可能性:

  • 使用 maven local 和库快照
  • 将示例应用程序作为模块复制到库中,并在发布时将所有更改合并到示例应用程序存储库,同时将库依赖项从模块更新到存储库中的工件
  • 以前使用的 git 子模块略有变化

它们都不显得高效和优雅。但与此同时,我们正在建造的东西并不是独一无二的。不知道别人是怎么做的。

我尝试在 github 上搜索库,但它们都是公共库和示例应用程序只是子模块。

重要提示 - 我们使用的是 Android Studio,因此最好尽量减少打开的 AS 窗口的数量

【问题讨论】:

    标签: android git gradle


    【解决方案1】:

    您可以创建常规的多项目结构,但可以根据某些标准19.2. Gradle properties and system properties 在依赖项之间切换。这样,开发机器上的示例项目将可以访问可以编辑和重建的库项目,但示例的开源用户将回退到 maven 库二进制 dep。

    multiproject (under git as 3rd project or as part of the library git)
     library (under git)
       build.gradle
     sample (under another git)
       build.gradle (if has libmodule defined use it, otherwise repo artefact)
     build.gradle
     settings.gradle
    

    伪代码:

    dependencies {
        compile hasDevMachineBoolean() ? project(':library') 
                                       : "com.packagename.sdk:library:1.0"
    }
    

    【讨论】:

      猜你喜欢
      • 2011-01-17
      • 1970-01-01
      • 2015-06-09
      • 2016-12-29
      • 2021-04-25
      • 2021-11-09
      • 1970-01-01
      • 1970-01-01
      • 2016-10-18
      相关资源
      最近更新 更多