public ContinuumProjectBuildingResult buildProjectsFromMetadata( URL url, String username, String password,
boolean recursiveProjects,
BuildDefinitionTemplate buildDefinitionTemplate )
throws ContinuumProjectBuilderException
{
ContinuumProjectBuildingResult result = new ContinuumProjectBuildingResult();
File pomFile;
pomFile = createMetadataFile( result, url, username, password );
if ( pomFile == null )
{
return result;
}
Project project = new Project();
try
{
metadataHelper.mapMetadata( result, pomFile, project, true);
if ( result.hasErrors() )
{
return result;
}
for ( BuildDefinition bd : (List<BuildDefinition>) buildDefinitionTemplate.getBuildDefinitions() )
{
BuildDefinition cloneBuildDefinition = buildDefinitionService.cloneBuildDefinition( bd );
cloneBuildDefinition.setTemplate( false );
project.addBuildDefinition( cloneBuildDefinition );
}
result.addProject( project, MavenOneBuildExecutor.ID );
}
catch ( MavenOneMetadataHelperException e )
{
log.error( "Unknown error while processing metadata", e );
result.addError( ContinuumProjectBuildingResult.ERROR_UNKNOWN );
}
finally
{
if ( pomFile.exists() )
{
pomFile.delete();
}
}
ProjectGroup projectGroup = new ProjectGroup();
// ----------------------------------------------------------------------
// Group id
// ----------------------------------------------------------------------
if ( StringUtils.isEmpty( project.getGroupId() ) )
{
result.addError( ContinuumProjectBuildingResult.ERROR_MISSING_GROUPID );
}
projectGroup.setGroupId( project.getGroupId() );
// ----------------------------------------------------------------------
// Name
// ----------------------------------------------------------------------
String name = project.getName();
if ( StringUtils.isEmpty( name ) )
{
name = project.getGroupId();
}
projectGroup.setName( name );
// ----------------------------------------------------------------------
// Description
// ----------------------------------------------------------------------
projectGroup.setDescription( project.getDescription() );
result.addProjectGroup( projectGroup );
return result;
}