@Override public void execute() throws MojoExecutionException, MojoFailureException { // // Fetch the latest wrapper archive // Unpack it in the current working project // Possibly interpolate the latest version of Maven in the wrapper properties // File localRepository = new File(System.getProperty("user.home"), ".m2/repository"); String artifactPath = String.format("io/takari/maven-wrapper/%s/maven-wrapper-%s.tar.gz", version, version); String wrapperUrl = String.format("https://repo1.maven.org/maven2/%s", artifactPath); File destination = new File(localRepository, artifactPath); Downloader downloader = new DefaultDownloader("mvnw", version); try { downloader.download(new URI(wrapperUrl), destination); UnArchiver unarchiver = UnArchiver.builder().useRoot(false).build(); Path rootDirectory = Paths.get(session.getExecutionRootDirectory()); unarchiver.unarchive(destination, rootDirectory.toFile()); overwriteDistributionUrl(rootDirectory, getDistributionUrl()); getLog().info(""); getLog().info("The Maven Wrapper version " + version + " has been successfully setup for your project."); getLog().info("Using Apache Maven " + maven); getLog().info(""); } catch (Exception e) { throw new MojoExecutionException("Error installing the maven-wrapper archive.", e); } }
unarchiver.unarchive(pluginFileWithoutVersion, pluginDirectory);
@Override public void execute(ProvisioningContext context) { if (!outputDirectory.exists()) { outputDirectory.mkdirs(); } File archive = artifact.getFile(); try { UnArchiver unarchiver = UnArchiver.builder() .includes(split(includes)) .excludes(split(excludes)) .useRoot(useRoot) .flatten(flatten) .build(); if (filter) { unarchiver.unarchive(archive, outputDirectory, new StandardFilteringProcessor(context.getVariables())); } else if (mustache) { unarchiver.unarchive(archive, outputDirectory, new MustacheFilteringProcessor(context.getVariables())); } else { unarchiver.unarchive(archive, outputDirectory); } } catch (IOException e) { throw new RuntimeException(e); } }
public void unarchive(File archive, File outputDirectory, UnarchivingEntryProcessor entryProcessor) throws IOException { // // These are the contributions that unpacking this archive is providing // if (outputDirectory.exists() == false) { outputDirectory.mkdirs(); } Source source = ArchiverHelper.getArchiveHandler(archive, posixLongFileMode).getArchiveSource(); for (Entry archiveEntry : source.entries()) { String entryName = archiveEntry.getName(); if (useRoot == false) { entryName = entryName.substring(entryName.indexOf('/') + 1); } if (!selector.include(entryName)) { continue; } // // Process the entry name before any output is created on disk // entryName = entryProcessor.processName(entryName); // // So with an entry we may want to take a set of entry in a set of directories and flatten them // into one directory, or we may want to preserve the directory structure. // if (flatten) { entryName = entryName.substring(entryName.lastIndexOf("/") + 1); } else { if (archiveEntry.isDirectory()) { createDir(new File(outputDirectory, entryName)); continue;
.build(); File unpackDirectory = new File(outputDirectory, "unpack"); unarchiver.unarchive(archive, unpackDirectory);