Java Code Examples for org.codehaus.plexus.archiver.tar.TarArchiver#setLongfile()
The following examples show how to use
org.codehaus.plexus.archiver.tar.TarArchiver#setLongfile() .
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: DockerAssemblyManager.java From docker-maven-plugin with Apache License 2.0 | 6 votes |
private TarArchiver createBuildArchiver(File outputDir, File archive, AssemblyConfiguration assemblyConfig) throws NoSuchArchiverException { TarArchiver archiver = (TarArchiver) archiverManager.getArchiver("tar"); archiver.setLongfile(TarLongFileMode.posix); AssemblyMode mode = assemblyConfig != null ? assemblyConfig.getMode() : null; if (mode != null && mode.isArchive()) { DefaultArchivedFileSet archiveSet = DefaultArchivedFileSet.archivedFileSet(new File(outputDir, assemblyConfig.getName() + "." + mode.getExtension())); archiveSet.setPrefix(assemblyConfig.getName() + "/"); archiveSet.setIncludingEmptyDirectories(true); archiveSet.setUsingDefaultExcludes(false); archiver.addArchivedFileSet(archiveSet); } else { DefaultFileSet fileSet = DefaultFileSet.fileSet(outputDir); fileSet.setUsingDefaultExcludes(false); archiver.addFileSet(fileSet); } archiver.setDestFile(archive); return archiver; }
Example 2
Source File: MavenUtil.java From jkube with Eclipse Public License 2.0 | 5 votes |
public static void createArchive(File sourceDir, File destinationFile, TarArchiver archiver) throws IOException { try { archiver.setCompression(TarArchiver.TarCompressionMethod.gzip); archiver.setLongfile(TarLongFileMode.posix); archiver.addDirectory(sourceDir); archiver.setDestFile(destinationFile); archiver.createArchive(); } catch (IOException e) { throw new IOException("Failed to create archive " + destinationFile + ": " + e, e); } }
Example 3
Source File: AllFilesExecCustomizer.java From docker-maven-plugin with Apache License 2.0 | 5 votes |
@Override public TarArchiver customize(TarArchiver archiver) throws IOException { log.warn("/--------------------- SECURITY WARNING ---------------------\\"); log.warn("|You are building a Docker image with normalized permissions.|"); log.warn("|All files and directories added to build context will have |"); log.warn("|'-rwxr-xr-x' permissions. It is recommended to double check |"); log.warn("|and reset permissions for sensitive files and directories. |"); log.warn("\\------------------------------------------------------------/"); TarArchiver newArchiver = new TarArchiver(); newArchiver.setDestFile(archiver.getDestFile()); newArchiver.setLongfile(TarLongFileMode.posix); ResourceIterator resources = archiver.getResources(); while (resources.hasNext()) { ArchiveEntry ae = resources.next(); String fileName = ae.getName(); PlexusIoResource resource = ae.getResource(); String name = StringUtils.replace(fileName, File.separatorChar, '/'); // See docker source: // https://github.com/docker/docker/blob/3d13fddd2bc4d679f0eaa68b0be877e5a816ad53/pkg/archive/archive_windows.go#L45 int mode = ae.getMode() & 0777; int newMode = mode; newMode &= 0755; newMode |= 0111; if (newMode != mode) { log.debug("Changing permissions of '%s' from %o to %o.", name, mode, newMode); } newArchiver.addResource(resource, name, newMode); } archiver = newArchiver; return archiver; }