Package org.apache.maven.continuum.model.project

Examples of org.apache.maven.continuum.model.project.Project


        }

        Collection<Project> projList = getContinuum().getProjectsInGroupWithDependencies( projectGroup.getId() );
        if ( projList != null && projList.size() > 0 )
        {
            Project rootProject = ( getContinuum().getProjectsInBuildOrder( projList ) ).get( 0 );

            if ( rootProject != null )
            {
                setUrl( rootProject.getUrl() );
            }
        }
        return SUCCESS;
    }
View Full Code Here


        getContinuum().updateProjectGroup( projectGroup );

        Collection<Project> projectList = getContinuum().getProjectsInGroupWithDependencies( projectGroupId );
        if ( projectList != null && projectList.size() > 0 )
        {
            Project rootProject = ( getContinuum().getProjectsInBuildOrder( projectList ) ).get( 0 );

            rootProject.setUrl( url );

            getContinuum().updateProject( rootProject );
        }

        Iterator keys = projects.keySet().iterator();
        while ( keys.hasNext() )
        {
            String key = (String) keys.next();

            String[] id = (String[]) projects.get( key );

            int projectId = Integer.parseInt( key );

            Project project = null;
            Iterator i = projectGroup.getProjects().iterator();
            while ( i.hasNext() )
            {
                project = (Project) i.next();
                if ( projectId == project.getId() )
                {
                    break;
                }
            }

            ProjectGroup newProjectGroup = getContinuum().getProjectGroupWithProjects( new Integer( id[0] ) );

            if ( newProjectGroup.getId() != projectGroup.getId() && isAuthorized( newProjectGroup.getName() ) )
            {
                logger.info( "Moving project " + project.getName() + " to project group " + newProjectGroup.getName() );
                project.setProjectGroup( newProjectGroup );

                // CONTINUUM-1512
                Collection<BuildResult> results = getContinuum().getBuildResultsForProject( project.getId() );
                for ( BuildResult br : results )
                {
                    getContinuum().removeBuildResult( br.getId() );
                }
View Full Code Here

        }

        // get the parent of the group by finding the parent project
        // i.e., the project that doesn't have a parent, or it's parent is not in the group.

        Project parent = null;

        boolean allBuildsOk = true;

        boolean allMavenTwo = true;

        projectList = getContinuum().getProjectsInGroupWithDependencies( projectGroupId );

        if ( projectList != null )
        {
            for ( Project p : projectList )
            {
                if ( p.getState() != ContinuumProjectState.OK )
                {
                    logger.info(
                        "Attempt to release group '" + projectGroup.getName() + "' failed as project '" + p.getName() +
                            "' is in state " + p.getState() );
                    allBuildsOk = false;
                }

                if ( ( p.getParent() == null ) || ( !isParentInProjectGroup( p.getParent(), projectList ) ) )
                {
                    if ( parent == null )
                    {
                        parent = p;
                    }
                    else
                    {
                        logger.info( "Attempt to release group '" + projectGroup.getName() + "' failed as project '" +
                            p.getName() + "' and project '" + parent.getName() + "' are both parents" );

                        // currently, we have no provisions for releasing 2 or more parents
                        // at the same time, this will be implemented in the future
                        addActionError( getText( "projectGroup.release.error.severalParentProjects" ) );
                        return INPUT;
                    }
                }

                if ( !"maven2".equals( p.getExecutorId() ) )
                {
                    logger.info(
                        "Attempt to release group '" + projectGroup.getName() + "' failed as project '" + p.getName() +
                            "' is not a Maven 2 project (executor '" + p.getExecutorId() + "')" );
                    allMavenTwo = false;
                }
            }
        }

        if ( parent == null )
        {
            addActionError( getText( "projectGroup.release.error.emptyGroup" ) );
            return INPUT;
        }

        releaseProjectId = parent.getId();

        if ( allBuildsOk && allMavenTwo )
        {
            return SUCCESS;
        }
View Full Code Here

            return null;
        }

        try
        {
            Project project = projectDao.getProjectWithAllDetails( ContinuumBuildConstant.getProjectId( context ) );
            List<ProjectDependency> dependencies = project.getDependencies();

            if ( dependencies == null )
            {
                dependencies = new ArrayList<ProjectDependency>();
            }

            if ( project.getParent() != null )
            {
                dependencies.add( project.getParent() );
            }

            if ( dependencies.isEmpty() )
            {
                return null;
            }

            List<ProjectDependency> modifiedDependencies = new ArrayList<ProjectDependency>();

            for ( ProjectDependency dep : dependencies )
            {
                Project dependencyProject =
                    projectDao.getProject( dep.getGroupId(), dep.getArtifactId(), dep.getVersion() );

                if ( dependencyProject != null )
                {
                    long nbBuild = buildResultDao.getNbBuildResultsInSuccessForProject( dependencyProject.getId(),
                                                                                        oldBuildResult.getEndTime() );
                    if ( nbBuild > 0 )
                    {
                        log.debug( "Dependency changed: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":" +
                            dep.getVersion() );
View Full Code Here

        {
            ArrayList<Project> projectsList = new ArrayList<Project>();
            for ( String pId : selectedProjects )
            {
                int projectId = Integer.parseInt( pId );
                Project p = getContinuum().getProjectWithAllDetails( projectId );
                projectsList.add( p );

                AuditLog event = new AuditLog( "Project id=" + projectId, AuditLogConstants.FORCE_BUILD );
                event.setCategory( AuditLogConstants.PROJECT );
                event.setCurrentUser( getPrincipal() );
View Full Code Here

        catch ( AuthorizationRequiredException e )
        {
            return REQUIRES_AUTHORIZATION;
        }

        Project project = getContinuum().getProject( projectId );
        projectName = project.getName();

        return "delete";
    }
View Full Code Here

            int projectId = ContinuumBuildConstant.getProjectId( context );
            int buildDefinitionId = ContinuumBuildConstant.getBuildDefinitionId( context );
   
            log.info( "update build result of project '" + projectId + "'" );
   
            Project project = projectDao.getProjectWithAllDetails( projectId );
            BuildDefinition buildDefinition = buildDefinitionDao.getBuildDefinition( buildDefinitionId );
   
            BuildResult oldBuildResult =
                buildResultDao.getLatestBuildResultForBuildDefinition( projectId, buildDefinitionId );
   
            int buildNumber;
   
            if ( ContinuumBuildConstant.getBuildState( context ) == ContinuumProjectState.OK )
            {
                buildNumber = project.getBuildNumber() + 1;
            }
            else
            {
                buildNumber = project.getBuildNumber();
            }
   
            // ----------------------------------------------------------------------
            // Make the buildResult
            // ----------------------------------------------------------------------
   
            BuildResult buildResult = distributedBuildUtil.convertMapToBuildResult( context );
   
            if ( buildResult.getState() != ContinuumProjectState.CANCELLED )
            {
                buildResult.setBuildDefinition( buildDefinition );
                buildResult.setBuildNumber( buildNumber );
                buildResult.setModifiedDependencies( distributedBuildUtil.getModifiedDependencies( oldBuildResult, context ) );
                buildResult.setScmResult( distributedBuildUtil.getScmResult( context ) );
   
                Date date = ContinuumBuildConstant.getLatestUpdateDate( context );
                if ( date != null )
                {
                    buildResult.setLastChangedDate( date.getTime() );
                }
                else if ( oldBuildResult != null )
                {
                    buildResult.setLastChangedDate( oldBuildResult.getLastChangedDate() );
                }
   
                buildResultDao.addBuildResult( project, buildResult );

                buildResult = buildResultDao.getBuildResult( buildResult.getId() );

                project.setOldState( project.getState() );
                project.setState( ContinuumBuildConstant.getBuildState( context ) );
                project.setBuildNumber( buildNumber );
                project.setLatestBuildId( buildResult.getId() );
            }
            else
            {
                project.setState( project.getOldState() );
                project.setOldState( 0 );
            }
   
            projectDao.updateProject( project );
   
            File buildOutputFile = configurationService.getBuildOutputFile( buildResult.getId(), project.getId() );
   
            FileWriter fstream = new FileWriter( buildOutputFile );
            BufferedWriter out = new BufferedWriter( fstream );
            out.write( ContinuumBuildConstant.getBuildOutput( context ) == null ? ""
                : ContinuumBuildConstant.getBuildOutput( context ) );
View Full Code Here

    public void startProjectBuild( int projectId )
        throws ContinuumException
    {
        try
        {
            Project project = projectDao.getProject( projectId );
            project.setState( ContinuumProjectState.BUILDING );
            projectDao.updateProject( project );
        }
        catch ( ContinuumStoreException e )
        {
            log.error( "Error while updating project's state (projectId=" + projectId + ")", e );
View Full Code Here

    public void updateProject( Map<String, Object> context )
        throws ContinuumException
    {
        try
        {
            Project project = projectDao.getProject( ContinuumBuildConstant.getProjectId( context ) );
   
            if ( StringUtils.isNotBlank( ContinuumBuildConstant.getGroupId( context ) ) )
            {
                project.setGroupId( ContinuumBuildConstant.getGroupId( context ) );
            }
            if ( StringUtils.isNotBlank( ContinuumBuildConstant.getArtifactId( context ) ) )
            {
                project.setArtifactId( ContinuumBuildConstant.getArtifactId( context ) );
            }
            if ( StringUtils.isNotBlank( ContinuumBuildConstant.getVersion( context ) ) )
            {
                project.setVersion( ContinuumBuildConstant.getVersion( context ) );
            }
            if ( StringUtils.isNotBlank( ContinuumBuildConstant.getProjectName( context ) ) )
            {
                project.setName( ContinuumBuildConstant.getProjectName( context ) );
            }
            if ( StringUtils.isNotBlank( ContinuumBuildConstant.getProjectDescription( context ) ) )
            {
                project.setDescription( ContinuumBuildConstant.getProjectDescription( context ) );
            }
            if ( StringUtils.isNotBlank( ContinuumBuildConstant.getProjectUrl( context ) ) )
            {
                project.setUrl( ContinuumBuildConstant.getProjectUrl( context ) );
            }
            if ( StringUtils.isNotBlank( ContinuumBuildConstant.getScmUrl( context ) ) )
            {
                project.setScmUrl( ContinuumBuildConstant.getScmUrl( context ) );
            }
            if ( StringUtils.isNotBlank( ContinuumBuildConstant.getScmTag( context ) ) )
            {
                project.setScmTag( ContinuumBuildConstant.getScmTag( context ) );
            }
            project.setParent( getProjectParent( context ) );
            project.setDependencies( getProjectDependencies( context ) );
            project.setDevelopers( getProjectDevelopers( context ) );
            project.setNotifiers( getProjectNotifiers( context ) );
   
            projectDao.updateProject( project );
        }
        catch ( ContinuumStoreException e )
        {
View Full Code Here

        {
            int buildDefinitionId = ContinuumBuildConstant.getBuildDefinitionId( context );
   
            int trigger = ContinuumBuildConstant.getTrigger( context );
   
            Project project = projectDao.getProjectWithAllDetails( projectId );
   
            BuildDefinition buildDefinition = buildDefinitionDao.getBuildDefinition( buildDefinitionId );
   
            BuildResult oldBuildResult =
                buildResultDao.getLatestBuildResultForBuildDefinition( projectId, buildDefinitionId );
   
            List<ProjectDependency> modifiedDependencies = distributedBuildUtil.getModifiedDependencies( oldBuildResult, context );
   
            List<ChangeSet> changes = distributedBuildUtil.getScmChanges( context );
   
            if ( buildDefinition.isBuildFresh() )
            {
                log.info( "FreshBuild configured, building (projectId=" + projectId + ")" );
                return true;
            }
            if ( buildDefinition.isAlwaysBuild() )
            {
                log.info( "AlwaysBuild configured, building (projectId=" + projectId + ")" );
                return true;
            }
            if ( oldBuildResult == null )
            {
                log.info( "The project '" +  projectId + "' was never built with the current build definition, building" );
                return true;
            }
   
            //CONTINUUM-1428
            if ( project.getOldState() == ContinuumProjectState.ERROR ||
                oldBuildResult.getState() == ContinuumProjectState.ERROR )
            {
                log.info( "Latest state was 'ERROR', building (projectId=" + projectId + ")" );
                return true;
            }
   
            if ( trigger == ContinuumProjectState.TRIGGER_FORCED )
            {
                log.info( "The project '" + projectId + "' build is forced, building" );
                return true;
            }
   
            Date date = ContinuumBuildConstant.getLatestUpdateDate( context );
            if ( date != null && oldBuildResult.getLastChangedDate() >= date.getTime() )
            {
                log.info( "No changes found, not building (projectId=" + projectId + ")" );
                return false;
            }
            else if ( date != null && changes.isEmpty() )
            {
                // fresh checkout from build agent that's why changes is empty
                log.info( "Changes found in the current project, building (projectId=" + projectId + ")" );
                return true;
            }
   
            boolean shouldBuild = false;
   
            boolean allChangesUnknown = true;
   
            if ( project.getOldState() != ContinuumProjectState.NEW &&
                project.getOldState() != ContinuumProjectState.CHECKEDOUT &&
                project.getState() != ContinuumProjectState.NEW &&
                project.getState() != ContinuumProjectState.CHECKEDOUT )
            {
                // Check SCM changes
                allChangesUnknown = checkAllChangesUnknown( changes );
   
                if ( allChangesUnknown )
                {
                    if ( !changes.isEmpty() )
                    {
                        log.info( "The project '" + projectId +
                            "' was not built because all changes are unknown (maybe local modifications or ignored files not defined in your SCM tool." );
                    }
                    else
                    {
                        log.info( "The project '" + projectId +
                            "' was not built because no changes were detected in sources since the last build." );
                    }
                }
   
                // Check dependencies changes
                if ( modifiedDependencies != null && !modifiedDependencies.isEmpty() )
                {
                    log.info( "Found dependencies changes, building (projectId=" + projectId + ")" );
                    shouldBuild = true;
                }
            }
   
            // Check changes
            if ( !shouldBuild && ( ( !allChangesUnknown && !changes.isEmpty() ) ||
                project.getExecutorId().equals( ContinuumBuildExecutorConstants.MAVEN_TWO_BUILD_EXECUTOR ) ) )
            {
                shouldBuild = shouldBuild( changes, buildDefinition, project, getMavenProjectVersion( context ),
                                           getMavenProjectModules( context ) );
            }
   
View Full Code Here

TOP

Related Classes of org.apache.maven.continuum.model.project.Project

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.