diff --git a/src/main/java/com/jfrog/ide/idea/scan/ScanUtils.java b/src/main/java/com/jfrog/ide/idea/scan/ScanUtils.java index fab31beb..5022cacb 100644 --- a/src/main/java/com/jfrog/ide/idea/scan/ScanUtils.java +++ b/src/main/java/com/jfrog/ide/idea/scan/ScanUtils.java @@ -6,14 +6,13 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectUtil; import com.intellij.openapi.vfs.VirtualFile; +import com.jfrog.ide.common.utils.Utils; import com.jfrog.ide.idea.log.Logger; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.SystemUtils; import java.io.IOException; import java.nio.file.Path; -import java.util.Collection; -import java.util.Map; import java.util.Set; /** @@ -22,14 +21,12 @@ public class ScanUtils { /** * This method gets a set of modules from IDEA, and searches for projects to be scanned. - * It appends the root path of each module it finds into a set. * - * @param scannersMap - current scanners - * @param project - the project + * @param project - the project * @return local scan paths */ - static Set createScanPaths(Map scannersMap, Project project) { - final Set paths = Sets.newHashSet(); + public static Set createScanPaths(Project project) { + Set paths = Sets.newHashSet(); paths.add(com.jfrog.ide.idea.utils.Utils.getProjectBasePath(project)); for (Module module : ModuleManager.getInstance(project).getModules()) { VirtualFile modulePath = ProjectUtil.guessModuleDir(module); @@ -37,7 +34,7 @@ static Set createScanPaths(Map scannersMap, Project paths.add(modulePath.toNioPath()); } } - scannersMap.values().stream().map(ScannerBase::getProjectPaths).flatMap(Collection::stream).forEach(paths::add); + paths = Utils.consolidatePaths(paths); Logger.getInstance().debug("Scanning projects in the following paths: " + paths); return paths; } diff --git a/src/main/java/com/jfrog/ide/idea/scan/ScannerFactory.java b/src/main/java/com/jfrog/ide/idea/scan/ScannerFactory.java index 63755203..3fa120a1 100644 --- a/src/main/java/com/jfrog/ide/idea/scan/ScannerFactory.java +++ b/src/main/java/com/jfrog/ide/idea/scan/ScannerFactory.java @@ -15,6 +15,7 @@ import java.io.IOException; import java.nio.file.Path; +import java.util.Collection; import java.util.Map; import java.util.Set; import java.util.concurrent.ExecutorService; @@ -45,7 +46,8 @@ public Map refreshScanners(Map oldSc Map scanners = Maps.newHashMap(); refreshMavenScanner(scanners, oldScanners, executor, scanLogic); refreshPypiScanners(scanners, oldScanners, executor, scanLogic); - Set scanPaths = createScanPaths(oldScanners, project); + Set scanPaths = createScanPaths(project); + oldScanners.values().stream().map(ScannerBase::getProjectPaths).flatMap(Collection::stream).forEach(scanPaths::add); refreshGenericScanners(scanners, oldScanners, scanPaths, executor, scanLogic); return scanners; } diff --git a/src/main/java/com/jfrog/ide/idea/scan/data/applications/JFrogApplicationsConfig.java b/src/main/java/com/jfrog/ide/idea/scan/data/applications/JFrogApplicationsConfig.java index 158257da..dde08b0a 100644 --- a/src/main/java/com/jfrog/ide/idea/scan/data/applications/JFrogApplicationsConfig.java +++ b/src/main/java/com/jfrog/ide/idea/scan/data/applications/JFrogApplicationsConfig.java @@ -3,14 +3,16 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.intellij.openapi.project.Project; import com.jfrog.ide.idea.configuration.GlobalSettings; +import com.jfrog.ide.idea.scan.ScanUtils; import lombok.Getter; import lombok.NoArgsConstructor; +import java.nio.file.Path; import java.util.ArrayList; import java.util.List; +import java.util.Set; import static com.jfrog.ide.idea.scan.SourceCodeScannerManager.convertToSkippedFolders; -import static com.jfrog.ide.idea.utils.Utils.getProjectBasePath; @Getter @NoArgsConstructor @@ -22,15 +24,16 @@ public class JFrogApplicationsConfig { public static JFrogApplicationsConfig createApplicationConfigWithDefaultModule(Project project) { JFrogApplicationsConfig applicationsConfig = new JFrogApplicationsConfig(); - - ModuleConfig defualtModuleConfig = new ModuleConfig(); - defualtModuleConfig.setSourceRoot(getProjectBasePath(project).toAbsolutePath().toString()); - defualtModuleConfig.setExcludePatterns(convertToSkippedFolders(GlobalSettings.getInstance().getServerConfig().getExcludedPaths())); - + Set paths = ScanUtils.createScanPaths(project); applicationsConfig.modules = new ArrayList<>(); - applicationsConfig.modules.add(defualtModuleConfig); + + for (Path path : paths) { + ModuleConfig defaultModuleConfig = new ModuleConfig(); + defaultModuleConfig.setSourceRoot(path.toString()); + defaultModuleConfig.setExcludePatterns(convertToSkippedFolders(GlobalSettings.getInstance().getServerConfig().getExcludedPaths())); + applicationsConfig.modules.add(defaultModuleConfig); + } return applicationsConfig; } - }