diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleAutoImportAware.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleAutoImportAware.java index 6b852a7149a5..c8828b912b23 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleAutoImportAware.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/project/GradleAutoImportAware.java @@ -49,11 +49,11 @@ public class GradleAutoImportAware implements ExternalSystemAutoImportAware { @Nullable @Override public String getAffectedExternalProjectPath(@NotNull String changedFileOrDirPath, @NotNull Project project) { - if (!changedFileOrDirPath.endsWith(GradleConstants.EXTENSION)) { + if (!changedFileOrDirPath.endsWith("." + GradleConstants.EXTENSION)) { return null; } File file = new File(changedFileOrDirPath); - if(file.isDirectory()) { + if (file.isDirectory()) { return null; } diff --git a/plugins/gradle/testSources/org/jetbrains/plugins/gradle/importing/GradleAutoImportAwareTest.java b/plugins/gradle/testSources/org/jetbrains/plugins/gradle/importing/GradleAutoImportAwareTest.java new file mode 100644 index 000000000000..31be5d86989b --- /dev/null +++ b/plugins/gradle/testSources/org/jetbrains/plugins/gradle/importing/GradleAutoImportAwareTest.java @@ -0,0 +1,31 @@ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +package org.jetbrains.plugins.gradle.importing; + +import com.intellij.openapi.module.Module; +import com.intellij.openapi.module.ModuleManager; +import com.intellij.openapi.roots.CompilerModuleExtension; +import com.intellij.openapi.vfs.VfsUtilCore; +import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.plugins.gradle.service.project.GradleAutoImportAware; +import org.junit.Test; + +public class GradleAutoImportAwareTest extends GradleImportingTestCase { + + @Test + public void testDirectoriesNotWatched() throws Exception { + createProjectSubFile("src/main/java/my/pack/gradle/A.java"); + final VirtualFile file = createProjectSubFile("buildScripts/myScript.gradle"); + importProjectUsingSingeModulePerGradleProject("apply plugin: 'java'"); + + assertModules("project"); + + final GradleAutoImportAware gradleAutoImportAware = new GradleAutoImportAware(); + + final Module module = ModuleManager.getInstance(myProject).getModules()[0]; + final CompilerModuleExtension compilerModuleExtension = CompilerModuleExtension.getInstance(module); + final String outputPath = VfsUtilCore.urlToPath(compilerModuleExtension.getCompilerOutputUrl() + "/my/pack/gradle"); + + assertNull(gradleAutoImportAware.getAffectedExternalProjectPath(outputPath, myProject)); + assertNotNull(gradleAutoImportAware.getAffectedExternalProjectPath(file.getPath(), myProject)); + } +}