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      static class PluginArtifactHandler
60          implements ArtifactHandler
61      {
62          public String getClassifier()
63          {
64              return null;
65          }
66  
67          public String getDirectory()
68          {
69              return null;
70          }
71  
72          public String getExtension()
73          {
74              return "jar";
75          }
76  
77          public String getLanguage()
78          {
79              return "none";
80          }
81  
82          public String getPackaging()
83          {
84              return "maven-plugin";
85          }
86  
87          public boolean isAddedToClasspath()
88          {
89              return true;
90          }
91  
92          public boolean isIncludesDependencies()
93          {
94              return false;
95          }
96      }
97  }