Package org.apache.maven.plugin

Examples of org.apache.maven.plugin.MojoFailureException


                + " if you are happy with the dependency changes.");

        if (warnOnDependencyChange) {
            getLog().warn(out.toString());
        } else {
            throw new MojoFailureException(out.toString());
        }
    }
View Full Code Here


        // Creating the target directory
        if ( !getTargetDirectory().mkdirs() )
        {
            Exception e = new IOException( I18n.err( I18n.ERR_112_COULD_NOT_CREATE_DIRECORY, getTargetDirectory() ) );
            log.error( e.getLocalizedMessage() );
            throw new MojoFailureException( e.getMessage() );
        }

        log.info( "    Copying archive files" );

        try
        {
            // Creating the installation and instance layouts
            createLayouts( false );

            // Copy bat and sh scripts to bin
            MojoHelperUtils.copyAsciiFile( mojo, filterProperties, getClass().getResourceAsStream(
                "apacheds.bat" ), new File( getInstallationLayout().getBinDirectory(),
                "apacheds.bat" ), false );
            MojoHelperUtils.copyAsciiFile( mojo, filterProperties, getClass().getResourceAsStream(
                "apacheds.sh" ), new File( getInstallationLayout().getBinDirectory(),
                "apacheds.sh" ), false );
            MojoHelperUtils.copyAsciiFile( mojo, filterProperties, getClass().getResourceAsStream(
                "cpappend.bat" ), new File( getInstallationLayout().getBinDirectory(),
                "cpappend.bat" ), false );

            // Removing unnecessary directories and files
            FileUtils.deleteDirectory( getInstallationLayout().getConfDirectory() );
            File wrapperConf = new File( getInstanceLayout().getConfDirectory(), "wrapper.conf" );
            if ( !wrapperConf.delete() )
            {
                throw new IOException( I18n.err( I18n.ERR_113_COULD_NOT_DELETE_FILE_OR_DIRECTORY, wrapperConf ) );
            }
            FileUtils.deleteDirectory( getInstanceLayout().getRunDirectory() );
        }
        catch ( Exception e )
        {
            log.error( e.getMessage() );
            throw new MojoFailureException( "Failed to copy archive files." );
        }

        // Generating the archive
        log.info( "    Generating archive" );

        // Creating the final file
        String finalName = target.getFinalName();
        if ( !finalName.endsWith( archiveType ) )
        {
            finalName = finalName + archiveType;
        }
        File finalFile = new File( mojo.getOutputDirectory(), finalName );

        // Preparing the Ant project
        Project project = new Project();
        project.setBaseDir( mojo.getOutputDirectory() );

        // ZIP Archive
        if ( archiveType.equalsIgnoreCase( "zip" ) )
        {
            Zip zipTask = new Zip();
            zipTask.setProject( project );
            zipTask.setDestFile( finalFile );
            zipTask.setBasedir( getTargetDirectory() );
            zipTask.setIncludes( getArchiveDirectory().getName() + "/**" );
            zipTask.execute();
        }
        // TAR Archive
        else if ( archiveType.equalsIgnoreCase( "tar" ) )
        {
            Tar tarTask = new Tar();
            tarTask.setProject( project );
            tarTask.setDestFile( finalFile );
            tarTask.setBasedir( getTargetDirectory() );
            tarTask.setIncludes( getArchiveDirectory().getName() + "/**" );
            tarTask.execute();
        }
        // TAR.GZ Archive
        else if ( archiveType.equalsIgnoreCase( "tar.gz" ) )
        {
            File tarFile = new File( mojo.getOutputDirectory(), target.getId() + ".tar" );

            Tar tarTask = new Tar();
            tarTask.setProject( project );
            tarTask.setDestFile( tarFile );
            tarTask.setBasedir( getTargetDirectory() );
            tarTask.setIncludes( getArchiveDirectory().getName() + "/**" );
            tarTask.execute();

            GZip gzipTask = new GZip();
            gzipTask.setProject( project );
            gzipTask.setDestfile( finalFile );
            gzipTask.setSrc( tarFile );
            gzipTask.execute();

            if ( !tarFile.delete() )
            {
                Exception e = new IOException( I18n.err( I18n.ERR_113_COULD_NOT_DELETE_FILE_OR_DIRECTORY, tarFile ) );
                log.error( e.getLocalizedMessage() );
                throw new MojoFailureException( e.getMessage() );
            }
        }
        // TAR.BZ2 Archive
        else if ( archiveType.equalsIgnoreCase( "tar.bz2" ) )
        {
            File tarFile = new File( mojo.getOutputDirectory(), target.getId() + ".tar" );

            Tar tarTask = new Tar();
            tarTask.setProject( project );
            tarTask.setDestFile( tarFile );
            tarTask.setBasedir( getTargetDirectory() );
            tarTask.setIncludes( getArchiveDirectory().getName() + "/**" );
            tarTask.execute();

            BZip2 bzip2Task = new BZip2();
            bzip2Task.setProject( project );
            bzip2Task.setDestfile( finalFile );
            bzip2Task.setSrc( tarFile );
            bzip2Task.execute();

            if ( !tarFile.delete() )
            {
                Exception e = new IOException( I18n.err( I18n.ERR_113_COULD_NOT_DELETE_FILE_OR_DIRECTORY, tarFile ) );
                log.error( e.getLocalizedMessage() );
                throw new MojoFailureException( e.getMessage() );
            }
        }

        log.info( "=> Archive Installer (" + archiveType + ") archive generated at "
            + finalFile );
View Full Code Here

                getLog().info("Removing " +localArtifactDirectory.getAbsolutePath());
                FileUtils.deleteDirectory(localArtifactDirectory);
            }
            catch (IOException e)
            {
                throw new MojoFailureException("Cannot delete " + localArtifactDirectory);
            }
        }
        else
        {
            File localMetadataFile = new File(localArtifactDirectory, MAVEN_METADATA_LOCAL);
View Full Code Here

    private void assertNoException( NestedCheckedException firstForkException )
        throws MojoFailureException
    {
        if ( firstForkException != null )
        {
            throw new MojoFailureException( firstForkException.getMessage(), firstForkException );
        }
    }
View Full Code Here

    private void assertNoFailureOrTimeout( NestedCheckedException summary )
        throws MojoFailureException
    {
        if ( summary != null )
        {
            throw new MojoFailureException( "Failure or timeout" );
        }
    }
View Full Code Here

            DefaultScanResult scan = scanForTestClasses();
            if ( !isValidSuiteXmlFileConfig() && scan.isEmpty() )
            {
                if ( getEffectiveFailIfNoTests() )
                {
                    throw new MojoFailureException(
                        "No tests were executed!  (Set -DfailIfNoTests=false to ignore this error.)" );
                }
                handleSummary( RunResult.noTestsRun(), null );
                return;
            }
View Full Code Here

        if ( !getTestClassesDirectory().exists()
            && ( getDependenciesToScan() == null || getDependenciesToScan().length == 0 ) )
        {
            if ( Boolean.TRUE.equals( getFailIfNoTests() ) )
            {
                throw new MojoFailureException( "No tests to run!" );
            }
            getLog().info( "No tests to run." );
        }
        else
        {
View Full Code Here

    void ensureWorkingDirectoryExists()
        throws MojoFailureException
    {
        if ( getWorkingDirectory() == null )
        {
            throw new MojoFailureException( "workingDirectory cannot be null" );
        }

        if ( !getWorkingDirectory().exists() )
        {
            if ( !getWorkingDirectory().mkdirs() )
            {
                throw new MojoFailureException( "Cannot create workingDirectory " + getWorkingDirectory() );
            }
        }

        if ( !getWorkingDirectory().isDirectory() )
        {
            throw new MojoFailureException(
                "workingDirectory " + getWorkingDirectory() + " exists and is not a directory" );
        }
    }
View Full Code Here

    void ensureParallelRunningCompatibility()
        throws MojoFailureException
    {
        if ( isMavenParallel() && isNotForking() )
        {
            throw new MojoFailureException( "parallel maven execution is not compatible with surefire forkCount 0" );
        }
    }
View Full Code Here

    void ensureThreadCountWithPerThread()
        throws MojoFailureException
    {
        if ( ForkConfiguration.FORK_PERTHREAD.equals( getEffectiveForkMode() ) && getThreadCount() < 1 )
        {
            throw new MojoFailureException( "Fork mode perthread requires a thread count" );
        }
    }
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.