001 package org.apache.maven.eventspy; 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 022 import java.util.Map; 023 024 /** 025 * A core extension to monitor Maven's execution. Typically, such an extension gets loaded into Maven by specifying the 026 * system property {@code maven.ext.class.path} on the command line. As soon as dependency injection is setup, Maven 027 * looks up all implementators of this interface and calls their {@link #init(Context)} method. <em>Note:</em> 028 * Implementors are strongly advised to inherit from {@link AbstractEventSpy} instead of directly implementing this 029 * interface. 030 */ 031 public interface EventSpy 032 { 033 034 interface Context 035 { 036 037 /** 038 * Gets key-value pairs providing information about the Maven runtime. 039 * 040 * @return The key-value pairs, never {@code null}. 041 */ 042 Map<String, Object> getData(); 043 044 } 045 046 /** 047 * Initializes the spy. 048 * 049 * @param context The event spy context, never {@code null}. 050 */ 051 void init( Context context ) 052 throws Exception; 053 054 /** 055 * Notifies the spy of some build event/operation. 056 * 057 * @param event The event, never {@code null}. 058 * @see org.apache.maven.settings.building.SettingsBuildingRequest 059 * @see org.apache.maven.settings.building.SettingsBuildingResult 060 * @see org.apache.maven.execution.MavenExecutionRequest 061 * @see org.apache.maven.execution.MavenExecutionResult 062 * @see org.apache.maven.project.DependencyResolutionRequest 063 * @see org.apache.maven.project.DependencyResolutionResult 064 * @see org.apache.maven.execution.ExecutionEvent 065 * @see org.eclipse.aether.RepositoryEvent 066 */ 067 void onEvent( Object event ) 068 throws Exception; 069 070 /** 071 * Notifies the spy of Maven's termination, allowing it to free any resources allocated by it. 072 */ 073 void close() 074 throws Exception; 075 076 }