1 package org.apache.maven.repository;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import org.apache.maven.project.Dependency;
22
23 /**
24 * Simple factory for creating Artifact implementations based on a dependency
25 * type.
26 *
27 * @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
28 * @version $Id: DefaultArtifactFactory.java 517014 2007-03-11 21:15:50Z ltheussl $
29 *
30 * @todo The factor needs to take a properties file describing the acceptable
31 * types of artifacts. We can have a default set and also allow users
32 * to customize the list for their own purposes.
33 */
34 public class DefaultArtifactFactory
35 {
36 /**
37 * Return an appropriate Artifact implementation based on the dependency
38 * type.
39 *
40 * @param dependency The base dependency.
41 * @todo not the intended usage of test type
42 * @return The appropriate artifact based on the dependency type.
43 */
44 public static Artifact createArtifact( Dependency dependency )
45 {
46
47
48 if ( ( dependency.getType() == null ) || ( dependency.getType().trim().length() == 0 )
49 || "jar".equals( dependency.getType() ) || "test".equals( dependency.getType() ) )
50 {
51 dependency.setType( "jar" );
52 return new GenericArtifact( dependency );
53 }
54 else
55 {
56 return new GenericArtifact( dependency );
57 }
58 }
59 }