Having difficulty setting up Gradle multiproject build for existing repository layout

前端 未结 2 418
既然无缘
既然无缘 2020-12-23 23:28

I\'m trying to craft a Gradle multiproject build for a situation in which my project layout is already dictated to me. I have something like this:

-->Shar         


        
2条回答
  •  天命终不由人
    2020-12-24 00:03

    For completeness, the settings.gradle that solved my specific example above is as follows:

    rootProject.name = 'Product1'
    
    def projectTreeRootDir = new File( "${ProjectsRoot}" )
    
    // Shared components
    
    def sharedRootDir = new File( projectTreeRootDir, 'Shared' )
    
    include ':SharedComponent1'
    project( ':SharedComponent1' ).projectDir = new File( sharedRootDir, 'SharedComponent1' )
    
    include ':SharedComponent2'
    project( ':SharedComponent2' ).projectDir = new File( sharedRootDir, 'SharedComponent2' )
    
    // Product components
    
    includeFlat 'ProductComponent1', 'ProductComponent2'
    

    Clearly this doesn't scale to large numbers of subprojects and it could be done significantly better using the hints provided by Peter above.

提交回复
热议问题