IDEA-157986 Gradle: filtering in processResources using org.apache.tools.ant.filters.EscapeUnicode filter not working

This commit is contained in:
Vladislav.Soroka
2016-06-29 15:58:55 +03:00
parent afce3735a4
commit 72afe354f3
2 changed files with 31 additions and 10 deletions
@@ -215,6 +215,24 @@ public class GradleResourceFilteringTest extends GradleCompilingTestCase {
assertCopied("build/resources/main/dir/file.txt", "some text myPropValue another text");
}
@Test
public void testEscapeUnicodeFilter() throws Exception {
createProjectSubFile(
"src/main/resources/dir/file.txt", "some text テキスト");
importProject(
"apply plugin: 'java'\n" +
"\n" +
"import org.apache.tools.ant.filters.*\n" +
"processResources {\n" +
" filter (EscapeUnicode)\n" +
"}"
);
assertModules("project", "project_main", "project_test");
compileModules("project_main");
assertCopied("build/resources/main/dir/file.txt", "some text \\u30c6\\u30ad\\u30b9\\u30c8");
}
@Test
public void testFiltersChain() throws Exception {
createProjectSubFile(
@@ -463,23 +463,26 @@ class ExternalProjectBuilderImpl implements ModelBuilderService {
if(copyActions) {
copyActions.each { Action<? super FileCopyDetails> action ->
if (action.hasProperty('val$filterType') && action.hasProperty('val$properties')) {
if (action.hasProperty('val$filterType')) {
//noinspection GrUnresolvedAccess
def filterType = (action?.val$filterType as Class).name
def filter = [filterType: filterType] as DefaultExternalFilter
//noinspection GrUnresolvedAccess
def props = action?.val$properties
if (props) {
if ('org.apache.tools.ant.filters.ExpandProperties'.equals(filterType) && props['project']) {
if (props['project']) filter.propertiesAsJsonMap = new GsonBuilder().create().toJson(props['project'].properties);
}
else {
filter.propertiesAsJsonMap = new GsonBuilder().create().toJson(props);
if(action.hasProperty('val$properties')) {
//noinspection GrUnresolvedAccess
def props = action?.val$properties
if (props) {
if ('org.apache.tools.ant.filters.ExpandProperties' == filterType && props['project']) {
if (props['project']) filter.propertiesAsJsonMap = new GsonBuilder().create().toJson(props['project'].properties);
}
else {
filter.propertiesAsJsonMap = new GsonBuilder().create().toJson(props);
}
}
}
filterReaders << filter
}
else if (action.class.simpleName.equals('RenamingCopyAction') && action.hasProperty('transformer')) {
else if (action.class.simpleName == 'RenamingCopyAction' && action.hasProperty('transformer')) {
//noinspection GrUnresolvedAccess
if (action.transformer.hasProperty('matcher') && action?.transformer?.hasProperty('replacement')) {
//noinspection GrUnresolvedAccess