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.artifact.handler;
20  
21  import org.codehaus.plexus.component.annotations.Component;
22  
23  /**
24   * @author <a href="mailto:brett@apache.org">Brett Porter</a>
25   * @author Jason van Zyl
26   */
27  @Component(role = ArtifactHandler.class)
28  public class DefaultArtifactHandler implements ArtifactHandler {
29      private String extension;
30  
31      private String type;
32  
33      private String classifier;
34  
35      private String directory;
36  
37      private String packaging;
38  
39      private boolean includesDependencies;
40  
41      private String language;
42  
43      private boolean addedToClasspath;
44  
45      public DefaultArtifactHandler() {}
46  
47      public DefaultArtifactHandler(String type) {
48          this.type = type;
49      }
50  
51      public String getExtension() {
52          if (extension == null) {
53              extension = type;
54          }
55          return extension;
56      }
57  
58      public void setExtension(String extension) {
59          this.extension = extension;
60      }
61  
62      public String getType() {
63          return type;
64      }
65  
66      public String getClassifier() {
67          return classifier;
68      }
69  
70      public String getDirectory() {
71          if (directory == null) {
72              directory = getPackaging() + "s";
73          }
74          return directory;
75      }
76  
77      public String getPackaging() {
78          if (packaging == null) {
79              packaging = type;
80          }
81          return packaging;
82      }
83  
84      public boolean isIncludesDependencies() {
85          return includesDependencies;
86      }
87  
88      public void setIncludesDependencies(boolean includesDependencies) {
89          this.includesDependencies = includesDependencies;
90      }
91  
92      public String getLanguage() {
93          if (language == null) {
94              language = "none";
95          }
96  
97          return language;
98      }
99  
100     public void setLanguage(String language) {
101         this.language = language;
102     }
103 
104     public boolean isAddedToClasspath() {
105         return addedToClasspath;
106     }
107 
108     public void setAddedToClasspath(boolean addedToClasspath) {
109         this.addedToClasspath = addedToClasspath;
110     }
111 }