org.codehaus.plexus.archiver.manager.NoSuchArchiverException Java Examples

The following examples show how to use org.codehaus.plexus.archiver.manager.NoSuchArchiverException. 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: StagerMojo.java    From helidon-build-tools with Apache License 2.0 6 votes vote down vote up
@Override
public void unpack(Path archive, Path target, String excludes, String includes) {
    File archiveFile = archive.toFile();
    UnArchiver unArchiver = null;
    try {
        unArchiver = archiverManager.getUnArchiver(archiveFile);
    } catch (NoSuchArchiverException ex) {
        throw new IllegalStateException(ex);
    }
    unArchiver.setSourceFile(archiveFile);
    unArchiver.setDestDirectory(target.toFile());
    if (StringUtils.isNotEmpty(excludes) || StringUtils.isNotEmpty(includes)) {
        IncludeExcludeFileSelector[] selectors = new IncludeExcludeFileSelector[]{
                new IncludeExcludeFileSelector()
        };
        if (StringUtils.isNotEmpty(excludes)) {
            selectors[0].setExcludes(excludes.split(","));
        }
        if (StringUtils.isNotEmpty(includes)) {
            selectors[0].setIncludes(includes.split(","));
        }
        unArchiver.setFileSelectors(selectors);
    }
    unArchiver.extract();
}
 
Example #2
Source File: FakeTimeMojo.java    From faketime with MIT License 6 votes vote down vote up
private void unpackAgent() {
  try {
    Artifact artifact = artifactResolver.resolveArtifact(session.getProjectBuildingRequest(), getAgentArtifactCoordinate()).getArtifact();

    getTargetDirectory().mkdirs();

    UnArchiver unArchiver = archiverManager.getUnArchiver(artifact.getType());
    unArchiver.setSourceFile(artifact.getFile());
    unArchiver.setDestDirectory(getTargetDirectory());
    unArchiver.setFileSelectors(getAgentBinaryFileSelector());
    unArchiver.extract();
  }
  catch (ArtifactResolverException | NoSuchArchiverException e) {
    throw new RuntimeException(e);
  }
}
 
Example #3
Source File: DockerAssemblyManager.java    From docker-maven-plugin with Apache License 2.0 6 votes vote down vote up
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 #4
Source File: TarsBuildMojo.java    From TarsJava with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * extract specified artifact. 
 *  
 * @param destination destination folder 
 * @param artifactFile 
 * @throws NoSuchArchiverException 
 * @throws ArchiverException 
 * @throws MojoExecutionException 
 */
private void unArchiveArtifact(final File destination, final File artifactFile) throws MojoExecutionException, IOException {
    try {
        final UnArchiver unArchiver = archiverManager.getUnArchiver(artifactFile);
        unArchiver.setSourceFile(artifactFile);
        unArchiver.setDestDirectory(destination);
        unArchiver.setOverwrite(true);
        unArchiver.extract();
    } catch (final NoSuchArchiverException | ArchiverException e) {
        throw new MojoExecutionException("Unable to unarchive " + artifactFile.getName(), e);
    }
}
 
Example #5
Source File: ArkPluginMojo.java    From sofa-ark with Apache License 2.0 2 votes vote down vote up
/**
 * create a zip archiver
 *
 * @return a un-compress zip archiver
 * @throws NoSuchArchiverException
 */
protected Archiver getArchiver() throws NoSuchArchiverException {
    Archiver archiver = archiverManager.getArchiver(ARCHIVE_MODE);
    ((AbstractZipArchiver) archiver).setCompress(false);
    return archiver;
}