1 package org.apache.maven.ejb;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 import org.apache.maven.MavenException;
21 import org.apache.maven.project.Project;
22 import org.apache.maven.repository.ArtifactTypeHandler;
23
24 /***
25 * This will do until wagon debuts.
26 *
27 * @author <a href="mailto:havard@tracetracker.com">H?vard Bj?stad</a>
28 * @author <a href="mailto:vmassol@apache.org>Vincent Massol</a>
29 * @version $Id: EJBArtifactTypeHandler.java 232640 2005-08-14 20:46:54Z vmassol $
30 */
31 public class EJBArtifactTypeHandler implements ArtifactTypeHandler
32 {
33 /***
34 * Map an artifact to a repository directory path.
35 *
36 * @param project the project for the artifact
37 * @param type The type of the artifact
38 * @return the path
39 */
40 public String constructRepositoryDirectoryPath(String type, Project project) throws MavenException
41 {
42 StringBuffer path = new StringBuffer();
43 path.append(project.getArtifactDirectory());
44 path.append("/ejbs/");
45 return path.toString();
46 }
47
48 /***
49 * Map an artifact to a repository path.
50 *
51 * @param project the project for the artifact
52 * @param type The type of the artifact
53 * @param version The version of the artifact (may be a snapshot)
54 * @return the path
55 */
56 public String constructRepositoryFullPath(String type, Project project, String version) throws MavenException
57 {
58 StringBuffer path = new StringBuffer(constructRepositoryDirectoryPath(type, project));
59 path.append(project.getArtifactId());
60 path.append("-");
61 path.append(version);
62
63 if ( type.equals( "ejb-client" ) ) {
64 path.append( "-client.jar" );
65 }
66 else if ( type.equals( "ejb" ) ) {
67 path.append(".jar");
68 }
69 else {
70 throw new MavenException("Unrecognised ejb type (is " + type + ")");
71 }
72
73 return path.toString();
74 }
75 }