本文整理了Java中org.sonar.api.resources.Project.getKey()
方法的一些代码示例,展示了Project.getKey()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Project.getKey()
方法的具体详情如下:
包路径:org.sonar.api.resources.Project
类名称:Project
方法名:getKey
暂无
代码示例来源: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
@Override
public String key() {
return getKey();
}
代码示例来源:origin: org.codehaus.sonar/sonar-batch
private String getSemaphoreKey() {
return "batch-" + getProject().getKey();
}
代码示例来源: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.sonarsource.sonarqube/sonar-batch
public void start() {
Project rootProject = projectTree.getRootProject();
if (StringUtils.isNotBlank(rootProject.getKey())) {
doStart(rootProject);
}
}
代码示例来源: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-batch
public void start() {
Project rootProject = projectTree.getRootProject();
if (StringUtils.isNotBlank(rootProject.getKey())) {
doStart(rootProject);
}
}
代码示例来源:origin: org.codehaus.sonar/sonar-batch
@VisibleForTesting
void logSuccess(Logger logger) {
if (analysisMode.isPreview() || analysisMode.isMediumTest()) {
logger.info("ANALYSIS SUCCESSFUL");
} else {
String baseUrl = settings.getString(CoreProperties.SERVER_BASE_URL);
if (baseUrl.equals(settings.getDefaultValue(CoreProperties.SERVER_BASE_URL))) {
// If server base URL was not configured in Sonar server then is is better to take URL configured on batch side
baseUrl = serverClient.getURL();
}
if (!baseUrl.endsWith("/")) {
baseUrl += "/";
}
String url = baseUrl + "dashboard/index/" + project.getKey();
logger.info("ANALYSIS SUCCESSFUL, you can browse {}", url);
logger.info("Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report.");
}
}
}
代码示例来源:origin: fr.sii.sonar/sonar-report-core
/**
* Generate a resource key for the provided file path.
*
* Using a plugin with some version and Sonar with another version will
* result in a null key provided by a {@link File} instance. So we generate
* it using the current project key and the relative path to the project.
*
* @param project
* the project that contains the file
* @param path
* the absolute path to the file
* @param possibleParents
* a list of directories to search file into ordered by priority
* @return the resource key usable by Sonar
* @throws KeyException
* when the key couldn't be generated
*/
public static String getKey(Project project, String path, List<java.io.File> possibleParents) throws KeyException {
try {
return project.getKey() + ":" + FileUtil.getRelativePath(path, possibleParents);
} catch(IOException e) {
throw new KeyException("failed to generate key for file "+path, e);
}
}
代码示例来源:origin: org.codehaus.sonar/sonar-batch
public void start() {
if (!analysisMode.isPreview() && StringUtils.isNotBlank(getProject().getKey())) {
Semaphores.Semaphore semaphore = acquire();
if (!semaphore.isLocked()) {
LOG.error(getErrorMessage(semaphore));
throw new SonarException("The project is already being analysed.");
}
}
}
代码示例来源:origin: org.codehaus.sonar/sonar-batch
void migrateIfNeeded(Project module, Iterable<InputFile> inputFiles, DefaultModuleFileSystem fs) {
logger.info("Update component keys");
Map<String, InputFile> deprecatedFileKeyMapper = new HashMap<String, InputFile>();
Map<String, InputFile> deprecatedTestKeyMapper = new HashMap<String, InputFile>();
Map<String, String> deprecatedDirectoryKeyMapper = new HashMap<String, String>();
for (InputFile inputFile : inputFiles) {
String deprecatedKey = computeDeprecatedKey(module.getKey(), (DeprecatedDefaultInputFile) inputFile, fs);
if (deprecatedKey != null) {
if (InputFile.Type.TEST == inputFile.type() && !deprecatedTestKeyMapper.containsKey(deprecatedKey)) {
deprecatedTestKeyMapper.put(deprecatedKey, inputFile);
} else if (InputFile.Type.MAIN == inputFile.type() && !deprecatedFileKeyMapper.containsKey(deprecatedKey)) {
deprecatedFileKeyMapper.put(deprecatedKey, inputFile);
}
}
}
ResourceModel moduleModel = session.getSingleResult(ResourceModel.class, "key", module.getEffectiveKey());
int moduleId = moduleModel.getId();
migrateFiles(module, deprecatedFileKeyMapper, deprecatedTestKeyMapper, deprecatedDirectoryKeyMapper, moduleId);
migrateDirectories(deprecatedDirectoryKeyMapper, moduleId);
session.commit();
}
代码示例来源:origin: org.codehaus.sonar/sonar-batch
@Override
public IssueBuilder newIssueBuilder() {
return new DefaultIssueBuilder().componentKey(component.key()).projectKey(project.getKey());
}
代码示例来源:origin: org.codehaus.sonar/sonar-batch
@VisibleForTesting
public DefaultModuleFileSystem(Project project,
Settings settings, FileIndexer indexer, ModuleFileSystemInitializer initializer, ComponentIndexer componentIndexer) {
super(initializer.baseDir().toPath());
this.componentIndexer = componentIndexer;
this.moduleKey = project.getKey();
this.settings = settings;
this.indexer = indexer;
setWorkDir(initializer.workingDir());
this.buildDir = initializer.buildDir();
this.sourceDirsOrFiles = initializer.sources();
this.testDirsOrFiles = initializer.tests();
this.binaryDirs = initializer.binaryDirs();
}
代码示例来源:origin: org.codehaus.sonar-plugins/sonar-useless-code-tracker-plugin
@Override
public void decorate(Resource resource, DecoratorContext context) {
double uselessDuplicatedLines = 0;
Measure measure = context.getMeasure(CoreMetrics.DUPLICATIONS_DATA);
if (MeasureUtils.hasData(measure)) {
String resourceKey = new StringBuilder(ResourceModel.KEY_SIZE)
.append(context.getProject().getKey())
.append(':')
.append(context.getResource().getKey())
.toString();
List<List<Block>> groups = parseDuplicationData(measure.getData());
uselessDuplicatedLines = analyse(groups, resourceKey);
}
uselessDuplicatedLines += MeasureUtils.sum(true, context.getChildrenMeasures(TrackerMetrics.USELESS_DUPLICATED_LINES));
if (uselessDuplicatedLines > 0) {
context.saveMeasure(TrackerMetrics.USELESS_DUPLICATED_LINES, uselessDuplicatedLines);
}
}
代码示例来源:origin: org.codehaus.sonar/sonar-batch
private Snapshot buildProjectSnapshot() {
Query query = session
.createNativeQuery("select p.id from projects p where p.kee=:resourceKey and p.qualifier<>:lib and p.enabled=:enabled");
query.setParameter("resourceKey", projectTree.getRootProject().getKey());
query.setParameter("lib", Qualifiers.LIBRARY);
query.setParameter("enabled", Boolean.TRUE);
Snapshot snapshot = null;
Number projectId = session.getSingleResult(query, null);
if (projectId != null) {
snapshot = new Snapshot();
snapshot.setResourceId(projectId.intValue());
snapshot.setCreatedAtMs(dateToLong(projectTree.getRootProject().getAnalysisDate()));
snapshot.setBuildDateMs(System.currentTimeMillis());
snapshot.setVersion(projectTree.getRootProject().getAnalysisVersion());
}
return snapshot;
}
代码示例来源: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/sonar-batch
public DefaultModuleFileSystem(ModuleInputFileCache moduleInputFileCache, Project project,
Settings settings, FileIndexer indexer, ModuleFileSystemInitializer initializer, ComponentIndexer componentIndexer) {
super(initializer.baseDir(), moduleInputFileCache);
this.componentIndexer = componentIndexer;
this.moduleKey = project.getKey();
this.settings = settings;
this.indexer = indexer;
setWorkDir(initializer.workingDir());
this.buildDir = initializer.buildDir();
this.sourceDirsOrFiles = initializer.sources();
this.testDirsOrFiles = initializer.tests();
this.binaryDirs = initializer.binaryDirs();
}
代码示例来源:origin: org.codehaus.sonar/sonar-batch
@Override
public void store(Issue issue) {
Resource r;
InputPath inputPath = issue.inputPath();
if (inputPath != null) {
if (inputPath instanceof InputDir) {
r = Directory.create(inputPath.relativePath());
} else {
r = File.create(inputPath.relativePath());
}
} else {
r = project;
}
Issuable issuable = perspectives.as(Issuable.class, r);
if (issuable == null) {
return;
}
issuable.addIssue(toDefaultIssue(project.getKey(), ComponentKeys.createEffectiveKey(project, r), issue));
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-batch
private void setFields(Project project,
Settings settings, FileIndexer indexer, ModuleFileSystemInitializer initializer, ComponentIndexer componentIndexer, DefaultAnalysisMode mode) {
this.componentIndexer = componentIndexer;
this.moduleKey = project.getKey();
this.settings = settings;
this.indexer = indexer;
setWorkDir(initializer.workingDir());
this.buildDir = initializer.buildDir();
this.sourceDirsOrFiles = initializer.sources();
this.testDirsOrFiles = initializer.tests();
this.binaryDirs = initializer.binaryDirs();
// filter the files sensors have access to
if (!mode.scanAllFiles()) {
setDefaultPredicate(predicates.not(predicates.hasStatus(Status.SAME)));
}
}
代码示例来源:origin: org.codehaus.sonar/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();
}
}
}
内容来源于网络,如有侵权,请联系作者删除!