001package org.apache.maven.lifecycle.internal; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import org.apache.maven.execution.ProjectDependencyGraph; 023import org.apache.maven.lifecycle.internal.builder.BuilderCommon; 024import org.apache.maven.project.MavenProject; 025 026import java.util.Collection; 027import java.util.Collections; 028import java.util.HashSet; 029 030/** 031 * Contains status information that is global to an entire reactor build. 032 * 033 * @since 3.0 034 * @author <a href="mailto:kristian.rosenvold@gmail.com">Kristian Rosenvold</a> 035 */ 036public class ReactorBuildStatus 037{ 038 private final ProjectDependencyGraph projectDependencyGraph; 039 040 private final Collection<String> blackListedProjects = Collections.synchronizedSet( new HashSet<String>() ); 041 042 private volatile boolean halted = false; 043 044 public ReactorBuildStatus( ProjectDependencyGraph projectDependencyGraph ) 045 { 046 this.projectDependencyGraph = projectDependencyGraph; 047 } 048 049 public boolean isBlackListed( MavenProject project ) 050 { 051 return blackListedProjects.contains( BuilderCommon.getKey( project ) ); 052 } 053 054 public void blackList( MavenProject project ) 055 { 056 if ( blackListedProjects.add( BuilderCommon.getKey( project ) ) && projectDependencyGraph != null ) 057 { 058 for ( MavenProject downstreamProject : projectDependencyGraph.getDownstreamProjects( project, true ) ) 059 { 060 blackListedProjects.add( BuilderCommon.getKey( downstreamProject ) ); 061 } 062 } 063 } 064 065 public void halt() 066 { 067 halted = true; 068 } 069 070 public boolean isHalted() 071 { 072 return halted; 073 } 074 075 public boolean isHaltedOrBlacklisted( MavenProject mavenProject ) 076 { 077 return isBlackListed( mavenProject ) || isHalted(); 078 } 079 080}