Search in sources :

Example 1 with LocalResourceAdapter

use of org.gradle.api.resources.internal.LocalResourceAdapter in project gradle by gradle.

the class DefaultFileOperations method tarTree.

public FileTree tarTree(Object tarPath) {
    File tarFile = null;
    ReadableResourceInternal resource;
    if (tarPath instanceof ReadableResourceInternal) {
        resource = (ReadableResourceInternal) tarPath;
    } else if (tarPath instanceof ReadableResource) {
        // custom type
        resource = new UnknownBackingFileReadableResource((ReadableResource) tarPath);
    } else {
        tarFile = file(tarPath);
        resource = new LocalResourceAdapter(new LocalFileStandInExternalResource(tarFile, fileSystem));
    }
    TarFileTree tarTree = new TarFileTree(tarFile, new MaybeCompressedFileResource(resource), getExpandDir(), fileSystem, fileSystem, directoryFileTreeFactory, streamHasher);
    return new FileTreeAdapter(tarTree, fileResolver.getPatternSetFactory());
}
Also used : ReadableResource(org.gradle.api.resources.ReadableResource) LocalResourceAdapter(org.gradle.api.resources.internal.LocalResourceAdapter) LocalFileStandInExternalResource(org.gradle.internal.resource.local.LocalFileStandInExternalResource) TarFileTree(org.gradle.api.internal.file.archive.TarFileTree) ReadableResourceInternal(org.gradle.api.resources.internal.ReadableResourceInternal) FileTreeAdapter(org.gradle.api.internal.file.collections.FileTreeAdapter) File(java.io.File)

Example 2 with LocalResourceAdapter

use of org.gradle.api.resources.internal.LocalResourceAdapter in project gradle by gradle.

the class TarFileTreeTest method readsGzippedTarFile.

@Test
public void readsGzippedTarFile() {
    TestFile tgz = tmpDir.getTestDirectory().file("test.tgz");
    rootDir.file("subdir/file1.txt").write("content");
    rootDir.file("subdir2/file2.txt").write("content");
    rootDir.tgzTo(tgz);
    MaybeCompressedFileResource resource = new MaybeCompressedFileResource(new LocalResourceAdapter(TestFiles.fileRepository().localResource(tgz)));
    TarFileTree tree = new TarFileTree(tarFile, resource, expandDir, fileSystem(), fileSystem(), directoryFileTreeFactory(), streamHasher());
    assertVisits(tree, toList("subdir/file1.txt", "subdir2/file2.txt"), toList("subdir", "subdir2"));
    assertSetContainsForAllTypes(tree, toList("subdir/file1.txt", "subdir2/file2.txt"));
}
Also used : MaybeCompressedFileResource(org.gradle.api.internal.file.MaybeCompressedFileResource) LocalResourceAdapter(org.gradle.api.resources.internal.LocalResourceAdapter) TestFile(org.gradle.test.fixtures.file.TestFile) Test(org.junit.Test)

Example 3 with LocalResourceAdapter

use of org.gradle.api.resources.internal.LocalResourceAdapter in project gradle by gradle.

the class TarFileTreeTest method readsBzippedTarFile.

@Test
public void readsBzippedTarFile() {
    TestFile tbz2 = tmpDir.getTestDirectory().file("test.tbz2");
    rootDir.file("subdir/file1.txt").write("content");
    rootDir.file("subdir2/file2.txt").write("content");
    rootDir.tbzTo(tbz2);
    MaybeCompressedFileResource resource = new MaybeCompressedFileResource(new LocalResourceAdapter(TestFiles.fileRepository().localResource(tbz2)));
    TarFileTree tree = new TarFileTree(tarFile, resource, expandDir, fileSystem(), fileSystem(), directoryFileTreeFactory(), streamHasher());
    assertVisits(tree, toList("subdir/file1.txt", "subdir2/file2.txt"), toList("subdir", "subdir2"));
    assertSetContainsForAllTypes(tree, toList("subdir/file1.txt", "subdir2/file2.txt"));
}
Also used : MaybeCompressedFileResource(org.gradle.api.internal.file.MaybeCompressedFileResource) LocalResourceAdapter(org.gradle.api.resources.internal.LocalResourceAdapter) TestFile(org.gradle.test.fixtures.file.TestFile) Test(org.junit.Test)

Aggregations

LocalResourceAdapter (org.gradle.api.resources.internal.LocalResourceAdapter)3 MaybeCompressedFileResource (org.gradle.api.internal.file.MaybeCompressedFileResource)2 TestFile (org.gradle.test.fixtures.file.TestFile)2 Test (org.junit.Test)2 File (java.io.File)1 TarFileTree (org.gradle.api.internal.file.archive.TarFileTree)1 FileTreeAdapter (org.gradle.api.internal.file.collections.FileTreeAdapter)1 ReadableResource (org.gradle.api.resources.ReadableResource)1 ReadableResourceInternal (org.gradle.api.resources.internal.ReadableResourceInternal)1 LocalFileStandInExternalResource (org.gradle.internal.resource.local.LocalFileStandInExternalResource)1