001package org.apache.maven.lifecycle; 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 java.util.List; 023import java.util.concurrent.CopyOnWriteArrayList; 024 025import javax.inject.Named; 026import javax.inject.Singleton; 027 028import org.apache.maven.execution.ProjectExecutionEvent; 029import org.apache.maven.execution.ProjectExecutionListener; 030 031@Named 032@Singleton 033public class DelegatingProjectExecutionListener 034 implements ProjectExecutionListener 035{ 036 private final List<ProjectExecutionListener> listeners = new CopyOnWriteArrayList<ProjectExecutionListener>(); 037 038 public void beforeProjectExecution( ProjectExecutionEvent event ) 039 throws LifecycleExecutionException 040 { 041 for ( ProjectExecutionListener listener : listeners ) 042 { 043 listener.beforeProjectExecution( event ); 044 } 045 } 046 047 public void beforeProjectLifecycleExecution( ProjectExecutionEvent event ) 048 throws LifecycleExecutionException 049 { 050 for ( ProjectExecutionListener listener : listeners ) 051 { 052 listener.beforeProjectLifecycleExecution( event ); 053 } 054 } 055 056 public void afterProjectExecutionSuccess( ProjectExecutionEvent event ) 057 throws LifecycleExecutionException 058 { 059 for ( ProjectExecutionListener listener : listeners ) 060 { 061 listener.afterProjectExecutionSuccess( event ); 062 } 063 } 064 065 public void afterProjectExecutionFailure( ProjectExecutionEvent event ) 066 { 067 for ( ProjectExecutionListener listener : listeners ) 068 { 069 listener.afterProjectExecutionFailure( event ); 070 } 071 } 072 073 public void addProjectExecutionListener( ProjectExecutionListener listener ) 074 { 075 this.listeners.add( listener ); 076 } 077 078 public void removeProjectExecutionListener( ProjectExecutionListener listener ) 079 { 080 this.listeners.remove( listener ); 081 } 082}