Search in sources :

Example 11 with DependencyResolutionRequiredException

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.");
    }
}
Also used : DependencyResolutionRequiredException(org.apache.maven.artifact.DependencyResolutionRequiredException) MavenProject(org.apache.maven.project.MavenProject) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ArchiverException(org.codehaus.plexus.archiver.ArchiverException) MavenArchiver(org.apache.maven.archiver.MavenArchiver) IOException(java.io.IOException) ManifestException(org.codehaus.plexus.archiver.jar.ManifestException) File(java.io.File)

Example 12 with DependencyResolutionRequiredException

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);
    }
}
Also used : DefaultFileSet(org.codehaus.plexus.archiver.util.DefaultFileSet) DependencyResolutionRequiredException(org.apache.maven.artifact.DependencyResolutionRequiredException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ArchiverException(org.codehaus.plexus.archiver.ArchiverException) ArrayList(java.util.ArrayList) MavenArchiver(org.apache.maven.archiver.MavenArchiver) IOException(java.io.IOException) ManifestException(org.codehaus.plexus.archiver.jar.ManifestException) BuildProperties(org.eclipse.tycho.core.shared.BuildProperties) BuildOutputJar(org.eclipse.tycho.core.osgitools.project.BuildOutputJar) File(java.io.File)

Example 13 with DependencyResolutionRequiredException

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);
    }
}
Also used : DependencyResolutionRequiredException(org.apache.maven.artifact.DependencyResolutionRequiredException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) IOException(java.io.IOException) File(java.io.File)

Example 14 with DependencyResolutionRequiredException

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());
}
Also used : MalformedURLException(java.net.MalformedURLException) DependencyResolutionRequiredException(org.apache.maven.artifact.DependencyResolutionRequiredException) URLClassLoader(java.net.URLClassLoader) ArrayList(java.util.ArrayList) File(java.io.File) URL(java.net.URL) MavenReportException(org.apache.maven.reporting.MavenReportException)

Example 15 with DependencyResolutionRequiredException

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());
}
Also used : Path(java.nio.file.Path) DependencyResolutionRequiredException(org.apache.maven.artifact.DependencyResolutionRequiredException) MojoFailureException(org.apache.maven.plugin.MojoFailureException)

Aggregations

DependencyResolutionRequiredException (org.apache.maven.artifact.DependencyResolutionRequiredException)37 File (java.io.File)25 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)16 IOException (java.io.IOException)12 ArchiverException (org.codehaus.plexus.archiver.ArchiverException)11 ManifestException (org.codehaus.plexus.archiver.jar.ManifestException)11 MavenArchiver (org.apache.maven.archiver.MavenArchiver)10 MojoFailureException (org.apache.maven.plugin.MojoFailureException)9 ArrayList (java.util.ArrayList)8 MavenProject (org.apache.maven.project.MavenProject)8 MalformedURLException (java.net.MalformedURLException)6 URLClassLoader (java.net.URLClassLoader)6 URL (java.net.URL)5 FileNotFoundException (java.io.FileNotFoundException)3 HashSet (java.util.HashSet)3 Resource (org.apache.maven.model.Resource)3 Path (org.apache.tools.ant.types.Path)3 NamespaceMetaData (io.siddhi.doc.gen.metadata.NamespaceMetaData)2 Path (java.nio.file.Path)2 List (java.util.List)2