use of org.gradle.api.plugins.buildcomparison.outcome.internal.BuildOutcome 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.outcome.internal.BuildOutcome in project gradle by gradle.
the class BuildComparisonSpecFactory method createSpec.
public BuildComparisonSpec createSpec(Set<BuildOutcome> from, Set<BuildOutcome> to) {
BuildComparisonSpecBuilder builder = new DefaultBuildComparisonSpecBuilder();
Set<BuildOutcome> toCopy = new HashSet<BuildOutcome>(to);
for (BuildOutcome fromBuildOutcome : from) {
BuildOutcome toBuildOutcome = null;
Class<? extends BuildOutcome> associationType = null;
for (BuildOutcome buildOutcome : toCopy) {
toBuildOutcome = buildOutcome;
associationType = associator.findAssociationType(fromBuildOutcome, toBuildOutcome);
if (associationType != null) {
break;
}
}
if (associationType == null) {
builder.addUnassociatedFrom(fromBuildOutcome);
} else {
builder.associate(associationType.cast(fromBuildOutcome), associationType.cast(toBuildOutcome), (Class<BuildOutcome>) associationType);
toCopy.remove(toBuildOutcome);
}
}
for (BuildOutcome buildOutcome : toCopy) {
builder.addUnassociatedTo(buildOutcome);
}
return builder.build();
}
use of org.gradle.api.plugins.buildcomparison.outcome.internal.BuildOutcome in project gradle by gradle.
the class DefaultBuildComparator method compareBuilds.
public BuildComparisonResult compareBuilds(BuildComparisonSpec spec) {
Set<BuildOutcome> uncomparedFrom = new HashSet<BuildOutcome>(spec.getSource());
Set<BuildOutcome> uncomparedTo = new HashSet<BuildOutcome>(spec.getTarget());
Set<BuildOutcome> unknownFrom = new HashSet<BuildOutcome>();
Set<BuildOutcome> unknownTo = new HashSet<BuildOutcome>();
List<BuildOutcomeComparisonResult<?>> results = new LinkedList<BuildOutcomeComparisonResult<?>>();
for (BuildOutcomeAssociation<? extends BuildOutcome> outcomeAssociation : spec.getOutcomeAssociations()) {
BuildOutcome from = outcomeAssociation.getSource();
boolean unknown = false;
if (!uncomparedFrom.remove(from)) {
unknown = true;
unknownFrom.add(from);
}
BuildOutcome to = outcomeAssociation.getTarget();
if (!uncomparedTo.remove(to)) {
unknown = true;
unknownTo.add(to);
}
// TODO - error if there are unknowns?
if (!unknown) {
BuildOutcomeComparator<?, ?> comparator = comparatorFactory.getComparator(outcomeAssociation.getType());
if (comparator == null) {
// TODO - better exception
throw new RuntimeException(String.format("No comparator for %s", outcomeAssociation.getType()));
}
@SuppressWarnings("unchecked") BuildOutcomeComparisonResult<?> comparisonResult = comparator.compare((BuildOutcomeAssociation) outcomeAssociation);
results.add(comparisonResult);
}
}
return new BuildComparisonResult(uncomparedFrom, uncomparedTo, results);
}
use of org.gradle.api.plugins.buildcomparison.outcome.internal.BuildOutcome in project gradle by gradle.
the class GradleBuildOutcomeSetTransformer method addFileBuildOutcome.
private void addFileBuildOutcome(GradleFileBuildOutcome outcome, ProjectOutcomes rootProject, Set<BuildOutcome> translatedOutcomes) {
if (zipArchiveTypes.contains(outcome.getTypeIdentifier())) {
File originalFile = outcome.getFile();
String relativePath = GFileUtils.relativePath(rootProject.getProjectDirectory(), originalFile);
LocallyAvailableResource resource = null;
if (originalFile.exists()) {
String filestoreDestination = fileStorePrefix + "/" + outcome.getTaskPath() + "/" + originalFile.getName();
resource = fileStore.move(filestoreDestination, originalFile);
}
BuildOutcome buildOutcome = new GeneratedArchiveBuildOutcome(outcome.getTaskPath(), outcome.getDescription(), resource, relativePath);
translatedOutcomes.add(buildOutcome);
} else {
String outcomeName = outcome.getTaskPath();
if (isEmpty(outcomeName)) {
outcomeName = GFileUtils.relativePath(rootProject.getProjectDirectory(), outcome.getFile());
}
translatedOutcomes.add(new UnknownBuildOutcome(outcomeName, outcome.getDescription()));
}
}
Aggregations