2017-07-14 5 views
1

Gradle war:正規表現ではファイル名を変更できません。gradle war rename file通常のEXPが動作しない

foo/bar/config/*.xml -> foo/config/*.xml 

エントリー・パスの名前を変更しようとすると

war { 
    into "foo" 

    from ("hello/world") { 
     include "bar/config/*.xml" 
     // remove bar/ in the path 
     rename '(.*)/bar/config/(.*)', '$1/config/$2' 

     // tried 
     // rename 'bar/config/(.*)', 'config/$1' 

    } 


} 

戦争の内部で変更されませんでした。

答えて

0

renameはファイルでフルパスではなく動作しています。パスを変更するには、FileCopyDetailsオブジェクトにアクセスする必要があります。これを行う方法の1つは、filesMatching()

war { 
    from('hello/world') { 
     includeEmptyDirs = false 
     include 'bar/config/*.xml' 
     filesMatching('**/*.xml') { 
      it.path = it.path.replace('bar/', '') 
     } 
    } 
} 
です。
関連する問題