private String getScmRootUrl( List<Project> projects ) { String scmRootUrl = ""; for ( Project project : projects ) { String scmUrl = project.getScmUrl(); scmRootUrl = getCommonPath( scmUrl, scmRootUrl ); } return scmRootUrl; }
private boolean pomUpdated( String buildFile, ScmResult scmResult, Project project ) { String filename = project.getScmUrl() + "/" + buildFile; for ( Iterator changeIt = scmResult.getChanges().listIterator(); changeIt.hasNext(); ) { ChangeSet change = (ChangeSet) changeIt.next(); for ( Iterator fileIt = change.getFiles().listIterator(); fileIt.hasNext(); ) { ChangeFile changeFile = (ChangeFile) fileIt.next(); if ( filename.endsWith( changeFile.getName() ) ) { return true; } } } return false; }
public ProjectScmRoot getProjectScmRootByProject( int projectId ) throws ContinuumException { Project project = getProject( projectId ); ProjectGroup group = getProjectGroupByProjectId( projectId ); List<ProjectScmRoot> scmRoots = getProjectScmRootByProjectGroup( group.getId() ); for ( ProjectScmRoot scmRoot : scmRoots ) { if ( project.getScmUrl() != null && project.getScmUrl().startsWith( scmRoot.getScmRootAddress() ) ) { return scmRoot; } } return null; }
private Map createProjectMap( Project project ) { Map<String, Object> map = new HashMap<String, Object>(); map.put( DistributedReleaseUtil.KEY_PROJECT_ID, project.getId() ); map.put( DistributedReleaseUtil.KEY_GROUP_ID, project.getGroupId() ); map.put( DistributedReleaseUtil.KEY_ARTIFACT_ID, project.getArtifactId() ); map.put( DistributedReleaseUtil.KEY_SCM_URL, project.getScmUrl() ); if ( project.getProjectGroup().getLocalRepository() != null ) { map.put( DistributedReleaseUtil.KEY_LOCAL_REPOSITORY_NAME, project.getProjectGroup().getLocalRepository().getName() ); } return map; }
private void createProjectScmRootForProjectGroup( ProjectGroup projectGroup ) throws ContinuumException { List<Project> projectsList; projectsList = getProjectsInBuildOrder( projectDao.getProjectsWithDependenciesByGroupId( projectGroup.getId() ) ); List<ProjectScmRoot> scmRoots = getProjectScmRootByProjectGroup( projectGroup.getId() ); String url = ""; for ( Project project : projectsList ) { boolean found = false; if ( StringUtils.isEmpty( url ) || !project.getScmUrl().startsWith( url ) ) { // this is a root project or the project is part of a flat multi module url = project.getScmUrl(); //createProjectScmRoot( projectGroup, url ); for ( ProjectScmRoot scmRoot : scmRoots ) { if ( url.startsWith( scmRoot.getScmRootAddress() ) ) { found = true; } } if ( !found ) { createProjectScmRoot( projectGroup, url ); } } } }
private ContinuumScmConfiguration createScmConfiguration( Project project, File workingDirectory, String scmUserName, String scmPassword ) { ContinuumScmConfiguration config = new ContinuumScmConfiguration(); // CONTINUUM-2628 config = ContinuumScmUtils.setSCMCredentialsforSSH( config, project.getScmUrl(), scmUserName, scmPassword ); config.setUrl( project.getScmUrl() ); config.setUseCredentialsCache( project.isScmUseCache() ); config.setWorkingDirectory( workingDirectory ); config.setTag( project.getScmTag() ); return config; }
private void updateProjectScmRoot( ProjectScmRoot oldScmRoot, Project project ) throws ContinuumException { try { removeProjectScmRoot( oldScmRoot ); ProjectScmRoot scmRoot = projectScmRootDao.getProjectScmRootByProjectGroupAndScmRootAddress( project.getProjectGroup().getId(), project.getScmUrl() ); if ( scmRoot == null ) { ProjectScmRoot newScmRoot = new ProjectScmRoot(); if ( project.getScmUrl().equals( oldScmRoot.getScmRootAddress() ) ) { BeanUtils.copyProperties( oldScmRoot, newScmRoot, new String[]{"id", "projectGroup"} ); } else { newScmRoot.setScmRootAddress( project.getScmUrl() ); } newScmRoot.setProjectGroup( project.getProjectGroup() ); projectScmRootDao.addProjectScmRoot( newScmRoot ); } } catch ( ContinuumStoreException ex ) { throw logAndCreateException( "Error while updating project.", ex ); } }
private ContinuumScmConfiguration createScmConfiguration( Project project, File workingDirectory ) { ContinuumScmConfiguration config = new ContinuumScmConfiguration(); config.setUrl( project.getScmUrl() ); // CONTINUUM-2628 config = ContinuumScmUtils.setSCMCredentialsforSSH( config, project.getScmUrl(), project.getScmUsername(), project.getScmPassword() ); config.setUseCredentialsCache( project.isScmUseCache() ); config.setWorkingDirectory( workingDirectory ); config.setTag( project.getScmTag() ); return config; }
public void execute( Map context ) throws Exception { Project project = projectDao.getProject( getProjectId( context ) ); List<Project> projectsWithCommonScmRoot = getListOfProjectsInGroupWithCommonScmRoot( context ); String projectScmRootUrl = getProjectScmRootUrl( context, project.getScmUrl() ); File workingDirectory = workingDirectoryService.getWorkingDirectory( project, projectScmRootUrl, projectsWithCommonScmRoot ); if ( !workingDirectory.exists() ) { setWorkingDirectoryExists( context, false ); return; } File[] files = workingDirectory.listFiles(); if ( files == null ) { //workingDirectory isn't a directory but a file. Not possible in theory. String msg = workingDirectory.getAbsolutePath() + " isn't a directory but a file."; getLogger().error( msg ); throw new ContinuumException( msg ); } setWorkingDirectoryExists( context, files.length > 0 ); }
if ( project.getScmUrl().startsWith( projectScmRoot.getScmRootAddress() ) )
private ScmRepository getScmRepository( Project project, boolean useCredentialsCache ) throws ScmRepositoryException, NoSuchScmProviderException { ScmRepository repository = scmManager.makeScmRepository( project.getScmUrl().trim() ); repository.getProviderRepository().setPersistCheckout( true ); if ( !( useCredentialsCache && repository.getProvider().equals( "svn" ) ) ) { if ( !StringUtils.isEmpty( project.getScmUsername() ) ) { repository.getProviderRepository().setUser( project.getScmUsername() ); if ( !StringUtils.isEmpty( project.getScmPassword() ) ) { repository.getProviderRepository().setPassword( project.getScmPassword() ); } else { repository.getProviderRepository().setPassword( "" ); } } } if ( repository.getProvider().equals( "perforce" ) ) { //Remove the clientspec name, so it will be recalcuated between each command for each project //instead of use the same for all projects System.setProperty( "maven.scm.perforce.clientspec.name", "" ); } return repository; }
public void execute( Map context ) throws Exception { Project project = projectDao.getProject( getProjectId( context ) ); List<Project> projectsWithCommonScmRoot = getListOfProjectsInGroupWithCommonScmRoot( context ); String projectScmRootUrl = getProjectScmRootUrl( context, project.getScmUrl() ); File workingDirectory = workingDirectoryService.getWorkingDirectory( project, projectScmRootUrl, projectsWithCommonScmRoot ); if ( workingDirectory.exists() ) { FileSetManager fileSetManager = new FileSetManager(); FileSet fileSet = new FileSet(); fileSet.setDirectory( workingDirectory.getPath() ); fileSet.addInclude( "**/**" ); // TODO : this with a configuration option somewhere ? fileSet.setFollowSymlinks( false ); fileSetManager.delete( fileSet ); } } }
private ContinuumScmConfiguration createScmConfiguration( Project project, File workingDirectory, String scmUserName, String scmPassword, String scmRootUrl, boolean isRootDirectory ) { ContinuumScmConfiguration config = new ContinuumScmConfiguration(); if ( project.isCheckedOutInSingleDirectory() && scmRootUrl != null && !"".equals( scmRootUrl ) && isRootDirectory ) { config.setUrl( scmRootUrl ); } else { config.setUrl( project.getScmUrl() ); } // CONTINUUM-2628 config = ContinuumScmUtils.setSCMCredentialsforSSH( config, config.getUrl(), scmUserName, scmPassword ); config.setUseCredentialsCache( project.isScmUseCache() ); config.setWorkingDirectory( workingDirectory ); config.setTag( project.getScmTag() ); return config; }
private ContinuumScmConfiguration createScmConfiguration( Project project, File workingDirectory ) { ContinuumScmConfiguration config = new ContinuumScmConfiguration(); config.setUrl( project.getScmUrl() ); config.setUsername( project.getScmUsername() ); config.setPassword( project.getScmPassword() ); config.setUseCredentialsCache( project.isScmUseCache() ); config.setWorkingDirectory( workingDirectory ); config.setTag( project.getScmTag() ); return config; }
private ContinuumScmConfiguration createScmConfiguration( Project project, File workingDirectory, String scmRootUrl ) { ContinuumScmConfiguration config = new ContinuumScmConfiguration(); if ( project.isCheckedOutInSingleDirectory() && scmRootUrl != null && !"".equals( scmRootUrl ) ) { config.setUrl( scmRootUrl ); } else { config.setUrl( project.getScmUrl() ); } // CONTINUUM-2628 config = ContinuumScmUtils.setSCMCredentialsforSSH( config, config.getUrl(), project.getScmUsername(), project.getScmPassword() ); config.setUseCredentialsCache( project.isScmUseCache() ); config.setWorkingDirectory( workingDirectory ); config.setTag( project.getScmTag() ); return config; }
String projectScmRootUrl = getProjectScmRootUrl( context, project.getScmUrl() );