2016-12-14 52 views
0

假設我們有以下項目結構。Gradle:在不知道其子項目細節的情況下包含項目

A depends on B 
B depends on C 

我想項目A,使得它不知道項目C.什麼它應該只知道它的直接依賴項目B.項目B應包含所有關於它如何取決於項目C.

信息

所有項目的細節必須在他們自己的gradle文件中。

更具體的假設應該有以下任務依賴

task build in A must depend on task build from B 
task build in B must depend on task build from C 

我怎麼能這樣做?

回答

0
project(':a') { 
    apply plugin: 'java' 
    evaluationDependsOn(':b') // possibly not required but worth a mention 
    dependencies { 
     // add the 'foo' configuration to the 'compile' dependencies 
     compile project(path: ':b', configuration: 'foo') 
    } 
} 

project(':b') { 
    configurations { 
     foo 
    } 
    task makeCustomJar(type: Jar) { 
     // configure the jar task 
    } 
    artifacts { 
     // the custom jar is added to the 'foo' configuration 
     foo makeCustomJar 
    } 
} 
+0

我還沒有明確表示,項目應該在自己的gradle文件中。我已經更新了這個問題。 – Sogartar

+0

我可以使用「申請」嗎? – Sogartar

+0

沒關係。如果每個項目都有單獨的gradle文件,那麼只需提取'project(...){...}'塊的主體。我可以使用「申請」這個 - 沒有 –

相關問題