Search in sources :

Example 1 with PathSensitive

use of org.gradle.api.tasks.PathSensitive in project gradle by gradle.

the class AbstractInputPropertyAnnotationHandler method visitPropertyValue.

@Override
public void visitPropertyValue(PropertyValue propertyValue, PropertyVisitor visitor, PropertySpecFactory specFactory, BeanPropertyContext context) {
    PathSensitive pathSensitive = propertyValue.getAnnotation(PathSensitive.class);
    final PathSensitivity pathSensitivity;
    if (pathSensitive == null) {
        pathSensitivity = PathSensitivity.ABSOLUTE;
    } else {
        pathSensitivity = pathSensitive.value();
    }
    DeclaredTaskInputFileProperty fileSpec = createFileSpec(propertyValue, specFactory);
    fileSpec.withPropertyName(propertyValue.getPropertyName()).optional(propertyValue.isOptional()).withPathSensitivity(pathSensitivity).skipWhenEmpty(propertyValue.isAnnotationPresent(SkipWhenEmpty.class)).optional(propertyValue.isOptional());
    visitor.visitInputFileProperty(fileSpec);
}
Also used : DeclaredTaskInputFileProperty(org.gradle.api.internal.tasks.DeclaredTaskInputFileProperty) PathSensitivity(org.gradle.api.tasks.PathSensitivity) PathSensitive(org.gradle.api.tasks.PathSensitive)

Example 2 with PathSensitive

use of org.gradle.api.tasks.PathSensitive in project gradle by gradle.

the class InstallXCTestBundle method getBundleBinary.

@SkipWhenEmpty
@Nullable
@Optional
@PathSensitive(PathSensitivity.NAME_ONLY)
@InputFile
protected File getBundleBinary() {
    RegularFile bundle = getBundleBinaryFile().get();
    File bundleFile = bundle.getAsFile();
    if (!bundleFile.exists()) {
        return null;
    }
    return bundleFile;
}
Also used : RegularFile(org.gradle.api.file.RegularFile) File(java.io.File) RegularFile(org.gradle.api.file.RegularFile) InputFile(org.gradle.api.tasks.InputFile) SkipWhenEmpty(org.gradle.api.tasks.SkipWhenEmpty) Optional(org.gradle.api.tasks.Optional) PathSensitive(org.gradle.api.tasks.PathSensitive) Nullable(javax.annotation.Nullable) InputFile(org.gradle.api.tasks.InputFile)

Example 3 with PathSensitive

use of org.gradle.api.tasks.PathSensitive in project gradle by gradle.

the class XCTest method getRunScript.

/**
 * Workaround for when the task is given an input file that doesn't exist
 */
@SkipWhenEmpty
@Nullable
@Optional
@PathSensitive(PathSensitivity.ABSOLUTE)
@InputFile
protected File getRunScript() {
    RegularFile runScript = getRunScriptFile().get();
    File runScriptFile = runScript.getAsFile();
    if (!runScriptFile.exists()) {
        return null;
    }
    return runScriptFile;
}
Also used : RegularFile(org.gradle.api.file.RegularFile) File(java.io.File) RegularFile(org.gradle.api.file.RegularFile) InputFile(org.gradle.api.tasks.InputFile) SkipWhenEmpty(org.gradle.api.tasks.SkipWhenEmpty) Optional(org.gradle.api.tasks.Optional) PathSensitive(org.gradle.api.tasks.PathSensitive) Nullable(javax.annotation.Nullable) InputFile(org.gradle.api.tasks.InputFile)

Example 4 with PathSensitive

use of org.gradle.api.tasks.PathSensitive in project gradle by gradle.

the class AbstractInputFilePropertyAnnotationHandler method visitPropertyValue.

@Override
public void visitPropertyValue(String propertyName, PropertyValue value, PropertyMetadata propertyMetadata, PropertyVisitor visitor, BeanPropertyContext context) {
    Annotation fileNormalization = propertyMetadata.getAnnotationForCategory(NORMALIZATION);
    Class<? extends FileNormalizer> fileNormalizer;
    if (fileNormalization == null) {
        fileNormalizer = null;
    } else if (fileNormalization instanceof PathSensitive) {
        PathSensitivity pathSensitivity = ((PathSensitive) fileNormalization).value();
        fileNormalizer = FileParameterUtils.determineNormalizerForPathSensitivity(pathSensitivity);
    } else if (fileNormalization instanceof Classpath) {
        fileNormalizer = ClasspathNormalizer.class;
    } else if (fileNormalization instanceof CompileClasspath) {
        fileNormalizer = CompileClasspathNormalizer.class;
    } else {
        throw new IllegalStateException("Unknown normalization annotation used: " + fileNormalization);
    }
    visitor.visitInputFileProperty(propertyName, propertyMetadata.isAnnotationPresent(Optional.class), propertyMetadata.isAnnotationPresent(SkipWhenEmpty.class), determineDirectorySensitivity(propertyMetadata), propertyMetadata.isAnnotationPresent(NormalizeLineEndings.class) ? LineEndingSensitivity.NORMALIZE_LINE_ENDINGS : LineEndingSensitivity.DEFAULT, propertyMetadata.isAnnotationPresent(Incremental.class), fileNormalizer, value, getFilePropertyType());
}
Also used : Incremental(org.gradle.work.Incremental) CompileClasspath(org.gradle.api.tasks.CompileClasspath) Optional(org.gradle.api.tasks.Optional) SkipWhenEmpty(org.gradle.api.tasks.SkipWhenEmpty) CompileClasspathNormalizer(org.gradle.api.tasks.CompileClasspathNormalizer) Classpath(org.gradle.api.tasks.Classpath) CompileClasspath(org.gradle.api.tasks.CompileClasspath) PathSensitivity(org.gradle.api.tasks.PathSensitivity) PathSensitive(org.gradle.api.tasks.PathSensitive) Annotation(java.lang.annotation.Annotation)

Aggregations

PathSensitive (org.gradle.api.tasks.PathSensitive)4 Optional (org.gradle.api.tasks.Optional)3 SkipWhenEmpty (org.gradle.api.tasks.SkipWhenEmpty)3 File (java.io.File)2 Nullable (javax.annotation.Nullable)2 RegularFile (org.gradle.api.file.RegularFile)2 InputFile (org.gradle.api.tasks.InputFile)2 PathSensitivity (org.gradle.api.tasks.PathSensitivity)2 Annotation (java.lang.annotation.Annotation)1 DeclaredTaskInputFileProperty (org.gradle.api.internal.tasks.DeclaredTaskInputFileProperty)1 Classpath (org.gradle.api.tasks.Classpath)1 CompileClasspath (org.gradle.api.tasks.CompileClasspath)1 CompileClasspathNormalizer (org.gradle.api.tasks.CompileClasspathNormalizer)1 Incremental (org.gradle.work.Incremental)1