@Override public boolean shouldExecuteOnProject(Project project) { return !project.getModules().isEmpty(); }
@Override public boolean shouldExecuteOnProject(Project project) { // Should be only executed on leaf modules return project.getModules().isEmpty() // Useless in issues mode && !analysisMode.isIssues(); }
@Override public boolean shouldExecuteOnProject(Project project) { // Should be only executed on leaf modules return project.getModules().isEmpty() // Useless in preview mode && !analysisMode.isPreview(); }
@Override protected void init() { if (!initialized) { initialized = true; validateLibraries = project.getModules().isEmpty(); binaries = getFilesFromProperty(JavaClasspathProperties.SONAR_JAVA_TEST_BINARIES); List<File> libraries = getFilesFromProperty(JavaClasspathProperties.SONAR_JAVA_TEST_LIBRARIES); elements = Lists.newArrayList(binaries); elements.addAll(libraries); } }
@Override protected boolean shouldDecorateResource(Resource resource, DecoratorContext context) { // Should not execute on views return (ResourceUtils.isRootProject(resource) || ResourceUtils.isModuleProject(resource)) // Only on leaf projects && ((Project) resource).getModules().isEmpty(); } }
@Override protected boolean shouldDecorateResource(Resource resource, DecoratorContext context) { // Should not execute on views return (ResourceUtils.isRootProject(resource) || ResourceUtils.isModuleProject(resource)) && !((Project) resource).getModules().isEmpty(); } }
private void scanRecursively(Project module) { for (Project subModules : module.getModules()) { scanRecursively(subModules); } scan(module); }
private void scanRecursively(Project module) { for (Project subModules : module.getModules()) { scanRecursively(subModules); } scan(module); }
public void collect(Project project, SensorContext context, File reportsDir) { File[] xmlFiles = getReports(reportsDir); if (xmlFiles.length == 0) { // See http://jira.codehaus.org/browse/SONAR-2371 if (project.getModules().isEmpty()) { context.saveMeasure(CoreMetrics.TESTS, 0.0); } } else { parseFiles(context, xmlFiles); } }
private void addSubProjects(Project project, List<Resource> subProjects) { for (Project subProject : project.getModules()) { Project indexedSubProject = getIndex().getResource(subProject); if (indexedSubProject != null) { subProjects.add(indexedSubProject); } addSubProjects(subProject, subProjects); } }
@Override protected void init() { if (!initialized) { TimeProfiler profiler = new TimeProfiler(getClass()).start("JavaTestClasspath initialization"); initialized = true; validateLibraries = project.getModules().isEmpty(); binaries = getFilesFromProperty(JavaClasspathProperties.SONAR_JAVA_TEST_BINARIES); List<File> libraries = getFilesFromProperty(JavaClasspathProperties.SONAR_JAVA_TEST_LIBRARIES); if(libraries.isEmpty()) { LOG.warn("Bytecode of dependencies was not provided for analysis of test files, you might end up with less precise results. " + "Bytecode can be provided using sonar.java.test.libraries property"); } elements = Lists.newArrayList(binaries); elements.addAll(libraries); profiler.stop(); } }
@Override protected void init() { if (!initialized) { initialized = true; validateLibraries = project.getModules().isEmpty(); binaries = getFilesFromProperty(JavaClasspathProperties.SONAR_JAVA_BINARIES); List<File> libraries = getFilesFromProperty(JavaClasspathProperties.SONAR_JAVA_LIBRARIES); boolean useDeprecatedProperties = binaries.isEmpty() && libraries.isEmpty(); if (useDeprecatedProperties) { binaries = getFilesFromProperty("sonar.binaries"); libraries = getFilesFromProperty("sonar.libraries"); } if (pom != null && libraries.isEmpty()) { //check mojo elements = getLibrariesFromMaven(pom); } else { elements = Lists.newArrayList(binaries); elements.addAll(libraries); if (useDeprecatedProperties && !elements.isEmpty()) { LOG.warn("sonar.binaries and sonar.libraries are deprecated since version 2.5 of sonar-java-plugin, please use sonar.java.binaries and sonar.java.libraries instead"); } } } }
@Override protected void init() { if (!initialized) { TimeProfiler profiler = new TimeProfiler(getClass()).start("JavaClasspath initialization"); initialized = true; validateLibraries = project.getModules().isEmpty(); binaries = getFilesFromProperty(JavaClasspathProperties.SONAR_JAVA_BINARIES); List<File> libraries = getFilesFromProperty(JavaClasspathProperties.SONAR_JAVA_LIBRARIES); boolean useDeprecatedProperties = binaries.isEmpty() && libraries.isEmpty(); if (useDeprecatedProperties) { binaries = getFilesFromProperty("sonar.binaries"); libraries = getFilesFromProperty("sonar.libraries"); } elements = Lists.newArrayList(binaries); if(libraries.isEmpty()) { LOG.warn("Bytecode of dependencies was not provided for analysis of source files, " + "you might end up with less precise results. Bytecode can be provided using sonar.java.libraries property"); } elements.addAll(libraries); if (useDeprecatedProperties && !elements.isEmpty()) { LOG.warn("sonar.binaries and sonar.libraries are deprecated since version 2.5 of sonar-java-plugin, please use sonar.java.binaries and sonar.java.libraries instead"); } profiler.stop(); } }
void doStart(Project rootProject) { Bucket bucket = new Bucket(rootProject); addBucket(rootProject, bucket); if (migration != null) { migration.checkIfMigrationNeeded(rootProject); } resourceCache.add(rootProject, null); currentProject = rootProject; for (Project module : rootProject.getModules()) { addModule(rootProject, module); } }
void doStart(Project rootProject) { Bucket bucket = new Bucket(rootProject); addBucket(rootProject, bucket); BatchComponent component = componentCache.add(rootProject, null); component.setInputComponent(new DefaultInputModule(rootProject.getEffectiveKey())); currentProject = rootProject; for (Project module : rootProject.getModules()) { addModule(rootProject, module); } }
private static void writeJsonModuleComponents(JsonWriter json, Project module) { json .beginObject() .prop("key", module.getEffectiveKey()) .prop("path", module.getPath()) .endObject(); for (Project subModule : module.getModules()) { writeJsonModuleComponents(json, subModule); } }
private void writeJsonModuleComponents(JsonWriter json, Project module) { json .beginObject() .prop("key", module.getEffectiveKey()) .prop("path", module.getPath()) .endObject(); for (Project subModule : module.getModules()) { writeJsonModuleComponents(json, subModule); } }
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); } }
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 void onProjectAnalysis(ProjectAnalysisEvent event) { Project module = event.getProject(); if (event.isStart()) { decoratorsProfiler = new DecoratorsProfiler(); currentModuleProfiling = new ModuleProfiling(module, system); } else { currentModuleProfiling.stop(); modulesProfilings.put(module, currentModuleProfiling); long moduleTotalTime = currentModuleProfiling.totalTime(); println(""); println(" -------- Profiling of module " + module.getName() + ": " + TimeUtils.formatDuration(moduleTotalTime) + " --------"); println(""); Properties props = new Properties(); currentModuleProfiling.dump(props); println(""); println(" -------- End of profiling of module " + module.getName() + " --------"); println(""); String fileName = module.getKey() + "-profiler.properties"; dumpToFile(props, BatchUtils.cleanKeyForFilename(fileName)); totalProfiling.merge(currentModuleProfiling); if (module.isRoot() && !module.getModules().isEmpty()) { dumpTotalExecutionSummary(); } } }