use of jetbrains.buildServer.artifacts.RevisionRule in project teamcity-rest by JetBrains.
the class Build method getBuildPatchedDeps.
@NotNull
private List<SArtifactDependency> getBuildPatchedDeps(@NotNull final List<SArtifactDependency> originalDeps, final boolean useAllOriginalDeps, @NotNull final ServiceLocator serviceLocator, @NotNull final List<BuildPromotion> artifactDepsBuilds) {
List<SArtifactDependency> originalDepsCopy = useAllOriginalDeps ? new ArrayList<>(originalDeps) : null;
Map<String, Integer> processedBuildsByBuildTypeExternalId = new HashMap<>();
final ArtifactDependencyFactory artifactDependencyFactory = serviceLocator.getSingletonService(ArtifactDependencyFactory.class);
List<SArtifactDependency> result = new ArrayList<>(artifactDepsBuilds.size());
for (BuildPromotion source : artifactDepsBuilds) {
Integer buildTypeProcessedBuilds = processedBuildsByBuildTypeExternalId.get(source.getBuildTypeExternalId());
if (buildTypeProcessedBuilds == null) {
buildTypeProcessedBuilds = 0;
}
final SArtifactDependency originalDep = getArtifactDependency(originalDeps, source.getBuildType(), buildTypeProcessedBuilds);
processedBuildsByBuildTypeExternalId.put(source.getBuildTypeExternalId(), buildTypeProcessedBuilds + 1);
final SBuild associatedBuild = source.getAssociatedBuild();
final RevisionRule revisionRule = RevisionRules.newBuildIdRule(source.getId(), associatedBuild != null ? associatedBuild.getBuildNumber() : null);
final SArtifactDependency dep = artifactDependencyFactory.createArtifactDependency(source.getBuildTypeExternalId(), originalDep.getSourcePaths(), revisionRule);
dep.setCleanDestinationFolder(originalDep.isCleanDestinationFolder());
result.add(dep);
if (useAllOriginalDeps) {
originalDepsCopy.remove(originalDep);
}
}
if (useAllOriginalDeps && !originalDepsCopy.isEmpty()) {
result.addAll(originalDepsCopy);
}
return result;
}
Aggregations