public void archive(File archive, List<String> sourceDirectories) throws IOException { File[] fileSourceDirectories = new File[sourceDirectories.size()]; for (int i = 0; i < sourceDirectories.size(); i++) { fileSourceDirectories[i] = new File(sourceDirectories.get(i)); } archive(archive, fileSourceDirectories); }
public Archiver build() { return new Archiver(includes, excludes, executables, useRoot, flatten, normalize, prefix, posixLongFileMode); } }
/** * Adds an entry to the Jar file, normalizing the name. * * @param entryName the name of the entry in the Jar file * @param fileName the name of the input file for the entry */ private void addEntry(String entryName, ExtendedArchiveEntry entry, ArchiveOutputStream aos) throws IOException { if (entryName.startsWith("/")) { entryName = entryName.substring(1); } else if (entryName.startsWith("./")) { entryName = entryName.substring(2); } if (normalize) { entry.setTime(newEntryTimeMillis(entryName)); entries.put(entryName, entry); } else { writeEntry(entry, aos); } }
private void archive(File jar, List<Iterable<Entry>> sources) throws IOException { Archiver archiver = Archiver.builder() // .useRoot(false) // .normalize(true) // .build(); archiver.archive(jar, new AggregateSource(sources)); if (logger.isDebugEnabled()) { int size = 0; for (Iterable<?> source : sources) { size += size(source); } logger.debug("Created archive {} with {} entries", jar, size); } }
for (String directoryName : getParentDirectoryNames(entryName)) { if (!paths.containsKey(directoryName)) { paths.put(directoryName, Boolean.FALSE); ExtendedArchiveEntry directoryEntry = archiveHandler.createEntryFor(directoryName, new DirectoryEntry(directoryName), false); addEntry(directoryName, directoryEntry, aos); paths.put(entryName, Boolean.TRUE); ExtendedArchiveEntry archiveEntry = archiveHandler.createEntryFor(entryName, entry, isExecutable); addEntry(entryName, archiveEntry, aos); } else { if (Boolean.TRUE.equals(paths.get(entryName))) { for (Map.Entry<String, ExtendedArchiveEntry> entry : entries.entrySet()) { ExtendedArchiveEntry archiveEntry = entry.getValue(); writeEntry(archiveEntry, aos);
/** * Returns the time for a new Jar file entry in milliseconds since the epoch. Uses {@link JarCreator#DOS_EPOCH_IN_JAVA_TIME} for normalized entries, {@link System#currentTimeMillis()} otherwise. * * @param filename The name of the file for which we are entering the time * @return the time for a new Jar file entry in milliseconds since the epoch. */ private long newEntryTimeMillis(String filename) { return normalize ? normalizedTimestamp(filename) : System.currentTimeMillis(); }
private void archive(File jar, List<Iterable<Entry>> sources) throws IOException { Archiver archiver = Archiver.builder() // .useRoot(false) // .normalize(true) // .build(); archiver.archive(jar, new AggregateSource(sources)); if (logger.isDebugEnabled()) { int size = 0; for (Iterable<?> source : sources) { size += size(source); } logger.debug("Created archive {} with {} entries", jar, size); } }
public void execute(ProvisioningContext context) { ArchiverBuilder builder = Archiver.builder(); if (executable != null) { builder.executable(StringUtils.split(executable, ",")); archiveFile = new File(new File(runtimeDirectory, "../").getCanonicalFile(), name); archiver.archive(archiveFile, runtimeDirectory);
public void archive(File archive, File... sourceDirectories) throws IOException { archive(archive, new DirectorySource(sourceDirectories)); }