use of org.codehaus.plexus.archiver.ArchiverException in project alfresco-maven by Acosix.
the class AmpUnArchiver method validate.
/**
* {@inheritDoc}
*/
@Override
protected void validate(final String path, final File outputDirectory) throws ArchiverException {
// for some reason there is an empty validation impl in base class(es)
final File sourceFile = this.getSourceFile();
if (sourceFile == null) {
throw new ArchiverException("The source file isn't defined.");
}
if (sourceFile.isDirectory()) {
throw new ArchiverException("The source must not be a directory.");
}
if (!sourceFile.exists()) {
throw new ArchiverException("The source file " + sourceFile + " doesn't exist.");
}
File destDirectory = this.getDestDirectory();
File destFile = this.getDestFile();
if (destDirectory == null && destFile == null) {
throw new ArchiverException("The destination isn't defined.");
}
if (destDirectory != null && destFile != null) {
throw new ArchiverException("You must choose between a destination directory and a destination file.");
}
if (destDirectory != null && !destDirectory.isDirectory()) {
this.setDestFile(destDirectory);
this.setDestDirectory(null);
destFile = destDirectory;
destDirectory = null;
}
if (destFile != null && destFile.isDirectory()) {
this.setDestDirectory(destFile);
this.setDestFile(null);
destDirectory = destFile;
destFile = null;
}
this.validateAlfrescoModuleMetadata();
}
use of org.codehaus.plexus.archiver.ArchiverException in project alfresco-maven by Acosix.
the class ModuleDependencyImpl method buildVersionRanges.
private static List<VersionRange> buildVersionRanges(final String versionStr) {
final List<VersionRange> versionRanges = new ArrayList<>(1);
final StringTokenizer rangesTokenizer = new StringTokenizer(versionStr, ",");
while (rangesTokenizer.hasMoreTokens()) {
String range = rangesTokenizer.nextToken().trim();
if (range.equals("*")) {
range = "*-*";
}
if (range.startsWith("-")) {
range = "*" + range;
}
if (range.endsWith("-")) {
range = range + "*";
}
final StringTokenizer rangeTokenizer = new StringTokenizer(range, "-", false);
ComparableVersion versionLower = null;
ComparableVersion versionUpper = null;
while (rangeTokenizer.hasMoreTokens()) {
String version = rangeTokenizer.nextToken();
version = version.trim();
if (versionLower == null) {
if (version.equals("*")) {
versionLower = ModuleDetails.VERSION_ZERO;
} else {
versionLower = new ComparableVersion(version);
}
} else if (versionUpper == null) {
if (version.equals("*")) {
versionUpper = ModuleDetails.VERSION_BIG;
} else {
versionUpper = new ComparableVersion(version);
}
}
}
// Check
if (versionUpper == null && versionLower == null) {
throw new ArchiverException("Valid dependency version ranges are: \n" + " LOW - HIGH \n" + " * - HIGH \n" + " LOW - * \n" + " * ");
} else if (versionUpper == null && versionLower != null) {
versionUpper = versionLower;
} else if (versionLower == null && versionUpper != null) {
versionLower = versionUpper;
}
versionRanges.add(new VersionRange(versionLower, versionUpper));
}
return versionRanges;
}
use of org.codehaus.plexus.archiver.ArchiverException in project tis by qlangtech.
the class AbstractHpiMojo method unpack.
/**
* Unpacks the archive file.
*
* @param file File to be unpacked.
* @param location Location where to put the unpacked files.
*/
private void unpack(File file, File location) throws MojoExecutionException, NoSuchArchiverException {
String archiveExt = FileUtils.getExtension(file.getAbsolutePath()).toLowerCase();
try {
UnArchiver unArchiver = archiverManager.getUnArchiver(archiveExt);
unArchiver.setSourceFile(file);
unArchiver.setDestDirectory(location);
unArchiver.extract();
} catch (IOException e) {
throw new MojoExecutionException("Error unpacking file: " + file + "to: " + location, e);
} catch (ArchiverException e) {
throw new MojoExecutionException("Error unpacking file: " + file + "to: " + location, e);
}
}
use of org.codehaus.plexus.archiver.ArchiverException in project conga by wcm-io-devops.
the class PackageMojo method buildZipFile.
/**
* Build JAR file with definitions.
* @param contentDirectory Content directory for JAR file
* @return JAR file
*/
private File buildZipFile(File contentDirectory, String classifier) throws MojoExecutionException {
File zipFile = new File(getProject().getBuild().getDirectory(), buildZipFileName(classifier));
String basePath = toZipDirectoryPath(contentDirectory);
addZipDirectory(basePath, contentDirectory);
zipArchiver.setDestFile(zipFile);
try {
zipArchiver.createArchive();
} catch (ArchiverException | IOException ex) {
throw new MojoExecutionException("Unable to build file " + zipFile.getPath() + ": " + ex.getMessage(), ex);
}
return zipFile;
}
use of org.codehaus.plexus.archiver.ArchiverException in project myfaces-build-tools by apache.
the class JSDocJarMojo method generateArchive.
// ----------------------------------------------------------------------
// private methods
// ----------------------------------------------------------------------
/**
* Method that creates the jar file
*
* @param jsdocFiles the directory where the generated jar file will be put
* @param jarFileName the filename of the generated jar file
* @return a File object that contains the generated jar file
* @throws ArchiverException if any
* @throws IOException if any
*/
private File generateArchive(File jsdocFiles, String jarFileName) throws ArchiverException, IOException {
File jsdocJar = new File(jarOutputDirectory, jarFileName);
if (jsdocJar.exists()) {
jsdocJar.delete();
}
MavenArchiver archiver = new MavenArchiver();
archiver.setArchiver(jarArchiver);
archiver.setOutputFile(jsdocJar);
File contentDirectory = jsdocFiles;
if (!contentDirectory.exists()) {
getLog().warn("JAR will be empty - no content was marked for inclusion!");
} else {
archiver.getArchiver().addDirectory(contentDirectory, DEFAULT_INCLUDES, DEFAULT_EXCLUDES);
}
List<Resource> resources = project.getBuild().getResources();
for (Resource r : resources) {
if (r.getDirectory().endsWith("maven-shared-archive-resources")) {
archiver.getArchiver().addDirectory(new File(r.getDirectory()));
}
}
if (useDefaultManifestFile && defaultManifestFile.exists() && archive.getManifestFile() == null) {
getLog().info("Adding existing MANIFEST to archive. Found under: " + defaultManifestFile.getPath());
archive.setManifestFile(defaultManifestFile);
}
try {
// we don't want Maven stuff
archive.setAddMavenDescriptor(false);
archiver.createArchive(project, archive);
} catch (ManifestException e) {
throw new ArchiverException("ManifestException: " + e.getMessage(), e);
} catch (DependencyResolutionRequiredException e) {
throw new ArchiverException("DependencyResolutionRequiredException: " + e.getMessage(), e);
}
return jsdocJar;
}
Aggregations