@Override protected void doAfterStart() { DefaultAnalysisMode analysisMode = getComponentByType(DefaultAnalysisMode.class); analysisMode.printMode(); LOG.debug("Start recursive analysis of project modules"); DefaultProjectTree tree = getComponentByType(DefaultProjectTree.class); scanRecursively(tree.getRootProject()); if (analysisMode.isMediumTest()) { getComponentByType(ScanTaskObservers.class).notifyEndOfScanTask(); } }
private void addModule(Project parent, Project module) { ProjectDefinition parentDefinition = projectTree.getProjectDefinition(parent); java.io.File parentBaseDir = parentDefinition.getBaseDir(); ProjectDefinition moduleDefinition = projectTree.getProjectDefinition(module); java.io.File moduleBaseDir = moduleDefinition.getBaseDir(); module.setPath(new PathResolver().relativePath(parentBaseDir, moduleBaseDir)); addResource(module); for (Project submodule : module.getModules()) { addModule(module, submodule); } }
@Override public String getSource(Resource reference) { Resource resource = getResource(reference); if (resource instanceof File) { File file = (File) resource; Project module = currentProject; ProjectDefinition def = projectTree.getProjectDefinition(module); try { return FileUtils.readFileToString(new java.io.File(def.getBaseDir(), file.getPath())); } catch (IOException e) { throw new IllegalStateException("Unable to read file content " + reference, e); } } return null; }
private Bucket getBucket(@Nullable Resource reference) { if (reference == null) { return null; } if (StringUtils.isNotBlank(reference.getKey())) { return buckets.get(reference); } String relativePathFromSourceDir = null; boolean isTest = false; boolean isDir = false; if (reference instanceof File) { File referenceFile = (File) reference; isTest = Qualifiers.UNIT_TEST_FILE.equals(referenceFile.getQualifier()); relativePathFromSourceDir = referenceFile.relativePathFromSourceDir(); } else if (reference instanceof Directory) { isDir = true; Directory referenceDir = (Directory) reference; relativePathFromSourceDir = referenceDir.relativePathFromSourceDir(); if (Directory.ROOT.equals(relativePathFromSourceDir)) { relativePathFromSourceDir = ""; } } if (relativePathFromSourceDir != null) { // Resolve using deprecated key List<String> dirs; ProjectDefinition projectDef = projectTree.getProjectDefinition(getProject()); if (isTest) { dirs = projectDef.getTestDirs(); } else { dirs = projectDef.getSourceDirs(); } for (String src : dirs) { java.io.File dirOrFile = pathResolver.relativeFile(projectDef.getBaseDir(), src); java.io.File abs = new java.io.File(dirOrFile, relativePathFromSourceDir); Bucket b = getBucket( isDir ? Directory.fromIOFile(abs, getProject()) : File.fromIOFile(abs, getProject())); if (b != null) { return b; } } } return null; }
public void start() { Project rootProject = projectTree.getRootProject(); if (StringUtils.isNotBlank(rootProject.getKey())) { doStart(rootProject); } }