Search in sources :

Example 1 with RevisionRule

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;
}
Also used : RevisionRule(jetbrains.buildServer.artifacts.RevisionRule) SArtifactDependency(jetbrains.buildServer.serverSide.artifacts.SArtifactDependency) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

RevisionRule (jetbrains.buildServer.artifacts.RevisionRule)1 SArtifactDependency (jetbrains.buildServer.serverSide.artifacts.SArtifactDependency)1 NotNull (org.jetbrains.annotations.NotNull)1