use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.
the class GroupConfigurationProviderTest method testAddConfiguration.
@Test
public void testAddConfiguration() {
// With
final int bcId = 3773;
final BuildConfiguration buildConfiguration = mockBuildConfig(bcId, "NEWCOMER");
when(buildConfigurationRepository.queryById(bcId)).thenReturn(buildConfiguration);
// When
provider.addConfiguration(bcs.getId().toString(), Integer.toString(bcId));
// Then
org.jboss.pnc.dto.GroupConfiguration refreshed = provider.getSpecific(bcs.getId().toString());
assertThat(refreshed.getBuildConfigs()).containsKey(buildConfiguration.getId().toString());
}
use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.
the class DatastoreAdapter method loadBuildConfigurations.
/**
* Fetch build configurations of project to be able access it outside transaction
*
* @param buildConfigAudited build config for which the build configurations are to be fetched
*/
private void loadBuildConfigurations(BuildConfigurationAudited buildConfigAudited) {
Project project = buildConfigAudited.getProject();
project.getBuildConfigurations().forEach(BuildConfiguration::getId);
}
use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.
the class AbstractDependentBuildTest method config.
protected BuildConfiguration config(String name, BuildConfiguration... dependencies) {
BuildConfiguration config = buildConfig(name, dependencies);
saveConfig(config);
return config;
}
use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.
the class BuildTasksInitializer method createBuildSetTask.
/**
* Create a BuildSetTask of BuildConfigurations contained in the BuildConfigurationSet.
*
* A specific revision of the BuildConfigurations contained in the set is used, if it's available in the
* buildConfigurationAuditedsMap parameter. If it's not available, latest revision of the BuildConfiguration is
* used.
*
* @param buildConfigurationSet BuildConfigurationSet to be built
* @param buildConfigurationAuditedsMap A map BuildConfiguration::id:BuildConfigurationAudited of specific revisions
* of BuildConfigurations contained in the buildConfigurationSet
* @param user A user, who triggered the build
* @param buildOptions Build options
* @param buildTaskIdProvider Provider to get build task ID
* @param submittedBuildTasks Already submitted build tasks
* @return Prepared BuildSetTask
* @throws CoreException Thrown if the BuildConfigSetRecord cannot be stored
*/
public BuildSetTask createBuildSetTask(BuildConfigurationSet buildConfigurationSet, Map<Integer, BuildConfigurationAudited> buildConfigurationAuditedsMap, User user, BuildOptions buildOptions, Supplier<String> buildTaskIdProvider, Set<BuildTask> submittedBuildTasks) throws CoreException {
BuildSetTask buildSetTask = initBuildSetTask(buildConfigurationSet, user, buildOptions);
Set<BuildConfigurationAudited> buildConfigurationAuditeds = new HashSet<>();
for (BuildConfiguration buildConfiguration : datastoreAdapter.getBuildConfigurations(buildConfigurationSet)) {
BuildConfigurationAudited buildConfigurationAudited = buildConfigurationAuditedsMap.get(buildConfiguration.getId());
if (buildConfigurationAudited == null) {
buildConfigurationAudited = datastoreAdapter.getLatestBuildConfigurationAuditedInitializeBCDependencies(buildConfiguration.getId());
}
buildConfigurationAuditeds.add(buildConfigurationAudited);
}
// initializeBuildTasksInSet
log.debug("Initializing BuildTasks In Set for BuildConfigurationAuditeds: {}.", buildConfigurationAuditeds.stream().map(BuildConfigurationAudited::toString).collect(Collectors.joining("; ")));
fillBuildTaskSet(buildSetTask, user, buildTaskIdProvider, buildConfigurationSet.getCurrentProductMilestone(), buildConfigurationAuditeds, submittedBuildTasks, buildOptions);
return buildSetTask;
}
use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.
the class BuildTasksInitializer method collectDependentConfigurations.
/**
* Collects all BuildConfigurationAudited entities, that needs to be built.
*
* @param buildConfiguration Current BuildConfiguration used to resolve dependencies.
* @param buildConfigurationAudited Specific revision of a BuildConfiguration (passed as first parameter) to be
* potentially built
* @param toBuild Set of BuildConfigurationAudited entities planned to be built
* @param visited Set of BuildConfigurations, which were already evaluated, if should be built
* @param checkImplicitDependencies if implicit check of dependencies needs to be done
* @param forceRebuild if force build is required
* @param temporaryBuild if build is temporary
* @param processedDependenciesCache list containing any dependency which was already processed in previous
* iterations
* @return Returns true, if the buildConfiguration should be rebuilt, otherwise returns false.
*/
private boolean collectDependentConfigurations(BuildConfiguration buildConfiguration, BuildConfigurationAudited buildConfigurationAudited, Set<BuildConfigurationAudited> toBuild, Set<BuildConfiguration> visited, boolean checkImplicitDependencies, boolean forceRebuild, boolean temporaryBuild, AlignmentPreference alignmentPreference, Set<Integer> processedDependenciesCache) {
if (visited.contains(buildConfiguration)) {
return toBuild.contains(buildConfigurationAudited);
}
visited.add(buildConfiguration);
boolean requiresRebuild = forceRebuild || datastoreAdapter.requiresRebuild(buildConfigurationAudited, checkImplicitDependencies, temporaryBuild, alignmentPreference, processedDependenciesCache);
for (BuildConfiguration dependency : buildConfiguration.getDependencies()) {
boolean dependencyRequiresRebuild = collectDependentConfigurations(dependency, datastoreAdapter.getLatestBuildConfigurationAuditedInitializeBCDependencies(dependency.getId()), toBuild, visited, checkImplicitDependencies, forceRebuild, temporaryBuild, alignmentPreference, processedDependenciesCache);
requiresRebuild = requiresRebuild || dependencyRequiresRebuild;
}
log.debug("Configuration {} requires rebuild: {}", buildConfiguration.getId(), requiresRebuild);
if (requiresRebuild) {
toBuild.add(buildConfigurationAudited);
}
return requiresRebuild;
}
Aggregations