Search in sources :

Example 1 with FileCollectionInternal

use of org.gradle.api.internal.file.FileCollectionInternal in project gradle by gradle.

the class DefaultConfigurableFileCollectionTest method taskDependenciesContainsUnionOfDependenciesOfNestedFileCollectionsPlusOwnDependencies.

@Test
public void taskDependenciesContainsUnionOfDependenciesOfNestedFileCollectionsPlusOwnDependencies() {
    final FileCollectionInternal fileCollectionMock = context.mock(FileCollectionInternal.class);
    collection.from(fileCollectionMock);
    collection.from("f");
    collection.builtBy("b");
    final Task taskA = context.mock(Task.class, "a");
    final Task taskB = context.mock(Task.class, "b");
    context.checking(new Expectations() {

        {
            allowing(resolverMock).resolve("f");
            will(returnValue(new File("f")));
            TaskDependency dependency = context.mock(TaskDependency.class);
            allowing(fileCollectionMock).getBuildDependencies();
            will(returnValue(dependency));
            allowing(dependency).getDependencies(null);
            will(returnValue(toSet(taskA)));
            allowing(taskResolverStub).resolveTask("b");
            will(returnValue(taskB));
        }
    });
    assertThat(collection.getBuildDependencies().getDependencies(null), equalTo((Set) toSet(taskA, taskB)));
}
Also used : Expectations(org.jmock.Expectations) TaskDependency(org.gradle.api.tasks.TaskDependency) Task(org.gradle.api.Task) Set(java.util.Set) FileCollectionInternal(org.gradle.api.internal.file.FileCollectionInternal) File(java.io.File) Test(org.junit.Test)

Example 2 with FileCollectionInternal

use of org.gradle.api.internal.file.FileCollectionInternal in project gradle by gradle.

the class AbstractFileCollectionSnapshotter method snapshot.

@Override
public FileCollectionSnapshot snapshot(FileCollection input, TaskFilePropertyCompareStrategy compareStrategy, final SnapshotNormalizationStrategy snapshotNormalizationStrategy) {
    final List<FileDetails> fileTreeElements = Lists.newLinkedList();
    FileCollectionInternal fileCollection = (FileCollectionInternal) input;
    FileCollectionVisitorImpl visitor = new FileCollectionVisitorImpl(fileTreeElements);
    fileCollection.visitRootElements(visitor);
    if (fileTreeElements.isEmpty()) {
        return FileCollectionSnapshot.EMPTY;
    }
    Map<String, NormalizedFileSnapshot> snapshots = Maps.newLinkedHashMap();
    for (FileDetails fileDetails : fileTreeElements) {
        String absolutePath = fileDetails.getPath();
        if (!snapshots.containsKey(absolutePath)) {
            NormalizedFileSnapshot normalizedSnapshot = snapshotNormalizationStrategy.getNormalizedSnapshot(fileDetails, stringInterner);
            if (normalizedSnapshot != null) {
                snapshots.put(absolutePath, normalizedSnapshot);
            }
        }
    }
    return new DefaultFileCollectionSnapshot(snapshots, compareStrategy, snapshotNormalizationStrategy.isPathAbsolute());
}
Also used : FileCollectionInternal(org.gradle.api.internal.file.FileCollectionInternal)

Example 3 with FileCollectionInternal

use of org.gradle.api.internal.file.FileCollectionInternal in project gradle by gradle.

the class DefaultConfiguration method registerWatchPoints.

@Override
public void registerWatchPoints(FileSystemSubset.Builder builder) {
    for (Dependency dependency : allDependencies) {
        if (dependency instanceof FileCollectionDependency) {
            FileCollection files = ((FileCollectionDependency) dependency).getFiles();
            ((FileCollectionInternal) files).registerWatchPoints(builder);
        }
    }
    super.registerWatchPoints(builder);
}
Also used : FileCollectionInternal(org.gradle.api.internal.file.FileCollectionInternal) TaskDependency(org.gradle.api.tasks.TaskDependency) FileCollectionDependency(org.gradle.api.artifacts.FileCollectionDependency) AbstractTaskDependency(org.gradle.api.internal.tasks.AbstractTaskDependency) Dependency(org.gradle.api.artifacts.Dependency) AbstractFileCollection(org.gradle.api.internal.file.AbstractFileCollection) FileCollection(org.gradle.api.file.FileCollection) FileCollectionDependency(org.gradle.api.artifacts.FileCollectionDependency)

Example 4 with FileCollectionInternal

use of org.gradle.api.internal.file.FileCollectionInternal in project gradle by gradle.

the class ContinuousBuildActionExecuter method executeBuildAndAccumulateInputs.

private Object executeBuildAndAccumulateInputs(BuildAction action, BuildRequestContext requestContext, BuildActionParameters actionParameters, final FileSystemChangeWaiter waiter, ServiceRegistry buildSessionScopeServices) {
    TaskInputsListener listener = new TaskInputsListener() {

        @Override
        public void onExecute(TaskInternal taskInternal, FileCollectionInternal fileSystemInputs) {
            FileSystemSubset.Builder fileSystemSubsetBuilder = FileSystemSubset.builder();
            fileSystemInputs.registerWatchPoints(fileSystemSubsetBuilder);
            waiter.watch(fileSystemSubsetBuilder.build());
        }
    };
    listenerManager.addListener(listener);
    try {
        return delegate.execute(action, requestContext, actionParameters, buildSessionScopeServices);
    } finally {
        listenerManager.removeListener(listener);
    }
}
Also used : TaskInternal(org.gradle.api.internal.TaskInternal) FileCollectionInternal(org.gradle.api.internal.file.FileCollectionInternal) FileSystemSubset(org.gradle.api.internal.file.FileSystemSubset) TaskInputsListener(org.gradle.api.execution.internal.TaskInputsListener)

Example 5 with FileCollectionInternal

use of org.gradle.api.internal.file.FileCollectionInternal in project gradle by gradle.

the class DependencyClassPathNotationConverter method maybeCreateUnderLock.

private SelfResolvingDependency maybeCreateUnderLock(DependencyFactory.ClassPathNotation notation) {
    SelfResolvingDependency dependency = internCache.get(notation);
    if (dependency == null) {
        Collection<File> classpath = classPathRegistry.getClassPath(notation.name()).getAsFiles();
        boolean runningFromInstallation = currentGradleInstallation.getInstallation() != null;
        FileCollectionInternal files;
        if (runningFromInstallation && notation.equals(GRADLE_API)) {
            files = gradleApiFileCollection(classpath);
        } else if (runningFromInstallation && notation.equals(GRADLE_TEST_KIT)) {
            files = gradleTestKitFileCollection(classpath);
        } else {
            files = fileResolver.resolveFiles(classpath);
        }
        dependency = instantiator.newInstance(DefaultSelfResolvingDependency.class, new OpaqueComponentIdentifier(notation.displayName), files);
        internCache.put(notation, dependency);
    }
    return dependency;
}
Also used : DefaultSelfResolvingDependency(org.gradle.api.internal.artifacts.dependencies.DefaultSelfResolvingDependency) SelfResolvingDependency(org.gradle.api.artifacts.SelfResolvingDependency) FileCollectionInternal(org.gradle.api.internal.file.FileCollectionInternal) OpaqueComponentIdentifier(org.gradle.internal.component.local.model.OpaqueComponentIdentifier) File(java.io.File) DefaultSelfResolvingDependency(org.gradle.api.internal.artifacts.dependencies.DefaultSelfResolvingDependency)

Aggregations

FileCollectionInternal (org.gradle.api.internal.file.FileCollectionInternal)6 File (java.io.File)3 TaskDependency (org.gradle.api.tasks.TaskDependency)2 Expectations (org.jmock.Expectations)2 Test (org.junit.Test)2 Set (java.util.Set)1 Task (org.gradle.api.Task)1 Dependency (org.gradle.api.artifacts.Dependency)1 FileCollectionDependency (org.gradle.api.artifacts.FileCollectionDependency)1 SelfResolvingDependency (org.gradle.api.artifacts.SelfResolvingDependency)1 TaskInputsListener (org.gradle.api.execution.internal.TaskInputsListener)1 FileCollection (org.gradle.api.file.FileCollection)1 TaskInternal (org.gradle.api.internal.TaskInternal)1 DefaultSelfResolvingDependency (org.gradle.api.internal.artifacts.dependencies.DefaultSelfResolvingDependency)1 AbstractFileCollection (org.gradle.api.internal.file.AbstractFileCollection)1 FileSystemSubset (org.gradle.api.internal.file.FileSystemSubset)1 AbstractTaskDependency (org.gradle.api.internal.tasks.AbstractTaskDependency)1 OpaqueComponentIdentifier (org.gradle.internal.component.local.model.OpaqueComponentIdentifier)1