Search in sources :

Example 6 with Timer

use of org.gradle.internal.time.Timer in project gradle by gradle.

the class BuildScriptProcessor method execute.

public void execute(ProjectInternal project) {
    LOGGER.info("Evaluating {} using {}.", project, project.getBuildScriptSource().getDisplayName());
    final Timer clock = Timers.startTimer();
    try {
        ScriptPlugin configurer = configurerFactory.create(project.getBuildScriptSource(), project.getBuildscript(), project.getClassLoaderScope(), project.getBaseClassLoaderScope(), true);
        configurer.apply(project);
    } finally {
        LOGGER.debug("Timing: Running the build script took {}", clock.getElapsed());
    }
}
Also used : Timer(org.gradle.internal.time.Timer) ScriptPlugin(org.gradle.configuration.ScriptPlugin)

Example 7 with Timer

use of org.gradle.internal.time.Timer in project gradle by gradle.

the class JarClasspathSnapshotMaker method storeJarSnapshots.

@Override
public void storeJarSnapshots(Iterable<File> classpath) {
    //clients may or may not have already created jar classpath snapshot
    maybeInitialize(classpath);
    Timer clock = Timers.startTimer();
    classpathSnapshotStore.put(jarClasspathSnapshot.getData());
    LOG.info("Written jar classpath snapshot for incremental compilation in {}.", clock.getElapsed());
}
Also used : Timer(org.gradle.internal.time.Timer)

Example 8 with Timer

use of org.gradle.internal.time.Timer in project gradle by gradle.

the class ResolveTaskArtifactStateTaskExecuter method execute.

@Override
public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    Timer clock = Timers.startTimer();
    context.setTaskArtifactState(repository.getStateFor(task));
    LOGGER.info("Putting task artifact state for {} into context took {}.", task, clock.getElapsed());
    try {
        executer.execute(task, state, context);
    } finally {
        context.setTaskArtifactState(null);
        LOGGER.debug("Removed task artifact state for {} from context.");
    }
}
Also used : Timer(org.gradle.internal.time.Timer)

Example 9 with Timer

use of org.gradle.internal.time.Timer in project gradle by gradle.

the class SkipCachedTaskExecuter method execute.

@Override
public void execute(final TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    final Timer clock = Timers.startTimer();
    LOGGER.debug("Determining if {} is cached already", task);
    final TaskOutputsInternal taskOutputs = task.getOutputs();
    TaskOutputCachingBuildCacheKey cacheKey = context.getBuildCacheKey();
    boolean taskOutputCachingEnabled = state.getTaskOutputCaching().isEnabled();
    if (taskOutputCachingEnabled) {
        if (cacheKey.isValid()) {
            TaskArtifactState taskState = context.getTaskArtifactState();
            if (taskState.isAllowedToUseCachedResults()) {
                boolean found = buildCache.load(cacheKey, new BuildCacheEntryReader() {

                    @Override
                    public void readFrom(final InputStream input) {
                        taskOutputsGenerationListener.beforeTaskOutputsGenerated();
                        packer.unpack(taskOutputs, input, taskOutputOriginFactory.createReader(task));
                        LOGGER.info("Unpacked output for {} from cache (took {}).", task, clock.getElapsed());
                    }
                });
                if (found) {
                    state.setOutcome(TaskExecutionOutcome.FROM_CACHE);
                    return;
                }
            } else {
                LOGGER.info("Not loading {} from cache because pulling from cache is disabled for this task", task);
            }
        } else {
            LOGGER.info("Not caching {} because no valid cache key was generated", task);
        }
    }
    delegate.execute(task, state, context);
    if (taskOutputCachingEnabled) {
        if (cacheKey.isValid()) {
            if (state.getFailure() == null) {
                buildCache.store(cacheKey, new BuildCacheEntryWriter() {

                    @Override
                    public void writeTo(OutputStream output) {
                        LOGGER.info("Packing {}", task.getPath());
                        packer.pack(taskOutputs, output, taskOutputOriginFactory.createWriter(task, clock.getElapsedMillis()));
                    }
                });
            } else {
                LOGGER.debug("Not pushing result from {} to cache because the task failed", task);
            }
        } else {
            LOGGER.info("Not pushing results from {} to cache because no valid cache key was generated", task);
        }
    }
}
Also used : Timer(org.gradle.internal.time.Timer) TaskArtifactState(org.gradle.api.internal.changedetection.TaskArtifactState) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) TaskOutputCachingBuildCacheKey(org.gradle.caching.internal.tasks.TaskOutputCachingBuildCacheKey) BuildCacheEntryReader(org.gradle.caching.BuildCacheEntryReader) TaskOutputsInternal(org.gradle.api.internal.TaskOutputsInternal) BuildCacheEntryWriter(org.gradle.caching.BuildCacheEntryWriter)

Example 10 with Timer

use of org.gradle.internal.time.Timer in project gradle by gradle.

the class SkipUpToDateTaskExecuter method execute.

public void execute(TaskInternal task, TaskStateInternal state, TaskExecutionContext context) {
    LOGGER.debug("Determining if {} is up-to-date", task);
    Timer clock = Timers.startTimer();
    TaskArtifactState taskArtifactState = context.getTaskArtifactState();
    try {
        List<String> messages = LOGGER.isInfoEnabled() ? new ArrayList<String>() : null;
        if (taskArtifactState.isUpToDate(messages)) {
            LOGGER.info("Skipping {} as it is up-to-date (took {}).", task, clock.getElapsed());
            state.setOutcome(TaskExecutionOutcome.UP_TO_DATE);
            return;
        }
        logOutOfDateMessages(messages, task, clock.getElapsed());
        task.getOutputs().setHistory(taskArtifactState.getExecutionHistory());
        taskArtifactState.beforeTask();
        try {
            executer.execute(task, state, context);
            if (state.getFailure() == null) {
                taskArtifactState.afterTask();
            }
        } finally {
            task.getOutputs().setHistory(null);
        }
    } finally {
        taskArtifactState.finished();
    }
}
Also used : Timer(org.gradle.internal.time.Timer) TaskArtifactState(org.gradle.api.internal.changedetection.TaskArtifactState)

Aggregations

Timer (org.gradle.internal.time.Timer)18 File (java.io.File)2 IOException (java.io.IOException)2 GradleException (org.gradle.api.GradleException)2 TaskArtifactState (org.gradle.api.internal.changedetection.TaskArtifactState)2 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 CompilerConfiguration (org.codehaus.groovy.control.CompilerConfiguration)1 Action (org.gradle.api.Action)1 Task (org.gradle.api.Task)1 UncheckedIOException (org.gradle.api.UncheckedIOException)1 ModuleDependency (org.gradle.api.artifacts.ModuleDependency)1 SettingsInternal (org.gradle.api.internal.SettingsInternal)1 TaskOutputsInternal (org.gradle.api.internal.TaskOutputsInternal)1 DefaultResolvedDependency (org.gradle.api.internal.artifacts.DefaultResolvedDependency)1 DependencyGraphNodeResult (org.gradle.api.internal.artifacts.DependencyGraphNodeResult)1 ResolvedConfigurationIdentifier (org.gradle.api.internal.artifacts.ResolvedConfigurationIdentifier)1