本文整理了Java中org.sonar.api.resources.Project
类的一些代码示例,展示了Project
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Project
类的具体详情如下:
包路径:org.sonar.api.resources.Project
类名称:Project
[英]A class that manipulates Projects in the Sonar way.
[中]以声纳方式操纵项目的类。
代码示例来源:origin: org.codehaus.sonar-plugins.dotnet/sonar-plugin-dotnet-core
/**
* 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();
}
代码示例来源:origin: org.codehaus.sonar/sonar-batch
public String moduleName() {
if (module != null) {
return module.getName();
}
return null;
}
代码示例来源:origin: stackoverflow.com
Collections.sort(list), new Comparator<Project>() {
public int compare(Project p1, Project p2) {
return p1.getKey().compareToIgnoreCase(p2.getKey());
}
});
代码示例来源:origin: org.codehaus.sonar/sonar-plugin-api
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;
}
代码示例来源:origin: org.codehaus.sonar/sonar-plugin-api
@Override
public String toString() {
return new ToStringBuilder(this)
.append("id", getId())
.append("key", getKey())
.append("qualifier", getQualifier())
.toString();
}
代码示例来源:origin: org.codehaus.sonar.plugins/sonar-surefire-plugin
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;
}
代码示例来源: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();
}
}
}
代码示例来源:origin: org.codehaus.sonar-plugins.dotnet/sonar-dotnet-gendarme-plugin
/**
* 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);
}
}
代码示例来源:origin: org.codehaus.sonar.plugins/sonar-surefire-plugin
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;
}
代码示例来源:origin: org.codehaus.sonar-plugins.dotnet.csharp/sonar-csharp-squid-plugin
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);
}
代码示例来源:origin: org.codehaus.sonar-plugins.java/sonar-surefire-plugin
@Override
public boolean shouldExecuteOnProject(Project project) {
return project.getAnalysisType().isDynamic(true)
&& (!project.getFileSystem().mainFiles("java").isEmpty() || !project.getFileSystem().testFiles("java").isEmpty());
}
代码示例来源:origin: org.codehaus.sonar/sonar-batch
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;
}
代码示例来源:origin: org.codehaus.sonar/sonar-batch
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);
代码示例来源:origin: org.codehaus.sonar/sonar-plugin-api
/**
* @return the qualifier of the current object
*/
@Override
public String getQualifier() {
return isRoot() ? Qualifiers.PROJECT : Qualifiers.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
@Override
public boolean shouldExecuteOnProject(Project project) {
return !project.getModules().isEmpty();
}
代码示例来源:origin: org.codehaus.sonar-plugins.dotnet/sonar-dotnet-plugin
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;
}
代码示例来源:origin: org.codehaus.sonar/sonar-batch
public ProjectConfigurator configure(Project project) {
Date analysisDate = loadAnalysisDate();
checkCurrentAnalysisIsTheLatestOne(project.getKey(), analysisDate);
project
.setAnalysisDate(analysisDate)
.setAnalysisVersion(loadAnalysisVersion())
.setAnalysisType(loadAnalysisType());
return this;
}
代码示例来源:origin: org.codehaus.sonar-plugins.dotnet/sonar-dotnet-plugin
/**
* {@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;
}
代码示例来源:origin: org.codehaus.sonar-plugins/sonar-php-plugin
/**
* @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;
}
内容来源于网络,如有侵权,请联系作者删除!