2015-08-17 67 views
0

Gradle構建腳本創建一個EAR文件,其中包含一些JAR和一個內部戰爭。gradle指定耳朵內模塊的路徑

是否可以在EAR文件內爲項目模塊(不是第三方庫)指定一個非根位置?

我的項目佈局看起來如下:

./ear_project   ear/ 
./jar_project_1 ==>  +-jars_direct/ 
./jar_project_2   |   +-jar1 
./war_project    |   +-jar2 
          | 
          \-war_direct/ 
             +-war 

謝謝!

回答

0

您可以使用into - > from語法。在耳塞包裝內建立一個梯子,你可以做到這一點 - 我提供了一個完整的例子。感興趣的代碼接近底部。

apply plugin: 'ear' 
dependencies { 
    //this works great - war is in the ear. 
    deploy project(path: ':web', configuration: 'archives') 

    /* 
    The following dependencies will become ear libs and will 
    be placed in a dir configured via the libDirName property. 
    this works great as well. 
    */ 
    earlib group: 'log4j', name: 'log4j', version: '1.2.15', ext: 'jar' 
} 
ear { 
    // put dependent libraries into lib inside the generated EAR 
    libDirName 'lib' 
    deploymentDescriptor { 
     // JavaEE version (e.g. JavaEE 5 xsd) 
     version = "5" 
     //in app.ear/META-INF/application.xml<display-name>" 
     displayName = "My Application ear display display name"" 

     //the xml entry in application.xml - doesn't make the jar itself part of the ear 
     module("ejbs.jar", "ejb") 

     //use into to define a folder within the ear and put stuff in it 
     into ('jars_direct'){ 
      from('jar_project_1'){ 
       include 'jar1.jar' 
      } 
      from('jar_project_2'){ 
       include 'jar2.jar' 
      } 
     } 
    } 
}