TargetTypeBuildScope (TargetTypeBuildScope scope1, TargetTypeBuildScope scope2) { String typeId = scope1.getTypeId(); if (scope1.getAllTargets()) { return !scope1.getForceBuild() && scope2.getForceBuild() ? createAllTargetForcedBuildScope(typeId) : scope1; } if (scope2.getAllTargets()) { return !scope2.getForceBuild() && scope1.getForceBuild() ? createAllTargetForcedBuildScope(typeId) : scope2; } return TargetTypeBuildScope.newBuilder() .setTypeId(typeId) .setForceBuild(scope1.getForceBuild() || scope2.getForceBuild()) .addAllTargetId(scope1.getTargetIdList()) .addAllTargetId(scope2.getTargetIdList()) .build(); }