We plan to use Git for our project which is a grails application have multiple components on the framework. We planned to keep the framework and each and every component in a separate repository. SO that depending upon the customer requirement we can mix and match the components. The components cant not run on its own it depends on the framework.
Take the below example where A and B are the components and F is the Framework,
F
/ \
A B
So when every we want to do some changes to the component we need to fetch the component A and it should automatically fetch F (Framework). When ever we do the changes to the framework and component both the changes should go the corresponding repository.
I looked into submodules but the directory structure followed in grails application does not suite. The application files are like below,
Component
+ grails-app
+ conf ---> location of configuration artifacts
+ hibernate ---> optional hibernate config
+ spring ---> optional spring config
+ controllers ---> location of controller artifacts
+ domain ---> location of domain classes
+ i18n ---> location of message bundles for i18n
+ services ---> location of services
+ taglib ---> location of tag libraries
+ util ---> location of special utility classes
+ views ---> location of views
+ layouts ---> location of layouts
This directory structure is followed by all the components and also the framework. The Framework which is the main project has some more file like below,
Framework
+ grails-app
+ conf ---> location of configuration artifacts
+ hibernate ---> optional hibernate config
+ spring ---> optional spring config
+ controllers ---> location of controller artifacts
+ domain ---> location of domain classes
+ i18n ---> location of message bundles for i18n
+ services ---> location of services
+ taglib ---> location of tag libraries
+ util ---> location of special utility classes
+ views ---> location of views
+ layouts ---> location of layouts
+ lib
+ scripts ---> scripts
+ src
+ groovy ---> optional; location for Groovy source files
开发者_Python百科 (of types other than those in grails-app/*)
+ java ---> optional; location for Java source files
+ test ---> generated test classes
+ web-app
+ WEB-INF
So the component folder structure and the files are merged together for running the application.
Please propose a solution to this problem.
Take a look at git submodule.
This is what git submodules are for.
About the best you can do is use one huge repository. This isn't pretty and definitely isn't standard practice with git
, but does satisfy your requirements.
- Start with a new repository, say
~/main
. To this, commit some basic files, perhaps a README, or an empty grails-app folder, or similar. - Create a branch, then commit your framework to that. You now have a two branchs, and almost empty
master
and aframework
branch. - Create a new branch off
master
for each component. Any development for these components will need to happen on these branches (or will need to have their history mangled so that it appears like it was). - Each new project (
~/project1
,~/project2
, etc) will clone this repository and use themaster
branch for development of the main project. Presumably the first few commits will be commands likegit merge framework
andgit merge component-x
to get all the requirements for the project intomaster
. - Any improvements to
component-x
will need to be commited to thecomponent-x
branch. This allows improvements to be pushed back into the main repository and then pulled from there into other projects and merged into theirmaster
branches.
Again, this is mostly hackery, and you would be much, much better using submodules if at all possible. But it seems like grails doesn't really want to play nicely with this.
精彩评论