View Javadoc
1   package org.apache.maven.project.artifact;
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 java.util.Collections;
23  import java.util.List;
24  
25  import org.apache.maven.artifact.Artifact;
26  import org.apache.maven.artifact.DefaultArtifact;
27  import org.apache.maven.artifact.handler.ArtifactHandler;
28  import org.apache.maven.model.Dependency;
29  import org.apache.maven.model.Plugin;
30  
31  /**
32   * PluginArtifact
33   */
34  public class PluginArtifact
35      extends DefaultArtifact
36      implements ArtifactWithDependencies
37  {
38      private Plugin plugin;
39  
40      public PluginArtifact( Plugin plugin, Artifact pluginArtifact )
41      {
42          super( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion(), null, "maven-plugin", null,
43                 new PluginArtifactHandler() );
44          this.plugin = plugin;
45          setFile( pluginArtifact.getFile() );
46          setResolved( true );
47      }
48  
49      public List<Dependency> getDependencies()
50      {
51          return plugin.getDependencies();
52      }
53  
54      public List<Dependency> getManagedDependencies()
55      {
56          return Collections.emptyList();
57      }
58  
59      // TODO: this is duplicate of MavenPluginArtifactHandlerProvider provided one
60      static class PluginArtifactHandler
61          implements ArtifactHandler
62      {
63          public String getClassifier()
64          {
65              return null;
66          }
67  
68          public String getDirectory()
69          {
70              return null;
71          }
72  
73          public String getExtension()
74          {
75              return "jar";
76          }
77  
78          public String getLanguage()
79          {
80              return "none";
81          }
82  
83          public String getPackaging()
84          {
85              return "maven-plugin";
86          }
87  
88          public boolean isAddedToClasspath()
89          {
90              return true;
91          }
92  
93          public boolean isIncludesDependencies()
94          {
95              return false;
96          }
97      }
98  }