View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.plugin;
20  
21  import org.apache.maven.model.Plugin;
22  import org.apache.maven.plugin.descriptor.MojoDescriptor;
23  import org.codehaus.plexus.classworlds.realm.ClassRealm;
24  import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
25  import org.codehaus.plexus.component.repository.exception.ComponentRepositoryException;
26  import org.codehaus.plexus.configuration.PlexusConfigurationException;
27  
28  /**
29   * Exception which occurs to indicate that the plugin cannot be initialized due
30   * to some deeper problem with Plexus. Context information includes the groupId,
31   * artifactId, and version for the plugin; at times, the goal name for which
32   * execution failed; a message detailing the problem; the ClassRealm used to
33   * look up the plugin; and the Plexus exception that caused this error.
34   *
35   *
36   */
37  public class PluginContainerException extends PluginManagerException {
38  
39      private ClassRealm pluginRealm;
40  
41      public PluginContainerException(
42              MojoDescriptor mojoDescriptor, ClassRealm pluginRealm, String message, Throwable e) {
43          super(mojoDescriptor, message, e);
44  
45          this.pluginRealm = pluginRealm;
46      }
47  
48      public PluginContainerException(
49              MojoDescriptor mojoDescriptor, ClassRealm pluginRealm, String message, ComponentLookupException e) {
50          super(mojoDescriptor, message, e);
51  
52          this.pluginRealm = pluginRealm;
53      }
54  
55      public PluginContainerException(Plugin plugin, ClassRealm pluginRealm, String message, Throwable e) {
56          super(plugin, message, e);
57  
58          this.pluginRealm = pluginRealm;
59      }
60  
61      /**
62       * Ctor left for binary compatibility.
63       *
64       * @deprecated Use {@link #PluginContainerException(Plugin, ClassRealm, String, Throwable)}
65       */
66      @Deprecated
67      public PluginContainerException(
68              Plugin plugin, ClassRealm pluginRealm, String message, PlexusConfigurationException e) {
69          this(plugin, pluginRealm, message, (Throwable) e);
70      }
71  
72      /**
73       * Ctor left for binary compatibility.
74       *
75       * @deprecated Use {@link #PluginContainerException(Plugin, ClassRealm, String, Throwable)}
76       */
77      @Deprecated
78      public PluginContainerException(
79              Plugin plugin, ClassRealm pluginRealm, String message, ComponentRepositoryException e) {
80          this(plugin, pluginRealm, message, (Throwable) e);
81      }
82  
83      public ClassRealm getPluginRealm() {
84          return pluginRealm;
85      }
86  }