2015-10-26 102 views
1

我們在不同的項目中有多個war文件,分別稱爲A和B,共享像圖像這樣的公共資源。公共資源放置在單獨項目E中的戰爭模塊中。並且此戰爭文件作爲依賴項添加到項目A和B中的所有戰爭模塊中。目前,我們使用maven資源插件將這些公共資源複製到A和B模塊。從Gradle中的依賴jar或war文件複製資源

我們如何使用Gradle做同樣的動作? 我正在嘗試使用下面的配置,但不會將文件複製到生成的war文件中。它們只被複製到build/libs文件夾。

 
    configurations { 
     commonWebResources 
    } 
    task extractApi(type: Copy) { 
     print 'File : ' + configurations.commonWebResources.singleFile 
     from zipTree(configurations.commonWebResources.singleFile) 
     into file("${project.buildDir}/libs/") 
    } 

    compileJava.dependsOn(extractApi) 

回答

2

當我有這樣我想要一個生成任務生成圖像的公共資源,我做了以下內容:

sourceSets { 
    main { 
     resources.srcDirs += "src-gen/main/resources" 
    } 
} 
// (include your configurations block and extractApi task here) 
processResources.dependsOn extractApi 
task cleanGen << { 
    file('src-gen/main/resources').delete() 
} 
clean.dependsOn cleanGen 
相關問題