Skip to content

Commit

Permalink
Update handling for version metadata
Browse files Browse the repository at this point in the history
- Fixes instances of version being set to null or '1.0.0'
- In the event a 'version' can not be found, 'version' gets set to 'projectVersion'
  • Loading branch information
danielrigos committed Feb 2, 2022
1 parent c375481 commit 1a866c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,6 @@ public void run() {
benchmarkSetting.put("benchReportName", getProperty(Constants.BENCHMARK_REPORT_NAME));
}

LOG.info("---> benchmarkSetting: {}", benchmarkSetting);

for (String s : report.getBenchmarks().keySet()) {
List<BenchmarkReport> custom = new ArrayList<>(report.getBenchmarks().get(s));
custom.forEach(benchmarkReport -> {
Expand All @@ -258,9 +256,7 @@ public void run() {
appendMetadataFromAnnotated(benchmarkMethod, benchmarkReport);
appendMetadataFromJavaDoc(aClass, benchmarkMethod, benchmarkReport);
benchmarkSetting.put(Constants.REPORT_VERSION, getRunnerVersion());
LOG.info("Placed Runner Version");
try {
benchmarkReport.setVersion(getMetadataFromBuildFile("version")); //tempfix for missing version
if (StringUtils.isNotEmpty(benchmarkReport.getProject())) {
report.setProject(benchmarkReport.getProject());
} else {
Expand All @@ -277,6 +273,11 @@ public void run() {

benchmarkReport.setProjectVersion(getMetadataFromBuildFile("version"));
}

if (StringUtils.isEmpty(benchmarkReport.getVersion())) {
benchmarkReport.setVersion(getMetadataFromBuildFile("version"));

}
} catch (Exception e) {
LOG.error("Error while attempting to setProject from runner: ", e);
}
Expand Down Expand Up @@ -448,7 +449,6 @@ public static void appendMetadataFromAnnotated(Optional<? extends AnnotatedEleme
if (singleAnnotation != null) {
checkSetOldMetadataProps(singleAnnotation.key(), singleAnnotation.value(), benchmarkReport);
benchmarkReport.addMetadata(singleAnnotation.key(), singleAnnotation.value());
LOG.info("added metadata(2) " + singleAnnotation.key() + "=" + singleAnnotation.value());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public Map<String, String> prepareBenchmarkProperties(String className,
} else {
benchmarkProperties.put("benchCategory", "CUSTOM");
benchmarkProperties.put("benchContext", "Custom");
benchmarkProperties.put("benchVersion", "1.0.0");

}
return benchmarkProperties;
} catch (Exception e) {
Expand Down Expand Up @@ -241,12 +241,11 @@ public Map<String, String> prepareBenchmarkSettings(String className,
}
} else {
benchmarkProperties.put("benchContext", "Custom");
benchmarkProperties.put("benchVersion", "1.0.0");

}
return benchmarkProperties;
} catch (Exception e) {
benchmarkProperties.put("benchContext", "Custom");
benchmarkProperties.put("benchVersion", "1.0.0");
benchmarkProperties.put("project", "Custom");
LOG.error("Error on resolving category: class={}", className, e);
}
Expand Down

0 comments on commit 1a866c4

Please sign in to comment.