Search in sources :

Example 1 with UnknownBuildOutcomeComparisonResultHtmlRenderer

use of org.gradle.api.plugins.buildcomparison.outcome.internal.unknown.UnknownBuildOutcomeComparisonResultHtmlRenderer 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()));
    MovableFileStore<String> fileStore = new Files(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);
}
Also used : UnknownBuildOutcomeComparator(org.gradle.api.plugins.buildcomparison.outcome.internal.unknown.UnknownBuildOutcomeComparator) ProgressLogger(org.gradle.internal.logging.progress.ProgressLogger) Logger(org.gradle.api.logging.Logger) ProgressLogger(org.gradle.internal.logging.progress.ProgressLogger) GeneratedArchiveBuildOutcomeComparator(org.gradle.api.plugins.buildcomparison.outcome.internal.archive.GeneratedArchiveBuildOutcomeComparator) Date(java.util.Date) LinkedHashMap(java.util.LinkedHashMap) BuildComparisonResult(org.gradle.api.plugins.buildcomparison.compare.internal.BuildComparisonResult) DefaultGradleBuildInvocationSpec(org.gradle.api.plugins.buildcomparison.gradle.internal.DefaultGradleBuildInvocationSpec) GeneratedArchiveBuildOutcomeComparisonResultHtmlRenderer(org.gradle.api.plugins.buildcomparison.outcome.internal.archive.GeneratedArchiveBuildOutcomeComparisonResultHtmlRenderer) ComparableGradleBuildExecuter(org.gradle.api.plugins.buildcomparison.gradle.internal.ComparableGradleBuildExecuter) UnknownBuildOutcomeHtmlRenderer(org.gradle.api.plugins.buildcomparison.outcome.internal.unknown.UnknownBuildOutcomeHtmlRenderer) GeneratedArchiveBuildOutcomeHtmlRenderer(org.gradle.api.plugins.buildcomparison.outcome.internal.archive.GeneratedArchiveBuildOutcomeHtmlRenderer) UnknownBuildOutcomeComparisonResultHtmlRenderer(org.gradle.api.plugins.buildcomparison.outcome.internal.unknown.UnknownBuildOutcomeComparisonResultHtmlRenderer) File(java.io.File) SimpleDateFormat(java.text.SimpleDateFormat) GradleBuildComparison(org.gradle.api.plugins.buildcomparison.gradle.internal.GradleBuildComparison) TaskAction(org.gradle.api.tasks.TaskAction)

Aggregations

File (java.io.File)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 LinkedHashMap (java.util.LinkedHashMap)1 Logger (org.gradle.api.logging.Logger)1 BuildComparisonResult (org.gradle.api.plugins.buildcomparison.compare.internal.BuildComparisonResult)1 ComparableGradleBuildExecuter (org.gradle.api.plugins.buildcomparison.gradle.internal.ComparableGradleBuildExecuter)1 DefaultGradleBuildInvocationSpec (org.gradle.api.plugins.buildcomparison.gradle.internal.DefaultGradleBuildInvocationSpec)1 GradleBuildComparison (org.gradle.api.plugins.buildcomparison.gradle.internal.GradleBuildComparison)1 GeneratedArchiveBuildOutcomeComparator (org.gradle.api.plugins.buildcomparison.outcome.internal.archive.GeneratedArchiveBuildOutcomeComparator)1 GeneratedArchiveBuildOutcomeComparisonResultHtmlRenderer (org.gradle.api.plugins.buildcomparison.outcome.internal.archive.GeneratedArchiveBuildOutcomeComparisonResultHtmlRenderer)1 GeneratedArchiveBuildOutcomeHtmlRenderer (org.gradle.api.plugins.buildcomparison.outcome.internal.archive.GeneratedArchiveBuildOutcomeHtmlRenderer)1 UnknownBuildOutcomeComparator (org.gradle.api.plugins.buildcomparison.outcome.internal.unknown.UnknownBuildOutcomeComparator)1 UnknownBuildOutcomeComparisonResultHtmlRenderer (org.gradle.api.plugins.buildcomparison.outcome.internal.unknown.UnknownBuildOutcomeComparisonResultHtmlRenderer)1 UnknownBuildOutcomeHtmlRenderer (org.gradle.api.plugins.buildcomparison.outcome.internal.unknown.UnknownBuildOutcomeHtmlRenderer)1 TaskAction (org.gradle.api.tasks.TaskAction)1 ProgressLogger (org.gradle.internal.logging.progress.ProgressLogger)1