watch for ".gradle" scripts, not "gradle" dirs IDEA-193631

This commit is contained in:
Nikita Skvortsov
2018-06-09 12:30:30 +03:00
parent cda259d255
commit 87586fb054
2 changed files with 33 additions and 2 deletions
@@ -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;
}
@@ -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));
}
}