build.gradle changes for git submodule

*爱你&永不变心* 提交于 2019-12-07 08:11:28

问题


Source Tree is as follows:

core               // root
  .gitmodules     // this has box-sdk as submodule
  box-sdk          // git submodule
     BoxJavaLibraryV2     // Box related files

I also created settings.gradle

include 'box-sdk:BoxJavaLibraryV2'

My build.gradle

compile project(':box-sdk:BoxJavaLibraryV2')

At this point I was able to compile and build root project with box as dependency.

Problem started when I tried to checkin and checkout again the whole project. I did following:

I was able to check in .gitmodules and box-sdk directory. But I was not able to checkin BoxJavaLibraryV2.

It errored out saying BoxJavaLibraryV2 is a submodule

I checked out root again separately where I get both .gitmodules and box-sdk (without BoxJavaLibraryV2)

Then to build my project I had to do manually:

git submodule init
git submodule update
gradle war

What changes and where I need to do to eliminate init and update steps.

What I am looking for is:

when I checkout git master, the whole project with submodules should build with gradle war

Please help


回答1:


First, you can have only one step:

git submodule update --init --recursive

Second, Gradle itself has an open issue (since 2010) to integrate that step:
GRADLE-21: "Streamline issues with including the build as a git submodule".

A git clone --recursive would clone:checkout your repo with submodules checked out.

The issue suggests various ways, one of them being making a gradle wrapper (which would call the appropriate git submodule command before calling gradle).



来源:https://stackoverflow.com/questions/21372956/build-gradle-changes-for-git-submodule

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!