use new FileFilters.withExtension method
authornik <Nikolay.Chashnikov@jetbrains.com>
Thu, 25 Jun 2015 08:58:20 +0000 (11:58 +0300)
committernik <Nikolay.Chashnikov@jetbrains.com>
Thu, 25 Jun 2015 08:58:20 +0000 (11:58 +0300)
plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/BaseGradleProjectResolverExtension.java

index 6877b707a03d4b7703b0c282838cceecd05ad542..96856036578a2379bc0585225d7c6a7e5084a791 100644 (file)
@@ -33,6 +33,7 @@ import com.intellij.openapi.module.ModuleType;
 import com.intellij.openapi.module.StdModuleTypes;
 import com.intellij.openapi.roots.DependencyScope;
 import com.intellij.openapi.util.KeyValue;
+import com.intellij.openapi.util.io.FileFilters;
 import com.intellij.openapi.util.io.FileUtil;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.pom.java.LanguageLevel;
@@ -66,7 +67,6 @@ import org.jetbrains.plugins.gradle.util.GradleUtil;
 import org.slf4j.impl.Log4jLoggerFactory;
 
 import java.io.File;
-import java.io.FilenameFilter;
 import java.io.IOException;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
@@ -469,18 +469,13 @@ public class BaseGradleProjectResolverExtension implements GradleProjectResolver
       throw new ExecutionException("Can't find gradle libraries");
     }
     File gradleJarsDir = new File(toolingApiPath).getParentFile();
-    String[] gradleJars = gradleJarsDir.list(new FilenameFilter() {
-      @Override
-      public boolean accept(@NotNull File dir, @NotNull String name) {
-        return name.endsWith(".jar");
-      }
-    });
+    File[] gradleJars = gradleJarsDir.listFiles(FileFilters.filesWithExtension("jar"));
     if (gradleJars == null) {
       LOG.warn(GradleBundle.message("gradle.generic.text.error.jar.not.found"));
       throw new ExecutionException("Can't find gradle libraries at " + gradleJarsDir.getAbsolutePath());
     }
-    for (String jar : gradleJars) {
-      classPath.add(new File(gradleJarsDir, jar).getAbsolutePath());
+    for (File jar : gradleJars) {
+      classPath.add(jar.getAbsolutePath());
     }
 
     List<String> additionalEntries = ContainerUtilRt.newArrayList();