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); } }
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); } }
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); } }
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); } }
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); } }
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); }
public CopySpec filesMatching(Iterable<String> patterns, Action<? super FileCopyDetails> action) { if (!patterns.iterator().hasNext()) { throw new InvalidUserDataException("must provide at least one pattern to match"); } List<Spec> matchers = new ArrayList<Spec>(); for (String pattern : patterns) { matchers.add(PatternMatcherFactory.getPatternMatcher(true, isCaseSensitive(), pattern)); } Spec unionMatcher = Specs.union(matchers.toArray(new Spec[matchers.size()])); return eachFile(new MatchingCopyAction(unionMatcher, action)); }
public CopySpec filesNotMatching(Iterable<String> patterns, Action<? super FileCopyDetails> action) { if (!patterns.iterator().hasNext()) { throw new InvalidUserDataException("must provide at least one pattern to not match"); } List<Spec> matchers = new ArrayList<Spec>(); for (String pattern : patterns) { matchers.add(PatternMatcherFactory.getPatternMatcher(true, isCaseSensitive(), pattern)); } Spec unionMatcher = Specs.union(matchers.toArray(new Spec[matchers.size()])); return eachFile(new MatchingCopyAction(Specs.<RelativePath>negate(unionMatcher), action)); }
public CopySpec filter(final Class<? extends FilterReader> filterType) { appendCopyAction(new Action<FileCopyDetails>() { public void execute(FileCopyDetails fileCopyDetails) { fileCopyDetails.filter(filterType); } }); return this; }
public CopySpec filter(final Transformer<String, String> transformer) { appendCopyAction(new Action<FileCopyDetails>() { public void execute(FileCopyDetails fileCopyDetails) { fileCopyDetails.filter(transformer); } }); return this; }
public CopySpec filter(final Map<String, ?> properties, final Class<? extends FilterReader> filterType) { appendCopyAction(new Action<FileCopyDetails>() { public void execute(FileCopyDetails fileCopyDetails) { fileCopyDetails.filter(properties, filterType); } }); return this; }
public CopySpec expand(final Map<String, ?> properties) { appendCopyAction(new Action<FileCopyDetails>() { public void execute(FileCopyDetails fileCopyDetails) { fileCopyDetails.expand(properties); } }); return this; }
public Collection<? extends Action<? super FileCopyDetails>> getAllCopyActions() { if (parentResolver == null) { return copyActions; } List<Action<? super FileCopyDetails>> allActions = new ArrayList<Action<? super FileCopyDetails>>(); allActions.addAll(parentResolver.getAllCopyActions()); allActions.addAll(copyActions); return allActions; }
public void execute(FileCopyDetails fileCopyDetails) { RelativePath path = fileCopyDetails.getRelativePath(); String newName = transformer.transform(path.getLastName()); if (newName != null) { path = path.replaceLastName(newName); fileCopyDetails.setRelativePath(path); } }
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); }
private void writeOriginalFile(FileCopyDetails fileDetails) { String path = fileDetails.getRelativePath().getPathString(); try { ZipEntry archiveEntry = new ZipEntry(path); archiveEntry.setTime(fileDetails.getLastModified()); zipOutStr.putNextEntry(archiveEntry); fileDetails.copyTo(zipOutStr); zipOutStr.closeEntry(); } catch (Exception e) { throw new GradleException(String.format("Could not add %s to ZIP '%s'.", path, zipFile), e); } }
private void writeGzippedFile(FileCopyDetails fileDetails) { String path = fileDetails.getRelativePath().getPathString() + ".gz"; try { ZipEntry archiveEntry = new ZipEntry(path); archiveEntry.setTime(fileDetails.getLastModified()); zipOutStr.putNextEntry(archiveEntry); GZIPOutputStream out = new GZIPOutputStream(zipOutStr, true); fileDetails.copyTo(out); out.finish(); out.flush(); zipOutStr.closeEntry(); } catch (Exception e) { throw new GradleException(String.format("Could not add %s to ZIP '%s'.", path, zipFile), e); } }
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()); zipOutStr.putNextEntry(archiveEntry); zipOutStr.closeEntry(); } catch (Exception e) { throw new GradleException(String.format("Could not add %s to ZIP '%s'.", dirDetails, zipFile), e); } }
private void visitFile(@Nonnull FileCopyDetails fileDetails) { try { JarArchiveEntry archiveEntry = new JarArchiveEntry(fileDetails.getRelativePath().getPathString()); archiveEntry.setTime(fileDetails.getLastModified()); archiveEntry.setUnixMode(UnixStat.FILE_FLAG | fileDetails.getMode()); zipOutStr.putArchiveEntry(archiveEntry); fileDetails.copyTo(zipOutStr); zipOutStr.closeArchiveEntry(); } catch (Exception e) { throw new GradleException(String.format("Could not add %s to ZIP '%s'.", fileDetails, zipFile), e); } }
private void visitDir(@Nonnull FileCopyDetails dirDetails) { try { // Trailing slash in name indicates that entry is a directory JarArchiveEntry archiveEntry = new JarArchiveEntry(dirDetails.getRelativePath().getPathString() + '/'); archiveEntry.setTime(dirDetails.getLastModified()); archiveEntry.setUnixMode(UnixStat.DIR_FLAG | dirDetails.getMode()); zipOutStr.putArchiveEntry(archiveEntry); zipOutStr.closeArchiveEntry(); } catch (Exception e) { throw new GradleException(String.format("Could not add %s to ZIP '%s'.", dirDetails, zipFile), e); } }
public void execute(FileCopyDetails fileCopyDetails) { classList.add(fileCopyDetails.getRelativePath().toString()); }
/** * {@inheritDoc} */ public AbstractCopyTask filesMatching(String pattern, Action<? super FileCopyDetails> action) { getMainSpec().filesMatching(pattern, action); return this; }
/** * {@inheritDoc} */ public AbstractCopyTask filesMatching(Iterable<String> patterns, Action<? super FileCopyDetails> action) { getMainSpec().filesMatching(patterns, action); return this; }
/** * {@inheritDoc} */ public AbstractCopyTask filesNotMatching(String pattern, Action<? super FileCopyDetails> action) { getMainSpec().filesNotMatching(pattern, action); return this; }
/** * {@inheritDoc} */ public AbstractCopyTask filesNotMatching(Iterable<String> patterns, Action<? super FileCopyDetails> action) { getMainSpec().filesNotMatching(patterns, action); return this; }
/** * {@inheritDoc} */ public AbstractCopyTask eachFile(Action<? super FileCopyDetails> action) { getMainSpec().eachFile(action); return this; }
public MatchingCopyAction(Spec<RelativePath> matchSpec, Action<? super FileCopyDetails> toApply) { this.matchSpec = matchSpec; this.toApply = toApply; }
public void execute(FileCopyDetails details) { if (matchSpec.isSatisfiedBy(details.getRelativeSourcePath())) { toApply.execute(details); } }