private void extractApksources(File apksourcesFile) throws MojoExecutionException { if (apksourcesFile.isDirectory()) { getLog() .warn( "The apksources artifact points to '" + apksourcesFile + "' which is a directory; skipping unpacking it."); return; } final UnArchiver unArchiver = new ZipUnArchiver(apksourcesFile) { @Override protected Logger getLogger() { return new ConsoleLogger(Logger.LEVEL_DEBUG, "dependencies-unarchiver"); } }; extractedDependenciesDirectory.mkdirs(); unArchiver.setDestDirectory(extractedDependenciesDirectory); try { unArchiver.extract(); } catch (ArchiverException e) { throw new MojoExecutionException( "ArchiverException while extracting " + apksourcesFile.getAbsolutePath() + ". Message: " + e.getLocalizedMessage(), e); } }
protected void addNonArchiveDependency( final Artifact depArtifact, final MavenProject depProject, final DependencySet dependencySet, final Archiver archiver, final AssemblerConfigurationSource configSource) throws AssemblyFormattingException, ArchiveCreationException { final File source = depArtifact.getFile(); String outputDirectory = dependencySet.getOutputDirectory(); outputDirectory = AssemblyFormatUtils.getOutputDirectory( outputDirectory, configSource.getProject(), moduleProject, depProject, depProject.getBuild().getFinalName(), configSource); final String destName = AssemblyFormatUtils.evaluateFileNameMapping( dependencySet.getOutputFileNameMapping(), depArtifact, configSource.getProject(), moduleProject, moduleArtifact, depProject, configSource); String target; // omit the last char if ends with / or \\ if (outputDirectory.endsWith("/") || outputDirectory.endsWith("\\")) { target = outputDirectory + destName; } else { target = outputDirectory + "/" + destName; } try { final int mode = TypeConversionUtils.modeToInt(dependencySet.getFileMode(), logger); if (mode > -1) { archiver.addFile(source, target, mode); } else { archiver.addFile(source, target); } } catch (final ArchiverException e) { throw new ArchiveCreationException("Error adding file to archive: " + e.getMessage(), e); } }