/** * Gets the report directory for a given project. * * @param pom * the project definition * @return the report directory */ public File getReportsDirectory(Project project) { return project.getFileSystem().getBuildDir(); }
public String moduleName() { if (module != null) { return module.getName(); } return null; }
public Project(String key, String branch, String name) { if (StringUtils.isNotBlank(branch)) { setKey(String.format(BRANCH_KEY_FORMAT, key, branch)); this.name = String.format("%s %s", name, branch); } else { setKey(key); this.name = name; } setEffectiveKey(getKey()); this.branch = branch; }
@Override public String toString() { return new ToStringBuilder(this) .append("id", getId()) .append("key", getKey()) .append("qualifier", getQualifier()) .toString(); }
private static File getReportsDirectoryFromProperty(Project project) { String path = (String) project.getProperty(CoreProperties.SUREFIRE_REPORTS_PATH_PROPERTY); if (path != null) { return project.getFileSystem().resolvePath(path); } return null; }
@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(); } } }
/** * Parses a processed violation file. * * @param file * the file to parse */ public void parse(File file) { this.repositoryKey = vsProject.isTest() ? GendarmeConstants.TEST_REPOSITORY_KEY : GendarmeConstants.REPOSITORY_KEY; if (!"cs".equals(project.getLanguageKey())) { // every repository key should be "fxcop-<language_key>", except for C# for which it is simply "fxcop" (for backward compatibility) repositoryKey += "-" + project.getLanguageKey(); } SMInputFactory inputFactory = StaxParserUtils.initStax(); FileInputStream fileInputStream = null; try { fileInputStream = new FileInputStream(file); SMHierarchicCursor cursor = inputFactory.rootElementCursor(new InputStreamReader(fileInputStream, project.getFileSystem().getSourceCharset())); SMInputCursor rulesCursor = cursor.advance().descendantElementCursor("rule"); parseRuleBlocs(rulesCursor); cursor.getStreamReader().closeCompletely(); } catch (XMLStreamException e) { throw new SonarException("Error while reading Gendarme result file: " + file.getAbsolutePath(), e); } catch (FileNotFoundException e) { throw new SonarException("Cannot find Gendarme result file: " + file.getAbsolutePath(), e); } finally { IOUtils.closeQuietly(fileInputStream); } }
private static File getReportsDirectoryFromPluginConfiguration(Project project) { MavenPlugin plugin = MavenPlugin.getPlugin(project.getPom(), MavenSurefireUtils.GROUP_ID, MavenSurefireUtils.ARTIFACT_ID); if (plugin != null) { String path = plugin.getParameter("reportsDirectory"); if (path != null) { return project.getFileSystem().resolvePath(path); } } return null; }
public CSharpCPDMapping(CSharp csharp, Project project) { super(); this.csharp = csharp; this.charset = project.getFileSystem().getSourceCharset(); ignoreLiterals = project.getConfiguration().getBoolean(CSharpSquidConstants.CPD_IGNORE_LITERALS_PROPERTY, CSharpSquidConstants.CPD_IGNORE_LITERALS_DEFVALUE); }
@Override public boolean shouldExecuteOnProject(Project project) { return project.getAnalysisType().isDynamic(true) && (!project.getFileSystem().mainFiles("java").isEmpty() || !project.getFileSystem().testFiles("java").isEmpty()); }
public IssuesReport buildReport() { Project project = projectTree.getRootProject(); IssuesReport issuesReport = new IssuesReport(); issuesReport.setNoFile(!inputPathCache.allFiles().iterator().hasNext()); issuesReport.setTitle(project.getName()); issuesReport.setDate(project.getAnalysisDate()); processIssues(issuesReport, issueCache.all()); return issuesReport; }
private Snapshot persistProject(Project project, @Nullable Project parent) { ResourceModel model = findOrCreateModel(project, parent); model.setDeprecatedKey(project.getKey()); if (parent != null) { parentSnapshot = resourceCache.get(parent.getEffectiveKey()).snapshot(); model.setRootId((Integer) ObjectUtils.defaultIfNull(parentSnapshot.getRootProjectId(), parentSnapshot.getResourceId())); } else { project.setId(model.getId()); project.setUuid(model.getUuid()); snapshot.setVersion(project.getAnalysisVersion()); snapshot.setCreatedAtMs(dateToLong(project.getAnalysisDate())); snapshot.setBuildDateMs(System.currentTimeMillis()); snapshot = session.save(snapshot);
/** * @return the qualifier of the current object */ @Override public String getQualifier() { return isRoot() ? Qualifiers.PROJECT : Qualifiers.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); } }
@Override public boolean shouldExecuteOnProject(Project project) { return !project.getModules().isEmpty(); }
public VisualStudioProject getProjectFromSonarProject(Project sonarProject) { String currentProjectName = sonarProject.getName(); String branch = sonarProject.getBranch(); for (VisualStudioProject project : projects) { final String vsProjectName; if (StringUtils.isEmpty(branch)) { vsProjectName = project.getName(); } else { vsProjectName = project.getName() + " " + branch; } if (currentProjectName.equals(vsProjectName)) { return project; } } return null; }
public ProjectConfigurator configure(Project project) { Date analysisDate = loadAnalysisDate(); checkCurrentAnalysisIsTheLatestOne(project.getKey(), analysisDate); project .setAnalysisDate(analysisDate) .setAnalysisVersion(loadAnalysisVersion()) .setAnalysisType(loadAnalysisType()); return this; }
/** * {@inheritDoc} */ public boolean shouldExecuteOnProject(Project project) { if (project.isRoot() || !isLanguageSupported(project.getLanguageKey())) { return false; } boolean skipMode = MODE_SKIP.equalsIgnoreCase(getExecutionMode()); if (skipMode) { LOG.info("{} plugin won't execute as it is set to 'skip' mode.", getToolName()); return false; } return true; }
/** * @see org.sonar.plugins.php.core.PhpPluginAbstractExecutor#getCommandLine() */ @Override protected List<String> getCommandLine() { List<String> result = new ArrayList<String>(); result.add(configuration.getOsDependentToolScriptName()); Configuration c = configuration.getProject().getConfiguration(); addBasicOptions(result); boolean useMaintTestClass = true; if (configuration.isStringPropertySet(PHPUNIT_CONFIGURATION_PROPERTY_KEY)) { result.add(PHPUNIT_CONFIGURATION_OPTION + configuration.getConfiguration()); useMaintTestClass = false; } addExtendedOptions(result, c); if (useMaintTestClass && configuration.isStringPropertySet(PHPUNIT_MAIN_TEST_FILE_PROPERTY_KEY)) { result.add(project.getName()); result.add(configuration.getMainTestClass()); } // source directory is appended phpunit. if ( !useMaintTestClass || !c.containsKey(PHPUNIT_ANALYZE_TEST_DIRECTORY_KEY) || c.getBoolean(PHPUNIT_ANALYZE_TEST_DIRECTORY_KEY)) { result.add(getTestDirectoryOrFiles()); } return result; }