org.gradle.api.file.FileCopyDetails Java Examples

The following examples show how to use org.gradle.api.file.FileCopyDetails. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LibraryCache.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
public static void unzipAar(final File bundle, final File folderOut, final Project project) throws IOException {
    FileUtils.deleteFolder(folderOut);
    folderOut.mkdirs();
    project.copy(new Action<CopySpec>() {
        @Override
        public void execute(CopySpec copySpec) {
            copySpec.from(project.zipTree(bundle));
            copySpec.into(new Object[]{folderOut});
            copySpec.filesMatching("**/*.jar", new Action<FileCopyDetails>() {
                @Override
                public void execute(FileCopyDetails details) {
                    setRelativePath(details, new RelativePath(false, FD_JARS).plus(details.getRelativePath()));
                }
            });
        }
    });
}
 
Example #2
Source File: JavaGradlePluginPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void execute(FileCopyDetails fileCopyDetails) {
    PluginDescriptor descriptor;
    try {
        descriptor = new PluginDescriptor(fileCopyDetails.getFile().toURI().toURL());
    } catch (MalformedURLException e) {
        // Not sure under what scenario (if any) this would occur,
        // but there's no sense in collecting the descriptor if it does.
        return;
    }
    if (descriptor.getImplementationClassName() != null) {
        descriptors.add(descriptor);
    }
}
 
Example #3
Source File: CopyFileVisitorImpl.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void processFile(FileVisitDetails visitDetails) {
    DefaultFileCopyDetails details = createDefaultFileCopyDetails(visitDetails);
    for (Action<? super FileCopyDetails> action : spec.getAllCopyActions()) {
        action.execute(details);
        if (details.isExcluded()) {
            return;
        }
    }
    action.processFile(details);
}
 
Example #4
Source File: ZipCopyAction.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void visitDir(FileCopyDetails dirDetails) {
    try {
        // Trailing slash in name indicates that entry is a directory
        ZipEntry archiveEntry = new ZipEntry(dirDetails.getRelativePath().getPathString() + '/');
        archiveEntry.setTime(dirDetails.getLastModified());
        archiveEntry.setUnixMode(UnixStat.DIR_FLAG | dirDetails.getMode());
        zipOutStr.putNextEntry(archiveEntry);
        zipOutStr.closeEntry();
    } catch (Exception e) {
        throw new GradleException(String.format("Could not add %s to ZIP '%s'.", dirDetails, zipFile), e);
    }
}
 
Example #5
Source File: ZipCopyAction.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void visitFile(FileCopyDetails fileDetails) {
    try {
        ZipEntry archiveEntry = new ZipEntry(fileDetails.getRelativePath().getPathString());
        archiveEntry.setTime(fileDetails.getLastModified());
        archiveEntry.setUnixMode(UnixStat.FILE_FLAG | fileDetails.getMode());
        zipOutStr.putNextEntry(archiveEntry);
        fileDetails.copyTo(zipOutStr);
        zipOutStr.closeEntry();
    } catch (Exception e) {
        throw new GradleException(String.format("Could not add %s to ZIP '%s'.", fileDetails, zipFile), e);
    }
}
 
Example #6
Source File: TarCopyAction.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void visitDir(FileCopyDetails dirDetails) {
    try {
        // Trailing slash on name indicates entry is a directory
        TarEntry archiveEntry = new TarEntry(dirDetails.getRelativePath().getPathString() + '/');
        archiveEntry.setModTime(dirDetails.getLastModified());
        archiveEntry.setMode(UnixStat.DIR_FLAG | dirDetails.getMode());
        tarOutStr.putNextEntry(archiveEntry);
        tarOutStr.closeEntry();
    } catch (Exception e) {
        throw new GradleException(String.format("Could not add %s to TAR '%s'.", dirDetails, tarFile), e);
    }
}
 
Example #7
Source File: TarCopyAction.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void visitFile(FileCopyDetails fileDetails) {
    try {
        TarEntry archiveEntry = new TarEntry(fileDetails.getRelativePath().getPathString());
        archiveEntry.setModTime(fileDetails.getLastModified());
        archiveEntry.setSize(fileDetails.getSize());
        archiveEntry.setMode(UnixStat.FILE_FLAG | fileDetails.getMode());
        tarOutStr.putNextEntry(archiveEntry);
        fileDetails.copyTo(tarOutStr);
        tarOutStr.closeEntry();
    } catch (Exception e) {
        throw new GradleException(String.format("Could not add %s to TAR '%s'.", fileDetails, tarFile), e);
    }
}
 
Example #8
Source File: CopyFileVisitorImpl.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void processFile(FileVisitDetails visitDetails) {
    DefaultFileCopyDetails details = createDefaultFileCopyDetails(visitDetails);
    for (Action<? super FileCopyDetails> action : copySpecResolver.getAllCopyActions()) {
        action.execute(details);
        if (details.isExcluded()) {
            return;
        }
    }
    action.processFile(details);
}
 
Example #9
Source File: ZipCopyAction.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void visitDir(FileCopyDetails dirDetails) {
    try {
        // Trailing slash in name indicates that entry is a directory
        ZipEntry archiveEntry = new ZipEntry(dirDetails.getRelativePath().getPathString() + '/');
        archiveEntry.setTime(dirDetails.getLastModified());
        archiveEntry.setUnixMode(UnixStat.DIR_FLAG | dirDetails.getMode());
        zipOutStr.putNextEntry(archiveEntry);
        zipOutStr.closeEntry();
    } catch (Exception e) {
        throw new GradleException(String.format("Could not add %s to ZIP '%s'.", dirDetails, zipFile), e);
    }
}
 
Example #10
Source File: ZipCopyAction.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void visitFile(FileCopyDetails fileDetails) {
    try {
        ZipEntry archiveEntry = new ZipEntry(fileDetails.getRelativePath().getPathString());
        archiveEntry.setTime(fileDetails.getLastModified());
        archiveEntry.setUnixMode(UnixStat.FILE_FLAG | fileDetails.getMode());
        zipOutStr.putNextEntry(archiveEntry);
        fileDetails.copyTo(zipOutStr);
        zipOutStr.closeEntry();
    } catch (Exception e) {
        throw new GradleException(String.format("Could not add %s to ZIP '%s'.", fileDetails, zipFile), e);
    }
}
 
Example #11
Source File: TarCopyAction.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void visitDir(FileCopyDetails dirDetails) {
    try {
        // Trailing slash on name indicates entry is a directory
        TarEntry archiveEntry = new TarEntry(dirDetails.getRelativePath().getPathString() + '/');
        archiveEntry.setModTime(dirDetails.getLastModified());
        archiveEntry.setMode(UnixStat.DIR_FLAG | dirDetails.getMode());
        tarOutStr.putNextEntry(archiveEntry);
        tarOutStr.closeEntry();
    } catch (Exception e) {
        throw new GradleException(String.format("Could not add %s to TAR '%s'.", dirDetails, tarFile), e);
    }
}
 
Example #12
Source File: TarCopyAction.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void visitFile(FileCopyDetails fileDetails) {
    try {
        TarEntry archiveEntry = new TarEntry(fileDetails.getRelativePath().getPathString());
        archiveEntry.setModTime(fileDetails.getLastModified());
        archiveEntry.setSize(fileDetails.getSize());
        archiveEntry.setMode(UnixStat.FILE_FLAG | fileDetails.getMode());
        tarOutStr.putNextEntry(archiveEntry);
        fileDetails.copyTo(tarOutStr);
        tarOutStr.closeEntry();
    } catch (Exception e) {
        throw new GradleException(String.format("Could not add %s to TAR '%s'.", fileDetails, tarFile), e);
    }
}
 
Example #13
Source File: JavaGradlePluginPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void execute(FileCopyDetails fileCopyDetails) {
    PluginDescriptor descriptor;
    try {
        descriptor = new PluginDescriptor(fileCopyDetails.getFile().toURI().toURL());
    } catch (MalformedURLException e) {
        // Not sure under what scenario (if any) this would occur,
        // but there's no sense in collecting the descriptor if it does.
        return;
    }
    if (descriptor.getImplementationClassName() != null) {
        descriptors.add(descriptor);
    }
}
 
Example #14
Source File: CopyFileVisitorImpl.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void processFile(FileVisitDetails visitDetails) {
    DefaultFileCopyDetails details = createDefaultFileCopyDetails(visitDetails);
    for (Action<? super FileCopyDetails> action : spec.getAllCopyActions()) {
        action.execute(details);
        if (details.isExcluded()) {
            return;
        }
    }
    action.processFile(details);
}
 
Example #15
Source File: ZipCopyAction.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void visitFile(FileCopyDetails fileDetails) {
    try {
        ZipEntry archiveEntry = new ZipEntry(fileDetails.getRelativePath().getPathString());
        archiveEntry.setTime(fileDetails.getLastModified());
        archiveEntry.setUnixMode(UnixStat.FILE_FLAG | fileDetails.getMode());
        zipOutStr.putNextEntry(archiveEntry);
        fileDetails.copyTo(zipOutStr);
        zipOutStr.closeEntry();
    } catch (Exception e) {
        throw new GradleException(String.format("Could not add %s to ZIP '%s'.", fileDetails, zipFile), e);
    }
}
 
Example #16
Source File: TarCopyAction.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void visitDir(FileCopyDetails dirDetails) {
    try {
        // Trailing slash on name indicates entry is a directory
        TarEntry archiveEntry = new TarEntry(dirDetails.getRelativePath().getPathString() + '/');
        archiveEntry.setModTime(dirDetails.getLastModified());
        archiveEntry.setMode(UnixStat.DIR_FLAG | dirDetails.getMode());
        tarOutStr.putNextEntry(archiveEntry);
        tarOutStr.closeEntry();
    } catch (Exception e) {
        throw new GradleException(String.format("Could not add %s to TAR '%s'.", dirDetails, tarFile), e);
    }
}
 
Example #17
Source File: TarCopyAction.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void visitFile(FileCopyDetails fileDetails) {
    try {
        TarEntry archiveEntry = new TarEntry(fileDetails.getRelativePath().getPathString());
        archiveEntry.setModTime(fileDetails.getLastModified());
        archiveEntry.setSize(fileDetails.getSize());
        archiveEntry.setMode(UnixStat.FILE_FLAG | fileDetails.getMode());
        tarOutStr.putNextEntry(archiveEntry);
        fileDetails.copyTo(tarOutStr);
        tarOutStr.closeEntry();
    } catch (Exception e) {
        throw new GradleException(String.format("Could not add %s to TAR '%s'.", fileDetails, tarFile), e);
    }
}
 
Example #18
Source File: TarCopyAction.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void visitFile(FileCopyDetails fileDetails) {
    try {
        TarEntry archiveEntry = new TarEntry(fileDetails.getRelativePath().getPathString());
        archiveEntry.setModTime(fileDetails.getLastModified());
        archiveEntry.setSize(fileDetails.getSize());
        archiveEntry.setMode(UnixStat.FILE_FLAG | fileDetails.getMode());
        tarOutStr.putNextEntry(archiveEntry);
        fileDetails.copyTo(tarOutStr);
        tarOutStr.closeEntry();
    } catch (Exception e) {
        throw new GradleException(String.format("Could not add %s to TAR '%s'.", fileDetails, tarFile), e);
    }
}
 
Example #19
Source File: TarCopyAction.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void visitDir(FileCopyDetails dirDetails) {
    try {
        // Trailing slash on name indicates entry is a directory
        TarEntry archiveEntry = new TarEntry(dirDetails.getRelativePath().getPathString() + '/');
        archiveEntry.setModTime(dirDetails.getLastModified());
        archiveEntry.setMode(UnixStat.DIR_FLAG | dirDetails.getMode());
        tarOutStr.putNextEntry(archiveEntry);
        tarOutStr.closeEntry();
    } catch (Exception e) {
        throw new GradleException(String.format("Could not add %s to TAR '%s'.", dirDetails, tarFile), e);
    }
}
 
Example #20
Source File: ZipCopyAction.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void visitFile(FileCopyDetails fileDetails) {
    try {
        ZipEntry archiveEntry = new ZipEntry(fileDetails.getRelativePath().getPathString());
        archiveEntry.setTime(fileDetails.getLastModified());
        archiveEntry.setUnixMode(UnixStat.FILE_FLAG | fileDetails.getMode());
        zipOutStr.putNextEntry(archiveEntry);
        fileDetails.copyTo(zipOutStr);
        zipOutStr.closeEntry();
    } catch (Exception e) {
        throw new GradleException(String.format("Could not add %s to ZIP '%s'.", fileDetails, zipFile), e);
    }
}
 
Example #21
Source File: CopyFileVisitorImpl.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void processFile(FileVisitDetails visitDetails) {
    DefaultFileCopyDetails details = createDefaultFileCopyDetails(visitDetails);
    for (Action<? super FileCopyDetails> action : copySpecResolver.getAllCopyActions()) {
        action.execute(details);
        if (details.isExcluded()) {
            return;
        }
    }
    action.processFile(details);
}
 
Example #22
Source File: ZipCopyAction.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void visitDir(FileCopyDetails dirDetails) {
    try {
        // Trailing slash in name indicates that entry is a directory
        ZipEntry archiveEntry = new ZipEntry(dirDetails.getRelativePath().getPathString() + '/');
        archiveEntry.setTime(dirDetails.getLastModified());
        archiveEntry.setUnixMode(UnixStat.DIR_FLAG | dirDetails.getMode());
        zipOutStr.putNextEntry(archiveEntry);
        zipOutStr.closeEntry();
    } catch (Exception e) {
        throw new GradleException(String.format("Could not add %s to ZIP '%s'.", dirDetails, zipFile), e);
    }
}
 
Example #23
Source File: ZipCopyAction.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void visitDir(FileCopyDetails dirDetails) {
    try {
        // Trailing slash in name indicates that entry is a directory
        ZipEntry archiveEntry = new ZipEntry(dirDetails.getRelativePath().getPathString() + '/');
        archiveEntry.setTime(dirDetails.getLastModified());
        archiveEntry.setUnixMode(UnixStat.DIR_FLAG | dirDetails.getMode());
        zipOutStr.putNextEntry(archiveEntry);
        zipOutStr.closeEntry();
    } catch (Exception e) {
        throw new GradleException(String.format("Could not add %s to ZIP '%s'.", dirDetails, zipFile), e);
    }
}
 
Example #24
Source File: MatchingCopyAction.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public MatchingCopyAction(Spec<RelativePath> matchSpec, Action<? super FileCopyDetails> toApply) {
    this.matchSpec = matchSpec;
    this.toApply = toApply;
}
 
Example #25
Source File: RenamingCopyAction.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void execute(FileCopyDetails fileCopyDetails) {
    RelativePath path = fileCopyDetails.getRelativePath();
    path = path.replaceLastName(transformer.transform(path.getLastName()));
    fileCopyDetails.setRelativePath(path);
}
 
Example #26
Source File: StartScriptsMutator.java    From gradle-modules-plugin with MIT License 4 votes vote down vote up
private void updateRelativePath(FileCopyDetails fileCopyDetails) {
    RelativePath updatedRelativePath = fileCopyDetails.getRelativePath().getParent().getParent()
            .append(true, "patchlibs", fileCopyDetails.getName());
    fileCopyDetails.setRelativePath(updatedRelativePath);
}
 
Example #27
Source File: MatchingCopyAction.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void execute(FileCopyDetails details) {
    if (matchSpec.isSatisfiedBy(details.getRelativePath())) {
        toApply.execute(details);
    }
}
 
Example #28
Source File: MatchingCopyAction.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public MatchingCopyAction(Spec<RelativePath> matchSpec, Action<? super FileCopyDetails> toApply) {
    this.matchSpec = matchSpec;
    this.toApply = toApply;
}
 
Example #29
Source File: JavaGradlePluginPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void execute(FileCopyDetails fileCopyDetails) {
    classList.add(fileCopyDetails.getRelativePath().toString());
}
 
Example #30
Source File: RenamingCopyAction.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void execute(FileCopyDetails fileCopyDetails) {
    RelativePath path = fileCopyDetails.getRelativePath();
    path = path.replaceLastName(transformer.transform(path.getLastName()));
    fileCopyDetails.setRelativePath(path);
}