use of org.apache.maven.artifact.DependencyResolutionRequiredException in project tycho by eclipse.
the class AbstractSourceJarMojo method packageSources.
protected void packageSources(List<MavenProject> projects) throws MojoExecutionException {
if (project.getArtifact().hasClassifier()) {
getLog().warn("NOT adding sources to artifacts with classifier as Maven only supports one classifier " + "per artifact. Current artifact [" + project.getArtifact().getId() + "] has a [" + project.getArtifact().getClassifier() + "] classifier.");
return;
}
MavenArchiver archiver = createArchiver();
for (Iterator<MavenProject> i = projects.iterator(); i.hasNext(); ) {
MavenProject subProject = getProject(i.next());
if ("pom".equals(subProject.getPackaging())) {
continue;
}
archiveProjectContent(subProject, archiver.getArchiver());
}
if (useDefaultManifestFile && defaultManifestFile.exists() && archive.getManifestFile() == null) {
getLog().info("Adding existing MANIFEST to archive. Found under: " + defaultManifestFile.getPath());
archive.setManifestFile(defaultManifestFile);
}
updateSourceManifest(archive);
File outputFile = new File(outputDirectory, finalName + "-" + getClassifier() + getExtension());
try {
archiver.setOutputFile(outputFile);
archive.setAddMavenDescriptor(false);
if (!archive.isForced()) {
// optimized archive creation not supported for now because of build qualifier mismatch issues, see TYCHO-502
getLog().warn("ignoring unsupported archive forced = false parameter.");
archive.setForced(true);
}
archiver.createArchive(project, archive);
} catch (IOException e) {
throw new MojoExecutionException("Error creating source archive: " + e.getMessage(), e);
} catch (ArchiverException e) {
throw new MojoExecutionException("Error creating source archive: " + e.getMessage(), e);
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("Error creating source archive: " + e.getMessage(), e);
} catch (ManifestException e) {
throw new MojoExecutionException("Error creating source archive: " + e.getMessage(), e);
}
if (attach) {
projectHelper.attachArtifact(project, getType(), getClassifier(), outputFile);
} else {
getLog().info("NOT adding java-sources to attached artifacts list.");
}
}
use of org.apache.maven.artifact.DependencyResolutionRequiredException in project tycho by eclipse.
the class PackagePluginMojo method createPluginJar.
private File createPluginJar() throws MojoExecutionException {
try {
MavenArchiver archiver = new MavenArchiver();
archiver.setArchiver(jarArchiver);
File pluginFile = new File(buildDirectory, finalName + ".jar");
if (pluginFile.exists()) {
pluginFile.delete();
}
BuildProperties buildProperties = pdeProject.getBuildProperties();
List<String> binIncludesList = buildProperties.getBinIncludes();
List<String> binExcludesList = buildProperties.getBinExcludes();
// 1. additional filesets should win over bin.includes, so we add them first
if (additionalFileSets != null) {
for (DefaultFileSet fileSet : additionalFileSets) {
if (fileSet.getDirectory() != null && fileSet.getDirectory().isDirectory()) {
archiver.getArchiver().addFileSet(fileSet);
}
}
}
List<String> binIncludesIgnoredForValidation = new ArrayList<>();
// 2. handle dir classpath entries and "."
for (BuildOutputJar outputJar : pdeProject.getOutputJarMap().values()) {
String jarName = outputJar.getName();
if (binIncludesList.contains(jarName) && outputJar.isDirClasspathEntry()) {
binIncludesIgnoredForValidation.add(jarName);
String prefix = ".".equals(jarName) ? "" : jarName;
archiver.getArchiver().addDirectory(outputJar.getOutputDirectory(), prefix);
}
}
// 3. handle nested jars and included resources
checkBinIncludesExist(buildProperties, binIncludesIgnoredForValidation.toArray(new String[0]));
archiver.getArchiver().addFileSet(getFileSet(project.getBasedir(), binIncludesList, binExcludesList));
File manifest = updateManifest();
if (manifest.exists()) {
archive.setManifestFile(manifest);
}
archiver.setOutputFile(pluginFile);
if (!archive.isForced()) {
// optimized archive creation not supported for now because of build qualifier mismatch issues
// see TYCHO-502
getLog().warn("ignoring unsupported archive forced = false parameter.");
archive.setForced(true);
}
archiver.createArchive(session, project, archive);
return pluginFile;
} catch (IOException e) {
throw new MojoExecutionException("Error assembling JAR", e);
} catch (ArchiverException e) {
throw new MojoExecutionException("Error assembling JAR", e);
} catch (ManifestException e) {
throw new MojoExecutionException("Error assembling JAR", e);
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("Error assembling JAR", e);
}
}
use of org.apache.maven.artifact.DependencyResolutionRequiredException in project maven-archetype by apache.
the class JarMojo method execute.
public void execute() throws MojoExecutionException, MojoFailureException {
try {
getLog().info("Building archetype jar: " + new File(outputDirectory, finalName));
File jarFile = manager.archiveArchetype(archetypeDirectory, outputDirectory, finalName);
checkArchetypeFile(jarFile);
project.getArtifact().setFile(jarFile);
} catch (DependencyResolutionRequiredException ex) {
throw new MojoExecutionException(ex.getMessage(), ex);
} catch (IOException ex) {
throw new MojoExecutionException(ex.getMessage(), ex);
}
}
use of org.apache.maven.artifact.DependencyResolutionRequiredException in project jewelcli by lexicalscope.
the class JewelCliReportMojo method getClassLoader.
private ClassLoader getClassLoader() throws MavenReportException {
final List<URL> urls = new ArrayList<URL>();
try {
for (final Object object : project.getCompileClasspathElements()) {
final String path = (String) object;
final URL url = new File(path).toURL();
getLog().debug("adding classpath element " + url);
urls.add(url);
}
} catch (final MalformedURLException e) {
throw new MavenReportException("Unable to load command line interface class", e);
} catch (final DependencyResolutionRequiredException e) {
throw new MavenReportException("Unable to resolve dependencies of project", e);
}
return new URLClassLoader(urls.toArray(new URL[] {}), getClass().getClassLoader());
}
use of org.apache.maven.artifact.DependencyResolutionRequiredException in project maven-plugins by apache.
the class BaseJDeprScanMojo method addJDeprScanOptions.
@Override
protected final void addJDeprScanOptions(Commandline cmd) throws MojoFailureException {
super.addJDeprScanOptions(cmd);
if (release != null) {
cmd.createArg().setValue("--release");
cmd.createArg().setValue(release);
}
try {
Collection<Path> cp = getClassPath();
if (!cp.isEmpty()) {
cmd.createArg().setValue("--class-path");
cmd.createArg().setValue(StringUtils.join(cp.iterator(), File.pathSeparator));
}
} catch (DependencyResolutionRequiredException e) {
throw new MojoFailureException(e.getMessage(), e);
}
cmd.createArg().setFile(getClassesDirectory().toFile());
}
Aggregations