From 4c107d60d6672d361f2bba8561a6d82d5b3db4ac Mon Sep 17 00:00:00 2001 From: Sheng Chen Date: Mon, 23 Oct 2023 22:59:38 -0700 Subject: [PATCH] fix: Skip android projects from importing (#1439) --- .../importer/GradleBuildServerProjectImporter.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/GradleBuildServerProjectImporter.java b/extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/GradleBuildServerProjectImporter.java index 9d2fd2a21..452bd3c5d 100644 --- a/extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/GradleBuildServerProjectImporter.java +++ b/extension/jdtls.ext/com.microsoft.gradle.bs.importer/src/com/microsoft/gradle/bs/importer/GradleBuildServerProjectImporter.java @@ -3,6 +3,7 @@ import java.io.File; import java.net.URI; import java.util.Arrays; +import java.util.Collection; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -54,6 +55,7 @@ public class GradleBuildServerProjectImporter extends AbstractProjectImporter { public static final String BUILD_GRADLE_KTS_DESCRIPTOR = "build.gradle.kts"; public static final String SETTINGS_GRADLE_DESCRIPTOR = "settings.gradle"; public static final String SETTINGS_GRADLE_KTS_DESCRIPTOR = "settings.gradle.kts"; + public static final String ANDROID_MANIFEST = "AndroidManifest.xml"; @Override public boolean applies(IProgressMonitor monitor) throws OperationCanceledException, CoreException { @@ -76,6 +78,16 @@ public boolean applies(IProgressMonitor monitor) throws OperationCanceledExcepti } for (java.nio.file.Path directory : directories) { + // we don't support android + BasicFileDetector androidDetector = new BasicFileDetector(directory, ANDROID_MANIFEST) + .includeNested(false) + .addExclusions("**/build") //default gradle build dir + .addExclusions("**/bin"); + Collection androidDirectories = androidDetector.scan(monitor); + if (!androidDirectories.isEmpty()) { + return false; + } + IProject project = ProjectUtils.getProjectFromUri(directory.toUri().toString()); // skip this importer if any of the project in workspace is already // imported by other importers.