使用Gradle将文件夹复制到耳朵的根部

时间:2017-08-16 10:50:14

标签: gradle build.gradle

我希望将文件夹移动到我生成的耳朵的根部。

我的子项目中的build.gradle如下所示:

apply plugin: 'ear'

dependencies {
    deploy project(path: ':UiWeb', configuration:'archives')
    deploy project(path: ':ProviderWeb', configuration:'archives')
    deploy project(path: ':Business', configuration: 'archives')
    deploy project(path: ':Common', configuration: 'archives')
    deploy project(path: ':Domain', configuration: 'archives')
    deploy project(path: ':Translator', configuration: 'archives')
    deploy project(path: ':Properties', configuration: 'archives')


    earlib fileTree(dir: 'sharedLib', include: '*.jar')
    earlib fileTree(dir: 'lib', include: '*.jar')
}


ear {

    from("EAR/resources/properties/${environment}") {
        include "*.*"
        into "properties"
    }

    classifier environment()
    libDirName 'lib'

    deploymentDescriptor {
        applicationName = "app"
        displayName = 'EAR'
        description = 'app'
        version = '6'

        metaInf {
            from './META-INF'
            exclude 'application.xml'

        }

        webModule("UiWeb.war", "UiWeb")

        securityRole 'AllUsers'
    }

    manifest {
        attributes("Implementation-Title": "App",
               "Implementation-Version": "TEST",
               "Implementation-Vendor": "Company",
               "Build-By": "gradle",
               "Build-Date": new Date().toString());
  }

}

我的麻烦是from("EAR/resources/properties/${environment}"),因为它实际上并没有将文件夹复制到耳中!我在任何级别的控制台输出中都没有出现任何错误。

使用-Penvironment = xxx将${environment}传递给Gradle,我知道这是有效的,因为该值会附加到耳朵名称。

拜托,有人可以帮我吗?

1 个答案:

答案 0 :(得分:0)

如果您通过属性传递environment的值,那么您应该使用project.getProperties().get("environment")

试试这个:

from("EAR/resources/properties/${project.getProperties().get("environment")}") {
    include "*.*"
    into "properties"
}

不要忘记在项目environment=

中加入gradle.properties