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)));
}
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());
}
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);
}
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);
}
}
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;
}
Aggregations