Package org.apache.maven.plugin

Examples of org.apache.maven.plugin.MojoFailureException


            try {
                compilationLevel =
                        CompilationLevel.valueOf(compilation
                                .getCompilationLevel());
            } catch (IllegalArgumentException e) {
                throw new MojoFailureException("Compilation level invalid", e);
            }

            CompilerOptions compilerOptions =
                    compilation.getCompilerOptionsMojo().getCompilerOptions();
            if (null == compilerOptions) {
                log.info("With no compiler options");
                compilerOptions = new CompilerOptions();
            }
            log.info("Compiler Options:" + compilerOptions);

            compilationLevel.setOptionsForCompilationLevel(compilerOptions);

            Compiler compiler = new Compiler();
            Result result = compiler.compile(externs, source, compilerOptions);

            // TODO: should log results to a file if desired.
            for (JSError warning : result.warnings) {
                getLog().warn(warning.toString());
            }

            for (JSError error : result.errors) {
                getLog().error(error.toString());
            }

            if (!result.success) {
                // TODO: better info?
                throw new MojoFailureException("Compilation failure");
            }

            try {
                Files.createParentDirs(compilation.getOutputFile());
                Files.touch(compilation.getOutputFile());
                Files.write(compiler.toSource(), compilation.getOutputFile(),
                        Charsets.UTF_8);
            } catch (IOException e) {
                throw new MojoFailureException(
                        compilation.getOutputFile() != null ? compilation
                                .getOutputFile().toString() : e.getMessage(), e);
            }
        }
    }
View Full Code Here


    }
    catch (final ScmNoRevisionException e)
    {
        if (failOnMissingRevision)
        {
            throw new MojoFailureException(e.getMessage()); // NOPMD
        }
        else
        {
                getLog().info( "Unable to determine SCM revision information "
                                   +
View Full Code Here

        synchronized (CLIENT_LOCK) {
            final ModelControllerClient client = getClient();
            try {
                executeCommands.execute(client);
            } catch (IOException e) {
                throw new MojoFailureException("Could not execute commands.", e);
            } finally {
                close();
            }
        }
    }
View Full Code Here

        }
        target.mkdirs();
        try {
            Files.unzip(result, target);
        } catch (IOException e) {
            throw new MojoFailureException("Artifact was not successfully extracted: " + result, e);
        }
        final File[] files = target.listFiles();
        if (files == null || files.length != 1) {
            throw new MojoFailureException("Artifact was not successfully extracted: " + result);
        }
        // Assume the first
        return files[0];
    }
View Full Code Here

        String version = this.version;
        // groupId:artifactId:version[:packaging][:classifier].
        if (artifact != null) {
            final String[] artifactParts = artifact.split(":");
            if (artifactParts.length == 0) {
                throw new MojoFailureException(String.format("Invalid artifact pattern: %s", artifact));
            }
            String value;
            switch (artifactParts.length) {
                case 5:
                    value = artifactParts[4].trim();
View Full Code Here

        }
        target.mkdirs();
        try {
            Files.unzip(result, target);
        } catch (IOException e) {
            throw new MojoFailureException("Artifact was not successfully extracted: " + result, e);
        }
        final File[] files = target.listFiles();
        if (files == null || files.length != 1) {
            throw new MojoFailureException("Artifact was not successfully extracted: " + result);
        }
        // Assume the first
        return files[0];
    }
View Full Code Here

        String version = this.version;
        // groupId:artifactId:version[:packaging][:classifier].
        if (artifact != null) {
            final String[] artifactParts = artifact.split(":");
            if (artifactParts.length == 0) {
                throw new MojoFailureException(String.format("Invalid artifact pattern: %s", artifact));
            }
            String value;
            switch (artifactParts.length) {
                case 5:
                    value = artifactParts[4].trim();
View Full Code Here

        return DiagnosisUtils.containsInCausality( error, MojoFailureException.class );
    }

    public String diagnose( Throwable error )
    {
        MojoFailureException mfe =
            (MojoFailureException) DiagnosisUtils.getFromCausality( error, MojoFailureException.class );

        StringBuffer message = new StringBuffer();

        Object source = mfe.getSource();
        if ( source != null )
        {
            message.append( ": " ).append( mfe.getSource() ).append( "\n" );
        }

        String shortMessage = mfe.getMessage();
        if ( shortMessage != null )
        {
            message.append( shortMessage );
        }

        String longMessage = mfe.getLongMessage();
       
        // the indexOf bit is very strange, but the compiler output for 1.5 source compiled using JDK 1.4 presents this case!
        if ( longMessage != null && !longMessage.equals( shortMessage ) && shortMessage.indexOf( longMessage ) < 0 )
        {
            message.append( "\n\n" ).append( longMessage );
View Full Code Here

            copyFiles( baseDirectory, binRootFolderServerDirectory );
        }
        catch ( IOException e )
        {
            log.error( e.getMessage() );
            throw new MojoFailureException( "Failed to copy image (" + target.getLayout().getBaseDirectory()
                + ") to the Bin directory (" + binRootFolderDirectory + ")" );
        }

        // Create instance and sh directory
        File binRootFolderInstanceDirectory = new File( binRootFolderDirectory, "instance" );
        binRootFolderInstanceDirectory.mkdirs();
        File binShDirectory = new File( binDirectory, "sh" );
        binShDirectory.mkdirs();

        // Copying the resources files
        try
        {
            // Copying the apacheds.conf file to the server installation layout
            MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream( "apacheds.conf" ),
                new File( binRootFolderServerDirectory, "conf/apacheds.conf" ), false );

            // Copying the default instance apacheds.conf file
            MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream(
                "apacheds-default.conf" ), new File( binRootFolderInstanceDirectory, "apacheds.conf" ), false );

            // Copying the log4j.properties file for the default instance
            MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, new File( binRootFolderServerDirectory,
                "conf/log4j.properties" ), new File( binRootFolderInstanceDirectory, "log4j.properties" ), false );

            // Copying the server.xml file for the default instance
            MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, new File( binRootFolderServerDirectory,
                "conf/server.xml" ), new File( binRootFolderInstanceDirectory, "server.xml" ), false );

            // Copying the apacheds-init script file for the default instance
            MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream( "apacheds-init" ),
                new File( binRootFolderInstanceDirectory, "apacheds-init" ), true );

            // Copying shell script utilities for the installer
            MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream( "bootstrap.sh" ),
                new File( binDirectory, "bootstrap.sh" ), true );
            MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream(
                "createInstaller.sh" ), new File( binDirectory, "createInstaller.sh" ), true );
            MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream( "functions.sh" ),
                new File( binShDirectory, "functions.sh" ), false );
            MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream( "install.sh" ),
                new File( binShDirectory, "install.sh" ), false );
            MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream( "variables.sh" ),
                new File( binShDirectory, "variables.sh" ), false );

            // Removing the redundant server.xml file (see DIRSERVER-1112)
            new File( binRootFolderServerDirectory, "conf/server.xml" ).delete();
        }
        catch ( IOException e )
        {
            log.error( e.getMessage() );
            throw new MojoFailureException( "Failed to copy Bin resources files." );
        }

        // Generating the Bin
        log.info( "Generating Bin Installer" );
        Execute createBinTask = new Execute();
        String[] cmd = new String[]
            { shUtility.getAbsolutePath(), "createInstaller.sh" };
        createBinTask.setCommandline( cmd );
        createBinTask.setSpawn( true );
        createBinTask.setWorkingDirectory( binDirectory );
        try
        {
            createBinTask.execute();
        }
        catch ( IOException e )
        {
            log.error( e.getMessage() );
            throw new MojoFailureException( "Failed while trying to generate the Bin: " + e.getMessage() );
        }

        log.info( "Bin Installer generated at " + new File( imagesDirectory, finalName ) );
    }
View Full Code Here

            artifactResolver.resolve(artifact, remoteArtifactRepositories,
                    localRepository);
            return artifact.getFile();
        } catch (InvalidVersionSpecificationException e) {
            throw new MojoFailureException("The skin version '" + version
                    + "' is not valid: " + e.getMessage());
        } catch (ArtifactResolutionException e) {
            throw new MojoFailureException("Unable to fink skin: "
                    + e.getMessage());
        } catch (ArtifactNotFoundException e) {
            throw new MojoFailureException("The skin does not exist: "
                    + e.getMessage());
        }
    }
View Full Code Here

TOP

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

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.