use of org.gradle.api.plugins.buildcomparison.compare.internal.BuildComparisonResult in project gradle by gradle.
the class GradleBuildComparison method compare.
public BuildComparisonResult compare(FileStore<String> fileStore, File reportDir, Map<String, String> hostAttributes) {
String executingSourceBuildMessage = executingMessage("source", sourceBuildExecuter);
String executingTargetBuildMessage = executingMessage("target", targetBuildExecuter);
if (!sourceBuildExecuter.isExecutable() || !targetBuildExecuter.isExecutable()) {
throw new GradleException(String.format("Builds must be executed with %s or newer (source: %s, target: %s)", ComparableGradleBuildExecuter.EXEC_MINIMUM_VERSION, sourceBuildExecuter.getSpec().getGradleVersion(), targetBuildExecuter.getSpec().getGradleVersion()));
}
Set<BuildOutcome> sourceOutcomes;
logger.info(executingSourceBuildMessage);
progressLogger.started(executingSourceBuildMessage);
ProjectOutcomes sourceOutput = executeBuild(sourceBuildExecuter);
progressLogger.progress("inspecting source build outcomes");
GradleBuildOutcomeSetTransformer sourceOutcomeTransformer = createOutcomeSetTransformer(fileStore, SOURCE_FILESTORE_PREFIX);
sourceOutcomes = sourceOutcomeTransformer.transform(sourceOutput);
logger.info(executingTargetBuildMessage);
progressLogger.progress(executingTargetBuildMessage);
ProjectOutcomes targetOutput = executeBuild(targetBuildExecuter);
Set<BuildOutcome> targetOutcomes;
progressLogger.progress("inspecting target build outcomes");
GradleBuildOutcomeSetTransformer targetOutcomeTransformer = createOutcomeSetTransformer(fileStore, TARGET_FILESTORE_PREFIX);
targetOutcomes = targetOutcomeTransformer.transform(targetOutput);
progressLogger.progress("comparing build outcomes");
BuildComparisonResult result = compareBuilds(sourceOutcomes, targetOutcomes);
writeReport(result, reportDir, fileStore, hostAttributes);
progressLogger.completed();
return result;
}
use of org.gradle.api.plugins.buildcomparison.compare.internal.BuildComparisonResult in project gradle by gradle.
the class CompareGradleBuilds method compare.
@SuppressWarnings("UnusedDeclaration")
@TaskAction
void compare() {
GradleBuildInvocationSpec sourceBuild = getSourceBuild();
GradleBuildInvocationSpec targetBuild = getTargetBuild();
if (sourceBuild.equals(targetBuild)) {
getLogger().warn("The source build and target build are identical. Set '{}.targetBuild.gradleVersion' if you want to compare with a different Gradle version.", getName());
}
ComparableGradleBuildExecuter sourceBuildExecuter = new ComparableGradleBuildExecuter(sourceBuild);
ComparableGradleBuildExecuter targetBuildExecuter = new ComparableGradleBuildExecuter(targetBuild);
Logger logger = getLogger();
ProgressLogger progressLogger = getProgressLoggerFactory().newOperation(getClass());
progressLogger.setDescription("Gradle Build Comparison");
progressLogger.setShortDescription(getName());
GradleBuildComparison comparison = new GradleBuildComparison(sourceBuildExecuter, targetBuildExecuter, logger, progressLogger, getProject().getGradle());
comparison.registerType(GeneratedArchiveBuildOutcome.class, new GeneratedArchiveBuildOutcomeComparator(), new GeneratedArchiveBuildOutcomeComparisonResultHtmlRenderer(), new GeneratedArchiveBuildOutcomeHtmlRenderer());
comparison.registerType(UnknownBuildOutcome.class, new UnknownBuildOutcomeComparator(), new UnknownBuildOutcomeComparisonResultHtmlRenderer(), new UnknownBuildOutcomeHtmlRenderer());
File fileStoreTmpBase = getFileResolver().resolve(String.format(TMP_FILESTORAGE_PREFIX + "-%s-%s", getName(), System.currentTimeMillis()));
FileStore<String> fileStore = new PathNormalisingKeyFileStore(fileStoreTmpBase);
Map<String, String> hostAttributes = new LinkedHashMap<String, String>(4);
hostAttributes.put("Project", getProject().getRootDir().getAbsolutePath());
hostAttributes.put("Task", getPath());
hostAttributes.put("Gradle version", GradleVersion.current().getVersion());
hostAttributes.put("Executed at", new SimpleDateFormat().format(new Date()));
BuildComparisonResult result = comparison.compare(fileStore, getReportDir(), hostAttributes);
communicateResult(result);
}
Aggregations