Package org.apache.maven.continuum.project.builder

Examples of org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult


    public void testgetMavenProject()
        throws Exception
    {
        MavenBuilderHelper mavenBuilderHelper = (MavenBuilderHelper) lookup( MavenBuilderHelper.ROLE, "default" );
        ContinuumProjectBuildingResult result = new ContinuumProjectBuildingResult();
        File file = new File( getBasedir(), "src/test-poms/pom.xml" );
        MavenProject project = mavenBuilderHelper.getMavenProject( result, file );
        assertNotNull( project );

        assertEquals( "plexus", project.getGroupId() );
        assertEquals( "continuum-project2", project.getArtifactId() );
        assertEquals( "This is a sample pom for test purposes", project.getDescription() );
        assertNotNull( project.getScm() );
        assertTrue( project.getDependencies().isEmpty() );
        assertTrue( result.getErrors().isEmpty() );
    }
View Full Code Here


    public void testgetMavenProjectMissingDeps()
        throws Exception
    {
        MavenBuilderHelper mavenBuilderHelper = (MavenBuilderHelper) lookup( MavenBuilderHelper.ROLE, "default" );
        ContinuumProjectBuildingResult result = new ContinuumProjectBuildingResult();
        File file = new File( getBasedir(), "src/test-poms/pom-unknown-dependency.xml" );
        mavenBuilderHelper.getMavenProject( result, file );
        assertFalse( result.getErrors().isEmpty() );
        String errorsAsString = result.getErrorsAsString();
        assertFalse( StringUtils.isEmpty( errorsAsString ) );
        log.info( "errorAsString " + errorsAsString );
        assertTrue( errorsAsString.contains( "ghd:non-exists:pom:2.6.267676-beta-754-alpha-95" ) );
        log.info( "errors " + result.getErrors() );
    }
View Full Code Here

    protected ContinuumProjectBuildingResult doExecute( String pomUrl, int selectedProjectGroup, boolean checkProtocol,
                                                        boolean scmUseCache )
        throws ContinuumException
    {
        ContinuumProjectBuildingResult result = null;
       
        // TODO: remove this part once uploading of an m2 project with modules is supported ( CONTINUUM-1098 )
        if ( !checkProtocol )
        {
            MavenXpp3Reader m2pomReader = new MavenXpp3Reader();

            try
            {
                String filePath = pomUrl;

                if ( !filePath.startsWith( FILE_SCHEME + "/" ) && filePath.startsWith( FILE_SCHEME ) )
                {
                    //Little hack for linux (CONTINUUM-1169)
                    filePath = StringUtils.replace( filePath, FILE_SCHEME, FILE_SCHEME + "/" );
                }

                if ( filePath.startsWith( FILE_SCHEME ) )
                {
                    filePath = filePath.substring( FILE_SCHEME.length() );
                }

                Model model = m2pomReader.read( new FileReader( filePath ) );

                List modules = model.getModules();

                if ( modules != null && modules.size() != 0 )
                {
                    result = new ContinuumProjectBuildingResult();
                    result.addError( ERROR_UPLOADING_M2_PROJECT_WITH_MODULES );
                }
            }
            catch ( FileNotFoundException e )
            {
                throw new ContinuumException( ERROR_READING_POM_EXCEPTION_MESSAGE, e );
            }
            catch ( IOException e )
            {
                throw new ContinuumException( ERROR_READING_POM_EXCEPTION_MESSAGE, e );
            }
            catch ( XmlPullParserException e )
            {
                throw new ContinuumException( ERROR_READING_POM_EXCEPTION_MESSAGE, e );
            }
        }

        if ( result == null )
        {
            result = getContinuum().addMavenTwoProject( pomUrl, selectedProjectGroup, checkProtocol, scmUseCache,
                                                        !this.isNonRecursiveProject(),
                                                        this.getBuildDefinitionTemplateId() );
        }

        AuditLog event = new AuditLog( hidePasswordInUrl( pomUrl ), AuditLogConstants.ADD_M2_PROJECT );
        event.setCategory( AuditLogConstants.PROJECT );
        event.setCurrentUser( getPrincipal() );

        if ( result == null || result.hasErrors() )
        {
            event.setAction( AuditLogConstants.ADD_M2_PROJECT_FAILED );
        }

        event.log();
View Full Code Here

                addActionError( getText( "add.project.field.required.error" ) );
                return doDefault();
            }
        }

        ContinuumProjectBuildingResult result = doExecute( pom, selectedProjectGroup, checkProtocol, scmUseCache );

        if ( result.hasErrors() )
        {
            for ( String key : result.getErrors() )
            {
                String cause = result.getErrorsWithCause().get( key );
                String msg = getText( key, new String[]{cause} );

                // olamy : weird getText(key, String[]) must do that something like bla bla {0}
                // here an ugly hack for CONTINUUM-1675
                if ( key.equals( ContinuumProjectBuildingResult.ERROR_MISSING_SCM ) )
                {
                    msg = getResourceBundle().getString( key ) + " " + cause;
                }
                if ( !StringUtils.equals( msg, key ) )
                {
                    errorMessages.add( msg );
                }
                else
                {
                    addActionError( msg );
                }

            }

            return doDefault();
        }

        if ( this.getSelectedProjectGroup() > 0 )
        {
            this.setProjectGroupId( this.getSelectedProjectGroup() );
            return "projectGroupSummary";
        }

        if ( result.getProjectGroups() != null && !result.getProjectGroups().isEmpty() )
        {
            this.setProjectGroupId( ( result.getProjectGroups().get( 0 ) ).getId() );
            return "projectGroupSummary";
        }

        return SUCCESS;
    }
View Full Code Here

        ContinuumProjectBuilder projectBuilder =
            (ContinuumProjectBuilder) lookup( ContinuumProjectBuilder.ROLE, MavenTwoContinuumProjectBuilder.ID );

        URL url = getClass().getClassLoader().getResource( "projects/continuum/pom_ci.xml" );

        ContinuumProjectBuildingResult result = projectBuilder.buildProjectsFromMetadata( url, null, null );

        assertNotNull( result );

        // ----------------------------------------------------------------------
        // Assert the warnings
        // ----------------------------------------------------------------------

        assertNotNull( result.getErrors() );

        assertEquals( 1, result.getErrors().size() );

        assertEquals( ContinuumProjectBuildingResult.ERROR_POM_NOT_FOUND, result.getErrors().get( 0 ) );

        // ----------------------------------------------------------------------
        // Assert the project group built
        // ----------------------------------------------------------------------

        assertNotNull( result.getProjectGroups() );

        assertEquals( 1, result.getProjectGroups().size() );

        ProjectGroup projectGroup = result.getProjectGroups().iterator().next();

        assertEquals( "projectGroup.groupId", "org.apache.maven.continuum", projectGroup.getGroupId() );

        assertEquals( "projectGroup.name", "Continuum Parent Project", projectGroup.getName() );

        assertEquals( "projectGroup.description", "Continuum Project Description", projectGroup.getDescription() );

        // assertEquals( "projectGroup.url", "http://cvs.continuum.codehaus.org/", projectGroup.getUrl() );

        // ----------------------------------------------------------------------
        // Assert the projects built
        // ----------------------------------------------------------------------

        assertNotNull( result.getProjects() );

        assertEquals( 9, result.getProjects().size() );

        Map<String, Project> projects = new HashMap<String, Project>();

        for ( Project project : result.getProjects() )
        {
            assertNotNull( project.getName() );

            projects.put( project.getName(), project );
        }
View Full Code Here

        throws Exception
    {
        String metadataUrl = "http://test:;password@svn.apache.org/repos/asf/continuum/tags/continuum-1.1/continuum-api/pom.xml";
        DefaultContinuum continuum = (DefaultContinuum) lookup( Continuum.ROLE );
       
        ContinuumProjectBuildingResult result = continuum
            .executeAddProjectsFromMetadataActivity( metadataUrl, MavenTwoContinuumProjectBuilder.ID,
                                                     getDefaultProjectGroup().getId(), false, true, false, -1, false );
        assertEquals( 1, result.getProjects().size() );
       
        // read the project from store
        Project project = continuum.getProject( result.getProjects().get( 0 ).getId());
        assertNullproject.getScmUsername() );
        assertNull( project.getScmPassword() );
        assertTrue( project.isScmUseCache() );
    }
View Full Code Here

        logger.debug( "projectGroups number " + getProjectGroupDao().getAllProjectGroups().size() );

        int all = service.getAllBuildDefinitions().size();

        ContinuumProjectBuildingResult result;

        result = projectBuilder.buildProjectsFromMetadata( url, null, null, false, bdt );
        assertFalse( result.hasErrors() );

        assertEquals( 5, service.getAllBuildDefinitionTemplate().size() );

        assertEquals( all + 1, service.getAllBuildDefinitions().size() );

        assertNotNull( result );

        assertNotNull( result.getErrors() );

        assertEquals( 0, result.getErrors().size() );

        assertNotNull( result.getProjectGroups() );

        assertEquals( 1, result.getProjectGroups().size() );

        ProjectGroup projectGroup = result.getProjectGroups().get( 0 );

        assertEquals( "projectGroup.groupId", "org.apache.maven.continuum", projectGroup.getGroupId() );

        assertEquals( "projectGroup.name", "Continuum Core", projectGroup.getName() );

        assertNotNull( result.getProjects() );

        assertEquals( 1, result.getProjects().size() );

        assertNotNull( projectGroup.getProjects() );

        assertEquals( 0, projectGroup.getProjects().size() );
    }
View Full Code Here

        throws Exception
    {
        String metadataUrl = "http://test:;password@svn.apache.org/repos/asf/continuum/tags/continuum-1.1/continuum-api/pom.xml";
        DefaultContinuum continuum = (DefaultContinuum) lookup( Continuum.ROLE );

        ContinuumProjectBuildingResult result = continuum
            .executeAddProjectsFromMetadataActivity( metadataUrl, MavenTwoContinuumProjectBuilder.ID,
                                                     getDefaultProjectGroup().getId(), false, false, false, -1, false );
        assertEquals( 1, result.getProjects().size() );

        // read the project from store
        Project project = continuum.getProject( result.getProjects().get( 0 ).getId() );
        assertEquals( SCM_USERNAME, project.getScmUsername() );
        assertEquals( SCM_PASSWORD, project.getScmPassword() );
        assertFalse( project.isScmUseCache() );
    }   
View Full Code Here

        bdt.setName( "maven1" );
        bd = service.addBuildDefinition( bd );
        bdt = service.addBuildDefinitionTemplate( bdt );
        bdt = service.addBuildDefinitionInTemplate( bdt, bd, false );

        ContinuumProjectBuildingResult result = projectBuilder.buildProjectsFromMetadata(
            getTestFile( "src/test/resources/projects/maven-1.pom.xml" ).toURL(), null, null, false, bdt );

        assertOnResult( result );

    }
View Full Code Here

        ContinuumProjectBuilder projectBuilder =
            (ContinuumProjectBuilder) lookup( ContinuumProjectBuilder.ROLE, MavenOneContinuumProjectBuilder.ID );

        BuildDefinitionService service = (BuildDefinitionService) lookup( BuildDefinitionService.class );

        ContinuumProjectBuildingResult result = projectBuilder.buildProjectsFromMetadata(
            getTestFile( "src/test/resources/projects/maven-1.pom.xml" ).toURL(), null, null, false,
            service.getDefaultMavenOneBuildDefinitionTemplate() );

        assertOnResult( result );
View Full Code Here

TOP

Related Classes of org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult

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.