2017-08-16 53 views
0

我期待將文件夾移動到我生成的耳朵的根部。使用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}"),因爲它實際上並沒有複製該文件夾到耳朵!我不會在任何級別的控制檯輸出中遇到任何錯誤。

${environment}使用-Penvironment = xxx傳入Gradle,我知道這是有效的,因爲這個值會附加到耳朵名稱上。

請有人可以幫助我嗎?

回答

0

如果通過屬性environment傳遞價值,那麼就應該用project.getProperties().get("environment")

嘗試用得到它這樣的:

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

不要忘了包括environment=項目gradle.properties