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