
org.gradle.internal.execution.steps.IdentifyStep Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-tooling-api Show documentation
Show all versions of gradle-tooling-api Show documentation
Gradle Tooling API - the programmatic API to invoke Gradle
The newest version!
/*
* Copyright 2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gradle.internal.execution.steps;
import com.google.common.collect.ImmutableSortedMap;
import org.gradle.cache.Cache;
import org.gradle.internal.Try;
import org.gradle.internal.execution.DeferredExecutionHandler;
import org.gradle.internal.execution.UnitOfWork;
import org.gradle.internal.execution.UnitOfWork.Identity;
import org.gradle.internal.execution.WorkValidationContext;
import org.gradle.internal.execution.fingerprint.InputFingerprinter;
import org.gradle.internal.fingerprint.CurrentFileCollectionFingerprint;
import org.gradle.internal.snapshot.ValueSnapshot;
import javax.annotation.Nonnull;
import java.util.Optional;
public class IdentifyStep implements DeferredExecutionAwareStep {
private final DeferredExecutionAwareStep super IdentityContext, R> delegate;
public IdentifyStep(
DeferredExecutionAwareStep super IdentityContext, R> delegate
) {
this.delegate = delegate;
}
@Override
public R execute(UnitOfWork work, C context) {
return delegate.execute(work, createIdentityContext(work, context));
}
@Override
public T executeDeferred(UnitOfWork work, C context, Cache> cache, DeferredExecutionHandler handler) {
return delegate.executeDeferred(work, createIdentityContext(work, context), cache, handler);
}
@Nonnull
private IdentityContext createIdentityContext(UnitOfWork work, C context) {
InputFingerprinter.Result inputs = work.getInputFingerprinter().fingerprintInputProperties(
ImmutableSortedMap.of(),
ImmutableSortedMap.of(),
ImmutableSortedMap.of(),
ImmutableSortedMap.of(),
work::visitIdentityInputs
);
ImmutableSortedMap identityInputProperties = inputs.getValueSnapshots();
ImmutableSortedMap identityInputFileProperties = inputs.getFileFingerprints();
Identity identity = work.identify(identityInputProperties, identityInputFileProperties);
return new IdentityContext() {
@Override
public Optional getRebuildReason() {
return context.getRebuildReason();
}
@Override
public WorkValidationContext getValidationContext() {
return context.getValidationContext();
}
@Override
public ImmutableSortedMap getInputProperties() {
return identityInputProperties;
}
@Override
public ImmutableSortedMap getInputFileProperties() {
return identityInputFileProperties;
}
@Override
public Identity getIdentity() {
return identity;
}
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy