From 6e1995b2ae4a6890cfdf7d71626469380e050273 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Tue, 2 Oct 2012 10:07:46 +0200 Subject: [PATCH] Fix compatibility with FileFilter extensions --- .../sonar/batch/bootstrap/ProjectInitializer.java | 12 +----------- .../api/resources/DefaultProjectFileSystem.java | 3 +++ .../api/resources/DefaultProjectFileSystemTest.java | 4 ++-- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectInitializer.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectInitializer.java index f6ee4c48af9..f20751864cb 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectInitializer.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectInitializer.java @@ -34,19 +34,16 @@ public class ProjectInitializer implements BatchComponent { private ResourceDao resourceDao; private DryRun dryRun; - private ProjectFileSystem fileSystem; private Languages languages; - public ProjectInitializer(ResourceDao resourceDao, DryRun dryRun, ProjectFileSystem fileSystem, Languages languages) { + public ProjectInitializer(ResourceDao resourceDao, DryRun dryRun, Languages languages) { this.resourceDao = resourceDao; this.dryRun = dryRun; - this.fileSystem = fileSystem; this.languages = languages; } public void execute(Project project, ProjectSettings settings) { initLanguage(project, settings); - initFileSystem(project); } private void initLanguage(Project project, ProjectSettings settings) { @@ -63,11 +60,4 @@ public class ProjectInitializer implements BatchComponent { } } - - private void initFileSystem(Project project) { - // TODO See http://jira.codehaus.org/browse/SONAR-2126 - // previously MavenProjectBuilder was responsible for creation of ProjectFileSystem - project.setFileSystem(fileSystem); - - } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/DefaultProjectFileSystem.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/DefaultProjectFileSystem.java index 7afea1cad57..c7be30c73da 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/DefaultProjectFileSystem.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/DefaultProjectFileSystem.java @@ -64,6 +64,9 @@ public class DefaultProjectFileSystem implements ProjectFileSystem { public DefaultProjectFileSystem(Project project, Languages languages) { this.project = project; this.languages = languages; + // TODO See http://jira.codehaus.org/browse/SONAR-2126 + // previously MavenProjectBuilder was responsible for creation of ProjectFileSystem + project.setFileSystem(this); } public DefaultProjectFileSystem(Project project, Languages languages, FileFilter... fileFilters) { diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/resources/DefaultProjectFileSystemTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/resources/DefaultProjectFileSystemTest.java index fd8f9304d53..4d083fd21da 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/resources/DefaultProjectFileSystemTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/resources/DefaultProjectFileSystemTest.java @@ -177,7 +177,7 @@ public class DefaultProjectFileSystemTest { public void resolvePathShouldReturnCanonicalFile() { MavenProject pom = mock(MavenProject.class); when(pom.getBasedir()).thenReturn(new File("/project")); - Project project = new Project("").setPom(pom); + Project project = new Project("foo").setPom(pom); DefaultProjectFileSystem fs = new DefaultProjectFileSystem(project, null); assertThat(fs.resolvePath(".").getAbsolutePath(), endsWith("project")); @@ -236,7 +236,7 @@ public class DefaultProjectFileSystemTest { public void shouldExcludeDirectoriesStartingWithDot() { List dirs = Arrays.asList(new File("test-resources/org/sonar/api/resources/DefaultProjectFileSystemTest/shouldExcludeDirectoriesStartingWithDot/src")); - List files = new DefaultProjectFileSystem(null, null).getFiles(dirs, Collections.emptyList(), false); + List files = new DefaultProjectFileSystem(new Project("foo"), null).getFiles(dirs, Collections.emptyList(), false); assertThat(files.size(), is(1)); assertThat(files.get(0).getRelativePath(), is("org/sonar/Included.java")); } -- 2.39.5