Package org.apache.maven.plugin

Examples of org.apache.maven.plugin.MojoExecutionException


        archiver.setArchiver(jarArchiver);
        archiver.setOutputFile(xarFile);
        try {
            buildArchive(jarArchiver);
        } catch (ArchiverException e) {
            throw new MojoExecutionException("Unable to build archive", e);
        }

        // create archive
        try {
            archiver.createArchive(project, archive);
        } catch (Exception e) {
            throw new MojoExecutionException("Unable to create archive", e);
        }

        if (classifier != null) {
            projectHelper.attachArtifact(project, "xar", classifier, xarFile);
        } else {
View Full Code Here


       
        Log log = getLog();
        File tmpServicesDir = new File(new File(tmpDirectory, "META-INF"), "services");
        File buildServicesDir = new File(new File(buildOutputDirectory, "META-INF"), "services");
        if (!tmpServicesDir.mkdirs()) {
            throw new MojoExecutionException("Error while creating the directory: " +
                    tmpServicesDir.getPath());
        }
       
        log.debug("Initializing class scanner ...");
        ClassScanner scanner = new ClassScanner(buildOutputDirectory);
        for (Artifact artifact : filterArtifacts(project.getArtifacts(),
                new ScopeArtifactFilter(Artifact.SCOPE_COMPILE))) {
            scanner.addToClasspath(artifact.getFile());
        }
        List<ServiceLocator> serviceLocators =
            new ArrayList<ServiceLocator>(serviceClassNames.length);
        for (String serviceClassName : serviceClassNames) {
            // If the user provided its own service file, skip generation
            File file = new File(buildServicesDir, serviceClassName);
            if (file.exists()) {
                log.debug(file + " exists; don't scan for " + serviceClassName +
                        " implementation");
            } else {
                ServiceLocator sl = new ServiceLocator(serviceClassName);
                serviceLocators.add(sl);
                scanner.addVisitor(sl);
            }
        }
        try {
            scanner.scan();
        } catch (ClassScannerException e) {
            throw new MojoExecutionException("Failed to scan classes for services", e);
        }
        for (ServiceLocator sl : serviceLocators) {
            File file = new File(tmpServicesDir, sl.getServiceClassName());
            if (!sl.getImplementations().isEmpty()) {
                String destFileName = "META-INF/services/" + sl.getServiceClassName();
                log.info("Generating " + destFileName);
                try {
                    Writer out = new OutputStreamWriter(new FileOutputStream(file));
                    try {
                        for (String impl : sl.getImplementations()) {
                            log.debug("  " + impl);
                            out.write(impl);
                            out.write("\n");
                        }
                    } finally {
                        out.close();
                    }
                } catch (IOException e) {
                    throw new MojoExecutionException("Unable to create temporary file " + file, e);
                }
                archiver.addFile(file, destFileName);
            }
        }
    }
View Full Code Here

                synapseCore = artifact;
                break;
            }
        }
        if (synapseCore == null) {
            throw new MojoExecutionException("Could not locate dependency on synapse-core");
        }
       
        log.debug("Loading project data for " + synapseCore + " ...");
        MavenProject synapseCoreProject;
        try {
            synapseCoreProject = projectBuilder.buildFromRepository(synapseCore,
                    remoteArtifactRepositories, localRepository);
        } catch (ProjectBuildingException e) {
            throw new MojoExecutionException("Unable to retrieve project information for "
                    + synapseCore, e);
        }
        Set<Artifact> synapseRuntimeDeps;
        try {
            synapseRuntimeDeps = synapseCoreProject.createArtifacts(artifactFactory,
                    Artifact.SCOPE_RUNTIME, new TypeArtifactFilter("jar"));
        } catch (InvalidDependencyVersionException e) {
            throw new MojoExecutionException("Unable to get project dependencies for "
                    + synapseCore, e);
        }
        log.debug("Direct runtime dependencies for " + synapseCore + " :");
        logArtifacts(synapseRuntimeDeps);
       
        log.debug("Resolving transitive dependencies for " + synapseCore + " ...");
        try {
            synapseRuntimeDeps = artifactCollector.collect(synapseRuntimeDeps,
                    synapseCoreProject.getArtifact(), synapseCoreProject.getManagedVersionMap(),
                    localRepository, remoteArtifactRepositories, artifactMetadataSource, null,
                    Collections.singletonList(new DebugResolutionListener(logger))).getArtifacts();
        } catch (ArtifactResolutionException e) {
            throw new MojoExecutionException("Unable to resolve transitive dependencies for "
                    + synapseCore);
        }
        log.debug("All runtime dependencies for " + synapseCore + " :");
        logArtifacts(synapseRuntimeDeps);
       
View Full Code Here

            getLog().debug("Calling wsdl2java with args: " + list);
            try {
                new WSDLToJava((String[])list.toArray(new String[list.size()])).run(new ToolContext());
            } catch (Throwable e) {
                getLog().debug(e);
                throw new MojoExecutionException(e.getMessage(), e);
            }
            try {
                doneFile.createNewFile();
            } catch (Throwable e) {
                getLog().warn("Could not create marker file " + doneFile.getAbsolutePath());
View Full Code Here

        options.setSpecVersion(SpecVersion.fromName(specVersion));
        options.setIncremental(this.buildContext.isIncremental());
        options.setSkipVolatileCheck(this.skipVolatileCheck);

        if ( specVersion != null && options.getSpecVersion() == null ) {
            throw new MojoExecutionException("Unknown spec version specified: " + specVersion);
        }

        try {

            final SCRDescriptorGenerator generator = new SCRDescriptorGenerator(
                    scrLog);

            // setup from plugin configuration
            generator.setOptions(options);
            generator.setProject(project);

            this.removePossiblyStaleFiles(scanner.getSources(), options);

            final Result result = generator.execute();
            this.setServiceComponentHeader(options);

            if ( !this.updateProjectResources() ) {
                this.setIncludeResourceHeader(options);
            }
            this.cleanUpDeletedSources(scanner.getDeletedSources(), options);

            this.refreshMessages(result.getProcessedSourceFiles());
            this.updateBuildContext(result);

        } catch (final SCRDescriptorException sde) {
            throw new MojoExecutionException(sde.getSourceLocation() + " : " + sde.getMessage(), sde);
        } catch (final SCRDescriptorFailureException sdfe) {
            throw (MojoFailureException) new MojoFailureException(
                    sdfe.getMessage()).initCause(sdfe);
        }
    }
View Full Code Here

        }

        catch (Throwable t)
        {
            getLog().error("Exception while scanning annotation", t);
            throw new MojoExecutionException(t.getMessage(), t.getCause());
        }

        finally
        {
            if (jar != null)
View Full Code Here

        {
            if (tmp.exists())
            {
                if (!tmp.delete())
                {
                    throw new MojoExecutionException("Could not remove " + tmp);
                }
            }
            jar.write(tmp);
            jar.close();

            if (target.exists() && !target.delete())
            {
                throw new MojoExecutionException("Could not remove " + target);
            }
            if (!tmp.renameTo(target))
            {
                throw new MojoExecutionException("Could not rename " + tmp + " to " + target);
            }
        }
        finally
        {
            jar.close();
            if (tmp.exists() && !tmp.delete())
            {
                throw new MojoExecutionException("Could not remove " + tmp);
            }
        }
    }
View Full Code Here

        outputDirFile.mkdirs();
       
        boolean result = true;
       
        if (wsdltoidlOptions == null) {
            throw new MojoExecutionException("Please specify the wsdltoidl options");
        }

        for (int x = 0; x < wsdltoidlOptions.length; x++) {
            File file = new File(wsdltoidlOptions[x].getWSDL());
            File doneFile = new File(outputDirFile, "." + file.getName() + ".DONE");

            boolean doWork = file.lastModified() > doneFile.lastModified();
            if (!doneFile.exists()) {
                doWork = true;
            } else if (file.lastModified() > doneFile.lastModified()) {
                doWork = true;
            }

            if (doWork) {
                List<Object> list = new ArrayList<Object>();
                list.add("-d");
                list.add(outputDir);
                if (wsdltoidlOptions[x].isCorbaEnabled()) {
                    list.add("-corba");
                }
                if (wsdltoidlOptions[x].isIdlEnabled()) {
                    list.add("-idl");
                }
                if (wsdltoidlOptions[x].getExtraargs() != null) {
                    list.addAll(wsdltoidlOptions[x].getExtraargs());
                }
                list.add(wsdltoidlOptions[x].getWSDL());           
                SecurityManager oldSm = System.getSecurityManager();
                try {
                    try {
                        System.setSecurityManager(new NoExitSecurityManager());
                        WSDLToIDL.main((String[])list.toArray(new String[list.size()]));
                        doneFile.delete();
                        doneFile.createNewFile();
                    } catch (ExitException e) {
                        if (e.getStatus() == 0) {
                            doneFile.delete();
                            doneFile.createNewFile();
                        } else {
                            throw e;
                        }
                    }
                } catch (Throwable e) {
                    e.printStackTrace();
                    throw new MojoExecutionException(e.getMessage(), e);
                } finally {
                    System.setSecurityManager(oldSm);
                }
            }
        }
View Full Code Here

        outputDirFile.mkdirs();
       
        boolean result = true;
       
        if (idltowsdlOptions == null) {
            throw new MojoExecutionException("Please specify the idltowsdl options");
        }

        for (int x = 0; x < idltowsdlOptions.length; x++) {
            File file = new File(idltowsdlOptions[x].getIDL());
            File doneFile = new File(outputDirFile, "." + file.getName() + ".DONE");

            boolean doWork = file.lastModified() > doneFile.lastModified();
            if (!doneFile.exists()) {
                doWork = true;
            } else if (file.lastModified() > doneFile.lastModified()) {
                doWork = true;
            }

            if (doWork) {
                List<Object> list = new ArrayList<Object>();
                list.add("-o");
                list.add(outputDir);
                list.addAll(idltowsdlOptions[x].getExtraargs());
                list.add(idltowsdlOptions[x].getIDL());           
                SecurityManager oldSm = System.getSecurityManager();
                try {
                    try {
                        System.setSecurityManager(new NoExitSecurityManager());
                        IDLToWSDL.main((String[])list.toArray(new String[list.size()]));
                        doneFile.delete();
                        doneFile.createNewFile();
                    } catch (ExitException e) {
                        if (e.getStatus() == 0) {
                            doneFile.delete();
                            doneFile.createNewFile();
                        } else {
                            throw e;
                        }
                    }
                } catch (Throwable e) {
                    e.printStackTrace();
                    throw new MojoExecutionException(e.getMessage(), e);
                } finally {
                    System.setSecurityManager(oldSm);
                }
            }
        }
View Full Code Here

        catch ( Exception e ) {
            reportError(e);

            if ( stopOnFailure ) {
                if ( e instanceof MojoExecutionException ) {
                    throw new MojoExecutionException(e.getMessage(), e);
                }
                else if ( e instanceof MojoFailureException ) {
                    MojoFailureException x = new MojoFailureException(e.getMessage());
                    x.initCause(e);
                    throw x;
                }
                else {
                    throw new MojoExecutionException(e.getMessage(), e);
                }
            }
            else {
                log.warn("Ignoring failure !");
            }
View Full Code Here

TOP

Related Classes of org.apache.maven.plugin.MojoExecutionException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.