org.sonar.api.resources.Project.getModules()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(106)

本文整理了Java中org.sonar.api.resources.Project.getModules()方法的一些代码示例,展示了Project.getModules()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Project.getModules()方法的具体详情如下:
包路径:org.sonar.api.resources.Project
类名称:Project
方法名:getModules

Project.getModules介绍

暂无

代码示例

代码示例来源:origin: org.codehaus.sonar/sonar-batch

@Override
public boolean shouldExecuteOnProject(Project project) {
 return !project.getModules().isEmpty();
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-batch

@Override
public boolean shouldExecuteOnProject(Project project) {
 // Should be only executed on leaf modules
 return project.getModules().isEmpty()
  // Useless in issues mode
  && !analysisMode.isIssues();
}

代码示例来源:origin: org.codehaus.sonar/sonar-batch

@Override
public boolean shouldExecuteOnProject(Project project) {
 // Should be only executed on leaf modules
 return project.getModules().isEmpty()
  // Useless in preview mode
  && !analysisMode.isPreview();
}

代码示例来源:origin: org.codehaus.sonar-plugins.java/java-squid

@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);
 }
}

代码示例来源:origin: org.codehaus.sonar/sonar-batch

@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();
 }
}

代码示例来源:origin: org.codehaus.sonar/sonar-batch

@Override
 protected boolean shouldDecorateResource(Resource resource, DecoratorContext context) {
  // Should not execute on views
  return (ResourceUtils.isRootProject(resource) || ResourceUtils.isModuleProject(resource))
   && !((Project) resource).getModules().isEmpty();
 }
}

代码示例来源:origin: org.codehaus.sonar/sonar-batch

private void scanRecursively(Project module) {
 for (Project subModules : module.getModules()) {
  scanRecursively(subModules);
 }
 scan(module);
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-batch

private void scanRecursively(Project module) {
 for (Project subModules : module.getModules()) {
  scanRecursively(subModules);
 }
 scan(module);
}

代码示例来源:origin: org.codehaus.sonar.plugins/sonar-surefire-plugin

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);
 }
}

代码示例来源:origin: org.codehaus.sonar/sonar-batch

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);
 }
}

代码示例来源:origin: org.sonarsource.java/java-squid

@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();
 }
}

代码示例来源:origin: org.codehaus.sonar-plugins.java/java-squid

@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");
   }
  }
 }
}

代码示例来源:origin: org.sonarsource.java/java-squid

@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();
 }
}

代码示例来源:origin: org.codehaus.sonar/sonar-batch

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);
 }
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-batch

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);
 }
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-batch

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);
 }
}

代码示例来源:origin: org.codehaus.sonar/sonar-batch

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);
 }
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-batch

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);
 }
}

代码示例来源:origin: org.codehaus.sonar/sonar-batch

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);
 }
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-batch

@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();
  }
 }
}

相关文章