View Javadoc

1   package org.apache.maven.plugin;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
23  import org.apache.maven.model.Plugin;
24  import org.apache.maven.plugin.descriptor.MojoDescriptor;
25  import org.apache.maven.plugin.descriptor.PluginDescriptor;
26  import org.apache.maven.project.MavenProject;
27  import org.codehaus.plexus.PlexusContainerException;
28  import org.codehaus.plexus.classworlds.realm.NoSuchRealmException;
29  import org.codehaus.plexus.component.repository.exception.ComponentRepositoryException;
30  import org.codehaus.plexus.configuration.PlexusConfigurationException;
31  
32  /**
33   * Exception in the plugin manager.
34   *
35   * @author <a href="mailto:brett@apache.org">Brett Porter</a>
36   * @version $Id: PluginManagerException.java 958295 2010-06-26 23:16:18Z hboutemy $
37   */
38  public class PluginManagerException
39      extends Exception
40  {
41  
42      private final String pluginGroupId;
43  
44      private final String pluginArtifactId;
45  
46      private final String pluginVersion;
47  
48      private String goal;
49  
50      private MavenProject project;
51  
52      protected PluginManagerException( Plugin plugin, String message, MavenProject project, Throwable cause )
53      {
54          super( message, cause );
55  
56          this.project = project;
57          pluginGroupId = plugin.getGroupId();
58          pluginArtifactId = plugin.getArtifactId();
59          pluginVersion = plugin.getVersion();
60      }
61  
62      public PluginManagerException( Plugin plugin, String message, Throwable cause )
63      {
64          super( message, cause );
65  
66          pluginGroupId = plugin.getGroupId();
67          pluginArtifactId = plugin.getArtifactId();
68          pluginVersion = plugin.getVersion();
69      }
70  
71      protected PluginManagerException( MojoDescriptor mojoDescriptor, String message, Throwable cause )
72      {
73          super( message, cause );
74          pluginGroupId = mojoDescriptor.getPluginDescriptor().getGroupId();
75          pluginArtifactId = mojoDescriptor.getPluginDescriptor().getArtifactId();
76          pluginVersion = mojoDescriptor.getPluginDescriptor().getVersion();
77          goal = mojoDescriptor.getGoal();
78      }
79  
80      protected PluginManagerException( MojoDescriptor mojoDescriptor, MavenProject project, String message )
81      {
82          super( message );
83          this.project = project;
84          pluginGroupId = mojoDescriptor.getPluginDescriptor().getGroupId();
85          pluginArtifactId = mojoDescriptor.getPluginDescriptor().getArtifactId();
86          pluginVersion = mojoDescriptor.getPluginDescriptor().getVersion();
87          goal = mojoDescriptor.getGoal();
88      }
89  
90      protected PluginManagerException( MojoDescriptor mojoDescriptor, MavenProject project, String message,
91                                        Throwable cause )
92      {
93          super( message, cause );
94          this.project = project;
95          pluginGroupId = mojoDescriptor.getPluginDescriptor().getGroupId();
96          pluginArtifactId = mojoDescriptor.getPluginDescriptor().getArtifactId();
97          pluginVersion = mojoDescriptor.getPluginDescriptor().getVersion();
98          goal = mojoDescriptor.getGoal();
99      }
100 
101     public PluginManagerException( Plugin plugin, InvalidVersionSpecificationException cause )
102     {
103         super( cause );
104 
105         pluginGroupId = plugin.getGroupId();
106         pluginArtifactId = plugin.getArtifactId();
107         pluginVersion = plugin.getVersion();
108     }
109 
110     public PluginManagerException( Plugin plugin, String message, PlexusConfigurationException cause )
111     {
112         super( message, cause );
113 
114         pluginGroupId = plugin.getGroupId();
115         pluginArtifactId = plugin.getArtifactId();
116         pluginVersion = plugin.getVersion();
117     }
118 
119     public PluginManagerException( Plugin plugin, String message, ComponentRepositoryException cause )
120     {
121         super( message, cause );
122 
123         pluginGroupId = plugin.getGroupId();
124         pluginArtifactId = plugin.getArtifactId();
125         pluginVersion = plugin.getVersion();
126     }
127 
128     public PluginManagerException( MojoDescriptor mojoDescriptor, MavenProject project, String message,
129                                    NoSuchRealmException cause )
130     {
131         super( message, cause );
132 
133         this.project = project;
134         pluginGroupId = mojoDescriptor.getPluginDescriptor().getGroupId();
135         pluginArtifactId = mojoDescriptor.getPluginDescriptor().getArtifactId();
136         pluginVersion = mojoDescriptor.getPluginDescriptor().getVersion();
137         goal = mojoDescriptor.getGoal();
138     }
139 
140     public PluginManagerException( MojoDescriptor mojoDescriptor, String message, MavenProject project,
141                                    PlexusContainerException cause )
142     {
143         super( message, cause );
144 
145         this.project = project;
146 
147         PluginDescriptor pd = mojoDescriptor.getPluginDescriptor();
148         pluginGroupId = pd.getGroupId();
149         pluginArtifactId = pd.getArtifactId();
150         pluginVersion = pd.getVersion();
151 
152         goal = mojoDescriptor.getGoal();
153     }
154 
155     public PluginManagerException( Plugin plugin, String message, PlexusContainerException cause )
156     {
157         super( message, cause );
158 
159         pluginGroupId = plugin.getGroupId();
160         pluginArtifactId = plugin.getArtifactId();
161         pluginVersion = plugin.getVersion();
162     }
163 
164     public PluginManagerException( Plugin plugin, String message, MavenProject project )
165     {
166         super( message );
167 
168         pluginGroupId = plugin.getGroupId();
169         pluginArtifactId = plugin.getArtifactId();
170         pluginVersion = plugin.getVersion();
171         this.project = project;
172     }
173 
174     public String getPluginGroupId()
175     {
176         return pluginGroupId;
177     }
178 
179     public String getPluginArtifactId()
180     {
181         return pluginArtifactId;
182     }
183 
184     public String getPluginVersion()
185     {
186         return pluginVersion;
187     }
188 
189     public String getGoal()
190     {
191         return goal;
192     }
193 
194     public MavenProject getProject()
195     {
196         return project;
197     }
198 }