void (CopySpec copySpec, Visitor visitor) { //if (true) return; copySpec.setIncludeEmptyDirs(true); MetaClass copySpecMetaclass = DefaultGroovyMethods.getMetaClass(copySpec); List<MetaMethod> walkMethods = copySpecMetaclass.respondsTo(copySpec, "walk", new Object[]{Action.class}); if (walkMethods.isEmpty()) { return; } walkMethods.get(0).invoke(copySpec, new Object[]{new Action<Object>() { @Override public void execute(Object resolver) { // def resolver -> // in Gradle v1.x - org.gradle.api.internal.file.copy.CopySpecInternal // in Gradle v2.x - org.gradle.api.internal.file.copy.CopySpecResolver MetaClass resolverMetaclass = DefaultGroovyMethods.getMetaClass(resolver); List<MetaMethod> setIncludeEmptyDirs = resolverMetaclass.respondsTo(resolver, "setIncludeEmptyDirs", new Object[]{Boolean.class}); if (!setIncludeEmptyDirs.isEmpty()) { setIncludeEmptyDirs.get(0).invoke(resolver, new Object[]{true}); } if (resolverMetaclass.respondsTo(resolver, "getDestPath").isEmpty() || resolverMetaclass.respondsTo(resolver, "getSource").isEmpty()) { throw new RuntimeException(GradleVersion.current() + " is not supported by JEE artifact importer"); } @SuppressWarnings("SSBasedInspection") Object destPath = resolverMetaclass.respondsTo(resolver, "getDestPath").get(0).invoke(resolver, new Object[0]); final String relativePath = GradleReflectionUtil.reflectiveCall(destPath, "getPathString", String.class); Collection<Object> sourcePaths = getSourcePaths(resolver); if (sourcePaths == null) { Object this0 = resolverMetaclass.getProperty(resolver, "this$0"); sourcePaths = getSourcePaths(this0); } if (sourcePaths != null) { for (Object path : DefaultGroovyMethods.flatten(sourcePaths)) { if (path instanceof String) { visitor.visitSourcePath(relativePath, (String)path); } } } FileTree sourceTree = GradleReflectionUtil.reflectiveCall(resolver, "getSource", FileTree.class); sourceTree.visit(new FileVisitor() { @Override public void visitDir(FileVisitDetails dirDetails) { try { visitor.visitDir(relativePath, dirDetails); } catch (Exception ignore) { } } @Override public void visitFile(FileVisitDetails fileDetails) { try { visitor.visitFile(relativePath, fileDetails); } catch (Exception ignore) { } } }); } }}); }