2016-03-11

Gradle 使用 subfolder 去包含 submodule

要整理在 Gradle 下面引用其他 Project , 需要在 setting.gradle 指名引用的Project. 要放在subfolder 先找到下面兩篇, 其中第二篇直接指向gradle 自己的setting.gradle
  • http://stackoverflow.com/questions/28440559/gradle-creating-build-directory-in-subfolder 
  • https://github.com/gradle/gradle/blob/master/settings.gradle 
整理結論如下:
1. Sub Project Folder Name : api-log-model
2. Sub Module Name : apiLogModel

範例
 git submodule add git@longtai.com:login/api-login-model.git module/api-login-model

.gitmodules

[submodule "module/api-log-model"]
        path = module/ApiLogModel
        url = git@longtai.com:login/api-login-model.git

setting.gradle

include 'apiLogModel'

rootProject.name = 'TestSubfolder'

rootProject.name = 'gradle'
rootProject.children.each {project ->
    String fileBaseName = project.name.replaceAll("\\p{Upper}") { "-${it.toLowerCase()}" }
    String projectDirName = "subprojects/$fileBaseName"
    project.projectDir = new File(settingsDir, projectDirName)
    project.buildFileName = "${fileBaseName}.gradle"
    assert project.projectDir.isDirectory()
    assert project.buildFile.isFile()
}

 

沒有留言:

張貼留言