Search in sources :

Example 31 with DependencyResolutionRequiredException

use of org.apache.maven.artifact.DependencyResolutionRequiredException in project cuke4duke by cucumber.

the class AbstractJRubyMojo method getProject.

protected Project getProject() throws MojoExecutionException {
    Project project = new Project();
    project.setBaseDir(mavenProject.getBasedir());
    project.setProperty("jruby.home", jrubyHome().getAbsolutePath());
    project.addBuildListener(new LogAdapter());
    Path jrubyClasspath = new Path(project);
    project.addReference("jruby.classpath", jrubyClasspath);
    try {
        append(jrubyClasspath, testClasspathElements);
        append(jrubyClasspath, compileClasspathElements);
        append(jrubyClasspath, pluginArtifacts);
        return project;
    } catch (DependencyResolutionRequiredException e) {
        throw new MojoExecutionException("error resolving dependencies", e);
    }
}
Also used : Path(org.apache.tools.ant.types.Path) MavenProject(org.apache.maven.project.MavenProject) Project(org.apache.tools.ant.Project) DependencyResolutionRequiredException(org.apache.maven.artifact.DependencyResolutionRequiredException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException)

Example 32 with DependencyResolutionRequiredException

use of org.apache.maven.artifact.DependencyResolutionRequiredException in project querydsl by querydsl.

the class AbstractExporterMojo method execute.

@SuppressWarnings("unchecked")
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    if (testClasspath) {
        project.addTestCompileSourceRoot(targetFolder.getAbsolutePath());
    } else {
        project.addCompileSourceRoot(targetFolder.getAbsolutePath());
    }
    if (skip || !hasSourceChanges()) {
        // prevent m2e from entering an infinite build cycle.
        return;
    }
    ClassLoader classLoader = null;
    try {
        classLoader = getProjectClassLoader();
    } catch (MalformedURLException | DependencyResolutionRequiredException e) {
        throw new MojoFailureException(e.getMessage(), e);
    }
    Charset charset = sourceEncoding != null ? Charset.forName(sourceEncoding) : Charset.defaultCharset();
    GenericExporter exporter = new GenericExporter(classLoader, charset);
    exporter.setTargetFolder(targetFolder);
    if (scala) {
        try {
            exporter.setSerializerClass((Class<? extends Serializer>) Class.forName("com.querydsl.scala.ScalaEntitySerializer"));
            exporter.setTypeMappingsClass((Class<? extends TypeMappings>) Class.forName("com.querydsl.scala.ScalaTypeMappings"));
            exporter.setCreateScalaSources(true);
        } catch (ClassNotFoundException e) {
            throw new MojoFailureException(e.getMessage(), e);
        }
    }
    configure(exporter);
    exporter.export(packages);
}
Also used : GenericExporter(com.querydsl.codegen.GenericExporter) MalformedURLException(java.net.MalformedURLException) DependencyResolutionRequiredException(org.apache.maven.artifact.DependencyResolutionRequiredException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) URLClassLoader(java.net.URLClassLoader) Charset(java.nio.charset.Charset)

Example 33 with DependencyResolutionRequiredException

use of org.apache.maven.artifact.DependencyResolutionRequiredException in project maven-plugins by apache.

the class ManifestCreationFinalizer method finalizeArchiveCreation.

@Override
public void finalizeArchiveCreation(final Archiver archiver) {
    if (archiveConfiguration != null) {
        try {
            Manifest manifest;
            final File manifestFile = archiveConfiguration.getManifestFile();
            if (manifestFile != null) {
                Reader manifestFileReader = null;
                try {
                    manifestFileReader = new InputStreamReader(new FileInputStream(manifestFile), "UTF-8");
                    manifest = new Manifest(manifestFileReader);
                    manifestFileReader.close();
                    manifestFileReader = null;
                } catch (final FileNotFoundException e) {
                    throw new ArchiverException("Manifest not found: " + e.getMessage(), e);
                } catch (final IOException e) {
                    throw new ArchiverException("Error processing manifest: " + e.getMessage(), e);
                } finally {
                    IOUtil.close(manifestFileReader);
                }
            } else {
                manifest = mavenArchiver.getManifest(session, project, archiveConfiguration);
            }
            if ((manifest != null) && (archiver instanceof JarArchiver)) {
                final JarArchiver jarArchiver = (JarArchiver) archiver;
                jarArchiver.addConfiguredManifest(manifest);
            }
        } catch (final ManifestException e) {
            throw new ArchiverException("Error creating manifest: " + e.getMessage(), e);
        } catch (final DependencyResolutionRequiredException e) {
            throw new ArchiverException("Dependencies were not resolved: " + e.getMessage(), e);
        }
    }
}
Also used : DependencyResolutionRequiredException(org.apache.maven.artifact.DependencyResolutionRequiredException) InputStreamReader(java.io.InputStreamReader) ArchiverException(org.codehaus.plexus.archiver.ArchiverException) FileNotFoundException(java.io.FileNotFoundException) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) IOException(java.io.IOException) Manifest(org.codehaus.plexus.archiver.jar.Manifest) ManifestException(org.codehaus.plexus.archiver.jar.ManifestException) File(java.io.File) JarArchiver(org.codehaus.plexus.archiver.jar.JarArchiver) FileInputStream(java.io.FileInputStream)

Example 34 with DependencyResolutionRequiredException

use of org.apache.maven.artifact.DependencyResolutionRequiredException in project maven-plugins by apache.

the class AbstractJDepsMojo method addJDepsOptions.

protected void addJDepsOptions(Commandline cmd, Set<Path> dependenciesToAnalyze) throws MojoFailureException {
    if (dotOutput != null) {
        cmd.createArg().setValue("-dotoutput");
        cmd.createArg().setFile(dotOutput);
    }
    if (verbose != null) {
        if ("class".equals(verbose)) {
            cmd.createArg().setValue("-verbose:class");
        } else if ("package".equals(verbose)) {
            cmd.createArg().setValue("-verbose:package");
        } else {
            cmd.createArg().setValue("-v");
        }
    }
    try {
        Collection<Path> cp = new ArrayList<>();
        for (Path path : getClassPath()) {
            if (!dependenciesToAnalyze.contains(path)) {
                cp.add(path);
            }
        }
        if (!cp.isEmpty()) {
            cmd.createArg().setValue("-cp");
            cmd.createArg().setValue(StringUtils.join(cp.iterator(), File.pathSeparator));
        }
    } catch (DependencyResolutionRequiredException e) {
        throw new MojoFailureException(e.getMessage(), e);
    }
    if (include != null) {
        cmd.createArg().setValue("-include");
        cmd.createArg().setValue(include);
    }
    if (profile) {
        cmd.createArg().setValue("-P");
    }
    if (module) {
        cmd.createArg().setValue("-M");
    }
    if (apiOnly) {
        cmd.createArg().setValue("-apionly");
    }
    if (recursive) {
        cmd.createArg().setValue("-R");
    }
// cmd.createArg().setValue( "-version" );
}
Also used : Path(java.nio.file.Path) DependencyResolutionRequiredException(org.apache.maven.artifact.DependencyResolutionRequiredException) ArrayList(java.util.ArrayList) MojoFailureException(org.apache.maven.plugin.MojoFailureException)

Example 35 with DependencyResolutionRequiredException

use of org.apache.maven.artifact.DependencyResolutionRequiredException in project maven-plugins by apache.

the class EjbMojo method generateEjb.

private File generateEjb() throws MojoExecutionException {
    File jarFile = EjbHelper.getJarFile(outputDirectory, jarName, getClassifier());
    getLog().info("Building EJB " + jarName + " with EJB version " + ejbVersion);
    MavenArchiver archiver = new MavenArchiver();
    archiver.setArchiver(jarArchiver);
    archiver.setOutputFile(jarFile);
    File deploymentDescriptor = new File(sourceDirectory, ejbJar);
    checkEJBVersionCompliance(deploymentDescriptor);
    try {
        List<String> defaultExcludes = Lists.newArrayList(ejbJar, "**/package.html");
        List<String> defaultIncludes = DEFAULT_INCLUDES_LIST;
        IncludesExcludes ie = new IncludesExcludes(Collections.<String>emptyList(), excludes, defaultIncludes, defaultExcludes);
        archiver.getArchiver().addDirectory(sourceDirectory, ie.resultingIncludes(), ie.resultingExcludes());
        // FIXME: We should be able to filter more than just the deployment descriptor?
        if (deploymentDescriptor.exists()) {
            // EJB-34 Filter ejb-jar.xml
            if (filterDeploymentDescriptor) {
                filterDeploymentDescriptor(deploymentDescriptor);
            }
            archiver.getArchiver().addFile(deploymentDescriptor, ejbJar);
        }
        // create archive
        archiver.createArchive(session, project, archive);
    } catch (ArchiverException e) {
        throw new MojoExecutionException("There was a problem creating the EJB archive: " + e.getMessage(), e);
    } catch (ManifestException e) {
        throw new MojoExecutionException("There was a problem creating the EJB archive: " + e.getMessage(), e);
    } catch (IOException e) {
        throw new MojoExecutionException("There was a problem creating the EJB archive: " + e.getMessage(), e);
    } catch (DependencyResolutionRequiredException e) {
        throw new MojoExecutionException("There was a problem creating the EJB archive: " + e.getMessage(), e);
    } catch (MavenFilteringException e) {
        throw new MojoExecutionException("There was a problem filtering the deployment descriptor: " + e.getMessage(), e);
    }
    return jarFile;
}
Also used : DependencyResolutionRequiredException(org.apache.maven.artifact.DependencyResolutionRequiredException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ArchiverException(org.codehaus.plexus.archiver.ArchiverException) MavenFilteringException(org.apache.maven.shared.filtering.MavenFilteringException) MavenArchiver(org.apache.maven.archiver.MavenArchiver) IOException(java.io.IOException) ManifestException(org.codehaus.plexus.archiver.jar.ManifestException) File(java.io.File)

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