Reader (ResourceRootFilter filter, Reader original) { if ("RenamingCopyFilter".equals(filter.filterType)) { final Matcher matcher = (Matcher)filter.getProperties().get("matcher"); final String replacement = (String)filter.getProperties().get("replacement"); if (matcher == null || replacement == null) return original; matcher.reset(myOutputFileRef.get().getName()); if (matcher.find()) { final String newFileName = matcher.replaceFirst(replacement); myOutputFileRef.set(new File(myOutputFileRef.get().getParentFile(), newFileName)); } return original; } try { Class<?> clazz = Class.forName(filter.filterType); if (!FilterReader.class.isAssignableFrom(clazz)) { myContext.processMessage( new CompilerMessage( GradleJpsBundle.message("gradle.resources.compiler"), BuildMessage.Kind.WARNING, GradleJpsBundle.message("error.invalid.filter.should.extend", filter.filterType), null) ); } Constructor constructor = clazz.getConstructor(Reader.class); FilterReader result = (FilterReader)constructor.newInstance(original); final Map<Object, Object> properties = filter.getProperties(); if (!properties.isEmpty()) { if (ExpandProperties.class.getName().equals(filter.filterType)) { final Map<Object, Object> antProps = new HashMap<>(properties); final Project project = new Project(); for (Map.Entry<Object, Object> entry : antProps.entrySet()) { project.setProperty(entry.getKey().toString(), entry.getValue().toString()); } properties.clear(); properties.put("project", project); } ConfigureUtil.configureByMap(properties, result); } return result; } catch (Throwable th) { myContext.processMessage(new CompilerMessage( GradleJpsBundle.message("gradle.resources.compiler"), BuildMessage.Kind.WARNING, GradleJpsBundle.message("error.failed.to.apply.filter", filter.filterType, th.getMessage()), null) ); } return original; }