Search in sources :

Example 1 with DefaultIncrementalInputProperties

use of org.gradle.internal.execution.history.changes.DefaultIncrementalInputProperties in project gradle by gradle.

the class ResolveChangesStep method createIncrementalInputProperties.

private static IncrementalInputProperties createIncrementalInputProperties(UnitOfWork work) {
    UnitOfWork.InputChangeTrackingStrategy inputChangeTrackingStrategy = work.getInputChangeTrackingStrategy();
    switch(inputChangeTrackingStrategy) {
        case NONE:
            return IncrementalInputProperties.NONE;
        // noinspection deprecation
        case ALL_PARAMETERS:
            // When using IncrementalTaskInputs, keep the old behaviour of all file inputs being incremental
            return IncrementalInputProperties.ALL;
        case INCREMENTAL_PARAMETERS:
            ImmutableBiMap.Builder<String, Object> builder = ImmutableBiMap.builder();
            InputVisitor visitor = new InputVisitor() {

                @Override
                public void visitInputFileProperty(String propertyName, InputPropertyType type, FileValueSupplier valueSupplier) {
                    if (type.isIncremental()) {
                        Object value = valueSupplier.getValue();
                        if (value == null) {
                            throw new InvalidUserDataException("Must specify a value for incremental input property '" + propertyName + "'.");
                        }
                        builder.put(propertyName, value);
                    }
                }
            };
            work.visitIdentityInputs(visitor);
            work.visitRegularInputs(visitor);
            return new DefaultIncrementalInputProperties(builder.build());
        default:
            throw new AssertionError("Unknown InputChangeTrackingStrategy: " + inputChangeTrackingStrategy);
    }
}
Also used : UnitOfWork(org.gradle.internal.execution.UnitOfWork) ImmutableBiMap(com.google.common.collect.ImmutableBiMap) InputPropertyType(org.gradle.internal.execution.fingerprint.InputFingerprinter.InputPropertyType) InvalidUserDataException(org.gradle.api.InvalidUserDataException) DefaultIncrementalInputProperties(org.gradle.internal.execution.history.changes.DefaultIncrementalInputProperties) InputVisitor(org.gradle.internal.execution.fingerprint.InputFingerprinter.InputVisitor) FileValueSupplier(org.gradle.internal.execution.fingerprint.InputFingerprinter.FileValueSupplier)

Aggregations

ImmutableBiMap (com.google.common.collect.ImmutableBiMap)1 InvalidUserDataException (org.gradle.api.InvalidUserDataException)1 UnitOfWork (org.gradle.internal.execution.UnitOfWork)1 FileValueSupplier (org.gradle.internal.execution.fingerprint.InputFingerprinter.FileValueSupplier)1 InputPropertyType (org.gradle.internal.execution.fingerprint.InputFingerprinter.InputPropertyType)1 InputVisitor (org.gradle.internal.execution.fingerprint.InputFingerprinter.InputVisitor)1 DefaultIncrementalInputProperties (org.gradle.internal.execution.history.changes.DefaultIncrementalInputProperties)1