gradle指定耳内模块的路径

时间:2015-08-17 15:19:12

标签: gradle

Gradle构建脚本创建一个带有一些罐子和一个内部战争的EAR文件。

可以在EAR文件中为项目模块(不是第三方库!)指定非根位置吗?

我的项目布局如下:

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

谢谢!

1 个答案:

答案 0 :(得分:0)

你可以使用into - >从语法。在耳包装的build.gradle中你可以做到这一点 - 我举了一个完整的例子。感兴趣的代码接近底部。

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'
            }
        }
    }
} 
相关问题