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  public class PluginArtifact
32      extends DefaultArtifact
33      implements ArtifactWithDependencies
34  {
35      private Plugin plugin;
36  
37      public PluginArtifact( Plugin plugin, Artifact pluginArtifact )
38      {
39          super( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion(), null, "maven-plugin", null,
40                 new PluginArtifactHandler() );
41          this.plugin = plugin;
42          setFile( pluginArtifact.getFile() );
43          setResolved( true );
44      }
45  
46      public List<Dependency> getDependencies()
47      {
48          return plugin.getDependencies();
49      }
50  
51      public List<Dependency> getManagedDependencies()
52      {
53          return Collections.emptyList();
54      }
55  
56      static class PluginArtifactHandler
57          implements ArtifactHandler
58      {
59          public String getClassifier()
60          {
61              return null;
62          }
63  
64          public String getDirectory()
65          {
66              return null;
67          }
68  
69          public String getExtension()
70          {
71              return "jar";
72          }
73  
74          public String getLanguage()
75          {
76              return "none";
77          }
78  
79          public String getPackaging()
80          {
81              return "maven-plugin";
82          }
83  
84          public boolean isAddedToClasspath()
85          {
86              return true;
87          }
88  
89          public boolean isIncludesDependencies()
90          {
91              return false;
92          }
93      }
94  }