1 package org.apache.maven.plugin.source;
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 * Java sources artifact type handler.
26 *
27 * @author <a href="snicoll@apache.org">Stephane Nicoll</a>
28 * @version $Id: JavaSourceArtifactTypeHandler.java 371078 2006-01-21 15:55:44Z snicoll $
29 */
30 public class JavaSourceArtifactTypeHandler
31 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 * @throws MavenException if an error occured while building the path
40 */
41 public String constructRepositoryDirectoryPath( String type, Project project )
42 throws MavenException
43 {
44 StringBuffer path = new StringBuffer();
45 path.append( project.getArtifactDirectory() );
46 path.append( "/java-sources/" );
47 return path.toString();
48 }
49
50 /**
51 * Map an artifact to a repository path.
52 *
53 * @param project the project for the artifact
54 * @param type The type of the artifact
55 * @param version The version of the artifact (may be a snapshot)
56 * @return the path
57 * @throws MavenException if an error occured while building the path
58 */
59 public String constructRepositoryFullPath( String type, Project project, String version )
60 throws MavenException
61 {
62 StringBuffer path = new StringBuffer( constructRepositoryDirectoryPath( type, project ) );
63 path.append( project.getArtifactId() );
64 path.append( "-" );
65 path.append( version );
66
67 if ( type.equals( "java-source" ) )
68 {
69 path.append( "-sources.jar" );
70 }
71 else
72 {
73 throw new MavenException( "Unrecognised java-source type (is " + type + ")" );
74 }
75
76 return path.toString();
77 }
78 }